summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/animated_sprite.cpp2
-rw-r--r--scene/2d/animated_sprite.h2
-rw-r--r--scene/2d/area_2d.cpp18
-rw-r--r--scene/2d/area_2d.h2
-rw-r--r--scene/2d/audio_stream_player_2d.cpp13
-rw-r--r--scene/2d/back_buffer_copy.cpp8
-rw-r--r--scene/2d/back_buffer_copy.h2
-rw-r--r--scene/2d/camera_2d.cpp28
-rw-r--r--scene/2d/camera_2d.h2
-rw-r--r--scene/2d/canvas_item.cpp67
-rw-r--r--scene/2d/canvas_item.h12
-rw-r--r--scene/2d/canvas_modulate.cpp2
-rw-r--r--scene/2d/canvas_modulate.h2
-rw-r--r--scene/2d/collision_object_2d.cpp2
-rw-r--r--scene/2d/collision_object_2d.h2
-rw-r--r--scene/2d/collision_polygon_2d.cpp18
-rw-r--r--scene/2d/collision_polygon_2d.h2
-rw-r--r--scene/2d/collision_shape_2d.cpp12
-rw-r--r--scene/2d/collision_shape_2d.h2
-rw-r--r--scene/2d/joints_2d.cpp22
-rw-r--r--scene/2d/joints_2d.h4
-rw-r--r--scene/2d/light_2d.cpp18
-rw-r--r--scene/2d/light_2d.h2
-rw-r--r--scene/2d/light_occluder_2d.cpp12
-rw-r--r--scene/2d/light_occluder_2d.h2
-rw-r--r--scene/2d/line_2d.cpp18
-rw-r--r--scene/2d/line_2d.h2
-rw-r--r--scene/2d/line_builder.cpp2
-rw-r--r--scene/2d/line_builder.h2
-rw-r--r--scene/2d/navigation2d.cpp87
-rw-r--r--scene/2d/navigation2d.h6
-rw-r--r--scene/2d/navigation_polygon.cpp17
-rw-r--r--scene/2d/navigation_polygon.h2
-rw-r--r--scene/2d/node_2d.cpp4
-rw-r--r--scene/2d/node_2d.h4
-rw-r--r--scene/2d/parallax_background.cpp4
-rw-r--r--scene/2d/parallax_background.h4
-rw-r--r--scene/2d/parallax_layer.cpp21
-rw-r--r--scene/2d/parallax_layer.h6
-rw-r--r--scene/2d/particles_2d.cpp11
-rw-r--r--scene/2d/particles_2d.h4
-rw-r--r--scene/2d/path_2d.cpp19
-rw-r--r--scene/2d/path_2d.h4
-rw-r--r--scene/2d/path_texture.cpp2
-rw-r--r--scene/2d/path_texture.h2
-rw-r--r--scene/2d/physics_body_2d.cpp72
-rw-r--r--scene/2d/physics_body_2d.h2
-rw-r--r--scene/2d/polygon_2d.cpp26
-rw-r--r--scene/2d/polygon_2d.h10
-rw-r--r--scene/2d/position_2d.cpp6
-rw-r--r--scene/2d/position_2d.h2
-rw-r--r--scene/2d/ray_cast_2d.cpp28
-rw-r--r--scene/2d/ray_cast_2d.h2
-rw-r--r--scene/2d/remote_transform_2d.cpp10
-rw-r--r--scene/2d/remote_transform_2d.h2
-rw-r--r--scene/2d/screen_button.cpp16
-rw-r--r--scene/2d/screen_button.h4
-rw-r--r--scene/2d/sprite.cpp10
-rw-r--r--scene/2d/sprite.h2
-rw-r--r--scene/2d/tile_map.cpp71
-rw-r--r--scene/2d/tile_map.h9
-rw-r--r--scene/2d/visibility_notifier_2d.cpp46
-rw-r--r--scene/2d/visibility_notifier_2d.h2
-rw-r--r--scene/2d/y_sort.cpp2
-rw-r--r--scene/2d/y_sort.h2
-rw-r--r--scene/3d/area.cpp18
-rw-r--r--scene/3d/area.h2
-rw-r--r--scene/3d/arvr_nodes.cpp14
-rw-r--r--scene/3d/arvr_nodes.h2
-rw-r--r--scene/3d/audio_stream_player_3d.cpp23
-rw-r--r--scene/3d/bone_attachment.cpp14
-rw-r--r--scene/3d/bone_attachment.h2
-rw-r--r--scene/3d/camera.cpp31
-rw-r--r--scene/3d/camera.h8
-rw-r--r--scene/3d/character_camera.cpp718
-rw-r--r--scene/3d/character_camera.h167
-rw-r--r--scene/3d/collision_object.cpp3
-rw-r--r--scene/3d/collision_object.h2
-rw-r--r--scene/3d/collision_polygon.cpp6
-rw-r--r--scene/3d/collision_polygon.h2
-rw-r--r--scene/3d/collision_shape.cpp16
-rw-r--r--scene/3d/collision_shape.h2
-rw-r--r--scene/3d/gi_probe.cpp15
-rw-r--r--scene/3d/gi_probe.h2
-rw-r--r--scene/3d/immediate_geometry.cpp2
-rw-r--r--scene/3d/immediate_geometry.h6
-rw-r--r--scene/3d/interpolated_camera.cpp16
-rw-r--r--scene/3d/interpolated_camera.h2
-rw-r--r--scene/3d/light.cpp61
-rw-r--r--scene/3d/light.h9
-rw-r--r--scene/3d/listener.cpp2
-rw-r--r--scene/3d/listener.h2
-rw-r--r--scene/3d/mesh_instance.cpp12
-rw-r--r--scene/3d/mesh_instance.h2
-rw-r--r--scene/3d/multimesh_instance.cpp2
-rw-r--r--scene/3d/multimesh_instance.h2
-rw-r--r--scene/3d/navigation.cpp4
-rw-r--r--scene/3d/navigation.h2
-rw-r--r--scene/3d/navigation_mesh.cpp14
-rw-r--r--scene/3d/navigation_mesh.h2
-rw-r--r--scene/3d/particles.cpp76
-rw-r--r--scene/3d/particles.h4
-rw-r--r--scene/3d/path.cpp35
-rw-r--r--scene/3d/path.h2
-rw-r--r--scene/3d/physics_body.cpp32
-rw-r--r--scene/3d/physics_body.h2
-rw-r--r--scene/3d/physics_joint.cpp436
-rw-r--r--scene/3d/physics_joint.h71
-rw-r--r--scene/3d/portal.cpp5
-rw-r--r--scene/3d/portal.h6
-rw-r--r--scene/3d/position_3d.cpp2
-rw-r--r--scene/3d/position_3d.h2
-rw-r--r--scene/3d/proximity_group.cpp6
-rw-r--r--scene/3d/proximity_group.h2
-rw-r--r--scene/3d/ray_cast.cpp14
-rw-r--r--scene/3d/ray_cast.h2
-rw-r--r--scene/3d/reflection_probe.cpp6
-rw-r--r--scene/3d/reflection_probe.h2
-rw-r--r--scene/3d/remote_transform.cpp10
-rw-r--r--scene/3d/remote_transform.h2
-rw-r--r--scene/3d/room_instance.cpp9
-rw-r--r--scene/3d/room_instance.h7
-rw-r--r--scene/3d/scenario_fx.cpp2
-rw-r--r--scene/3d/scenario_fx.h2
-rw-r--r--scene/3d/skeleton.cpp12
-rw-r--r--scene/3d/skeleton.h8
-rw-r--r--scene/3d/spatial.cpp67
-rw-r--r--scene/3d/spatial.h3
-rw-r--r--scene/3d/spatial_indexer.cpp166
-rw-r--r--scene/3d/spatial_indexer.h84
-rw-r--r--scene/3d/spatial_velocity_tracker.h2
-rw-r--r--scene/3d/sprite_3d.cpp296
-rw-r--r--scene/3d/sprite_3d.h35
-rw-r--r--scene/3d/vehicle_body.cpp21
-rw-r--r--scene/3d/vehicle_body.h4
-rw-r--r--scene/3d/visibility_notifier.cpp22
-rw-r--r--scene/3d/visibility_notifier.h2
-rw-r--r--scene/3d/visual_instance.cpp50
-rw-r--r--scene/3d/visual_instance.h6
-rw-r--r--scene/SCsub1
-rw-r--r--scene/animation/animation_cache.cpp6
-rw-r--r--scene/animation/animation_cache.h2
-rw-r--r--scene/animation/animation_player.cpp39
-rw-r--r--scene/animation/animation_player.h4
-rw-r--r--scene/animation/animation_tree_player.cpp32
-rw-r--r--scene/animation/animation_tree_player.h10
-rw-r--r--scene/animation/tween.cpp64
-rw-r--r--scene/animation/tween.h24
-rw-r--r--scene/animation/tween_interpolaters.cpp2
-rw-r--r--scene/audio/audio_player.cpp19
-rw-r--r--scene/audio/audio_player.h2
-rw-r--r--scene/gui/base_button.cpp15
-rw-r--r--scene/gui/base_button.h2
-rw-r--r--scene/gui/box_container.cpp16
-rw-r--r--scene/gui/box_container.h2
-rw-r--r--scene/gui/button.cpp12
-rw-r--r--scene/gui/button.h2
-rw-r--r--scene/gui/button_group.cpp4
-rw-r--r--scene/gui/button_group.h2
-rw-r--r--scene/gui/center_container.cpp6
-rw-r--r--scene/gui/center_container.h2
-rw-r--r--scene/gui/check_box.cpp2
-rw-r--r--scene/gui/check_box.h2
-rw-r--r--scene/gui/check_button.cpp2
-rw-r--r--scene/gui/check_button.h2
-rw-r--r--scene/gui/color_picker.cpp37
-rw-r--r--scene/gui/color_picker.h10
-rw-r--r--scene/gui/color_rect.cpp2
-rw-r--r--scene/gui/color_rect.h2
-rw-r--r--scene/gui/container.cpp8
-rw-r--r--scene/gui/container.h2
-rw-r--r--scene/gui/control.cpp408
-rw-r--r--scene/gui/control.h49
-rw-r--r--scene/gui/dialogs.cpp28
-rw-r--r--scene/gui/dialogs.h2
-rw-r--r--scene/gui/file_dialog.cpp21
-rw-r--r--scene/gui/file_dialog.h2
-rw-r--r--scene/gui/gradient_edit.cpp2
-rw-r--r--scene/gui/gradient_edit.h2
-rw-r--r--scene/gui/graph_edit.cpp170
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/graph_node.cpp18
-rw-r--r--scene/gui/graph_node.h2
-rw-r--r--scene/gui/grid_container.cpp8
-rw-r--r--scene/gui/grid_container.h2
-rw-r--r--scene/gui/item_list.cpp19
-rw-r--r--scene/gui/item_list.h6
-rw-r--r--scene/gui/label.cpp27
-rw-r--r--scene/gui/label.h2
-rw-r--r--scene/gui/line_edit.cpp30
-rw-r--r--scene/gui/line_edit.h5
-rw-r--r--scene/gui/link_button.cpp8
-rw-r--r--scene/gui/link_button.h2
-rw-r--r--scene/gui/margin_container.cpp6
-rw-r--r--scene/gui/margin_container.h2
-rw-r--r--scene/gui/menu_button.cpp4
-rw-r--r--scene/gui/menu_button.h2
-rw-r--r--scene/gui/option_button.cpp14
-rw-r--r--scene/gui/option_button.h2
-rw-r--r--scene/gui/panel.cpp2
-rw-r--r--scene/gui/panel.h2
-rw-r--r--scene/gui/panel_container.cpp6
-rw-r--r--scene/gui/panel_container.h2
-rw-r--r--scene/gui/patch_9_rect.cpp8
-rw-r--r--scene/gui/patch_9_rect.h4
-rw-r--r--scene/gui/popup.cpp57
-rw-r--r--scene/gui/popup.h2
-rw-r--r--scene/gui/popup_menu.cpp26
-rw-r--r--scene/gui/popup_menu.h4
-rw-r--r--scene/gui/progress_bar.cpp2
-rw-r--r--scene/gui/progress_bar.h2
-rw-r--r--scene/gui/range.cpp4
-rw-r--r--scene/gui/range.h2
-rw-r--r--scene/gui/reference_rect.cpp6
-rw-r--r--scene/gui/reference_rect.h2
-rw-r--r--scene/gui/rich_text_label.cpp44
-rw-r--r--scene/gui/rich_text_label.h4
-rw-r--r--scene/gui/scroll_bar.cpp204
-rw-r--r--scene/gui/scroll_bar.h9
-rw-r--r--scene/gui/scroll_container.cpp12
-rw-r--r--scene/gui/scroll_container.h2
-rw-r--r--scene/gui/separator.cpp2
-rw-r--r--scene/gui/separator.h2
-rw-r--r--scene/gui/shortcut.cpp (renamed from scene/gui/input_action.cpp)62
-rw-r--r--scene/gui/shortcut.h (renamed from scene/gui/input_action.h)12
-rw-r--r--scene/gui/slider.cpp2
-rw-r--r--scene/gui/slider.h2
-rw-r--r--scene/gui/spin_box.cpp4
-rw-r--r--scene/gui/spin_box.h2
-rw-r--r--scene/gui/split_container.cpp10
-rw-r--r--scene/gui/split_container.h2
-rw-r--r--scene/gui/tab_container.cpp32
-rw-r--r--scene/gui/tab_container.h4
-rw-r--r--scene/gui/tabs.cpp18
-rw-r--r--scene/gui/tabs.h2
-rw-r--r--scene/gui/text_edit.cpp244
-rw-r--r--scene/gui/text_edit.h32
-rw-r--r--scene/gui/texture_button.cpp20
-rw-r--r--scene/gui/texture_button.h6
-rw-r--r--scene/gui/texture_progress.cpp275
-rw-r--r--scene/gui/texture_progress.h13
-rw-r--r--scene/gui/texture_rect.cpp18
-rw-r--r--scene/gui/texture_rect.h2
-rw-r--r--scene/gui/tool_button.cpp2
-rw-r--r--scene/gui/tool_button.h2
-rw-r--r--scene/gui/tree.cpp121
-rw-r--r--scene/gui/tree.h34
-rw-r--r--scene/gui/video_player.cpp50
-rw-r--r--scene/gui/video_player.h17
-rw-r--r--scene/gui/viewport_container.cpp10
-rw-r--r--scene/gui/viewport_container.h2
-rw-r--r--scene/io/SCsub7
-rw-r--r--scene/io/resource_format_image.cpp266
-rw-r--r--scene/io/resource_format_image.h55
-rw-r--r--scene/io/resource_format_wav.cpp277
-rw-r--r--scene/io/resource_format_wav.h46
-rw-r--r--scene/main/canvas_layer.cpp4
-rw-r--r--scene/main/canvas_layer.h4
-rw-r--r--scene/main/http_request.cpp28
-rw-r--r--scene/main/http_request.h4
-rw-r--r--scene/main/instance_placeholder.cpp2
-rw-r--r--scene/main/instance_placeholder.h2
-rwxr-xr-xscene/main/node.cpp174
-rw-r--r--scene/main/node.h16
-rw-r--r--scene/main/resource_preloader.cpp2
-rw-r--r--scene/main/resource_preloader.h2
-rw-r--r--scene/main/scene_tree.cpp221
-rw-r--r--scene/main/scene_tree.h15
-rwxr-xr-xscene/main/timer.cpp10
-rwxr-xr-xscene/main/timer.h2
-rw-r--r--scene/main/viewport.cpp256
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/register_scene_types.cpp231
-rw-r--r--scene/register_scene_types.h2
-rw-r--r--scene/resources/animation.cpp79
-rw-r--r--scene/resources/animation.h4
-rw-r--r--scene/resources/audio_stream_resampled.cpp388
-rw-r--r--scene/resources/audio_stream_resampled.h166
-rw-r--r--scene/resources/audio_stream_sample.cpp2
-rw-r--r--scene/resources/audio_stream_sample.h2
-rw-r--r--scene/resources/bit_mask.cpp2
-rw-r--r--scene/resources/bit_mask.h2
-rw-r--r--scene/resources/bounds.cpp2
-rw-r--r--scene/resources/bounds.h2
-rw-r--r--scene/resources/box_shape.cpp2
-rw-r--r--scene/resources/box_shape.h2
-rw-r--r--scene/resources/canvas.cpp2
-rw-r--r--scene/resources/canvas.h2
-rw-r--r--scene/resources/capsule_shape.cpp2
-rw-r--r--scene/resources/capsule_shape.h2
-rw-r--r--scene/resources/capsule_shape_2d.cpp2
-rw-r--r--scene/resources/capsule_shape_2d.h2
-rw-r--r--scene/resources/circle_shape_2d.cpp2
-rw-r--r--scene/resources/circle_shape_2d.h2
-rw-r--r--scene/resources/color_ramp.cpp6
-rw-r--r--scene/resources/color_ramp.h8
-rw-r--r--scene/resources/concave_polygon_shape.cpp2
-rw-r--r--scene/resources/concave_polygon_shape.h2
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp2
-rw-r--r--scene/resources/concave_polygon_shape_2d.h2
-rw-r--r--scene/resources/convex_polygon_shape.cpp2
-rw-r--r--scene/resources/convex_polygon_shape.h2
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp2
-rw-r--r--scene/resources/convex_polygon_shape_2d.h2
-rw-r--r--scene/resources/curve.cpp341
-rw-r--r--scene/resources/curve.h58
-rw-r--r--scene/resources/default_theme/default_theme.cpp822
-rw-r--r--scene/resources/default_theme/default_theme.h2
-rw-r--r--scene/resources/default_theme/scroll_grabber_pressed.pngbin0 -> 233 bytes
-rw-r--r--scene/resources/default_theme/theme_data.h4
-rw-r--r--scene/resources/dynamic_font.cpp22
-rw-r--r--scene/resources/dynamic_font.h6
-rw-r--r--scene/resources/dynamic_font_stb.cpp4
-rw-r--r--scene/resources/dynamic_font_stb.h2
-rw-r--r--scene/resources/environment.cpp51
-rw-r--r--scene/resources/environment.h6
-rw-r--r--scene/resources/font.cpp10
-rw-r--r--scene/resources/font.h2
-rw-r--r--scene/resources/gibberish_stream.cpp337
-rw-r--r--scene/resources/gibberish_stream.h118
-rw-r--r--scene/resources/material.cpp182
-rw-r--r--scene/resources/material.h8
-rw-r--r--scene/resources/mesh.cpp55
-rw-r--r--scene/resources/mesh.h5
-rw-r--r--scene/resources/mesh_data_tool.cpp2
-rw-r--r--scene/resources/mesh_data_tool.h2
-rw-r--r--scene/resources/mesh_library.cpp65
-rw-r--r--scene/resources/mesh_library.h16
-rw-r--r--scene/resources/multimesh.cpp13
-rw-r--r--scene/resources/multimesh.h2
-rw-r--r--scene/resources/packed_scene.cpp161
-rw-r--r--scene/resources/packed_scene.h2
-rw-r--r--scene/resources/plane_shape.cpp2
-rw-r--r--scene/resources/plane_shape.h2
-rw-r--r--scene/resources/polygon_path_finder.cpp2
-rw-r--r--scene/resources/polygon_path_finder.h2
-rw-r--r--scene/resources/primitive_meshes.cpp32
-rw-r--r--scene/resources/primitive_meshes.h2
-rw-r--r--scene/resources/ray_shape.cpp2
-rw-r--r--scene/resources/ray_shape.h2
-rw-r--r--scene/resources/rectangle_shape_2d.cpp2
-rw-r--r--scene/resources/rectangle_shape_2d.h2
-rw-r--r--scene/resources/room.cpp5
-rw-r--r--scene/resources/room.h8
-rw-r--r--scene/resources/scene_format_text.cpp10
-rw-r--r--scene/resources/scene_format_text.h2
-rw-r--r--scene/resources/segment_shape_2d.cpp2
-rw-r--r--scene/resources/segment_shape_2d.h2
-rw-r--r--scene/resources/shader.cpp8
-rw-r--r--scene/resources/shader.h2
-rw-r--r--scene/resources/shader_graph.cpp323
-rw-r--r--scene/resources/shader_graph.h3
-rw-r--r--scene/resources/shape.cpp4
-rw-r--r--scene/resources/shape.h2
-rw-r--r--scene/resources/shape_2d.cpp2
-rw-r--r--scene/resources/shape_2d.h6
-rw-r--r--scene/resources/shape_line_2d.cpp2
-rw-r--r--scene/resources/shape_line_2d.h2
-rw-r--r--scene/resources/sky_box.cpp93
-rw-r--r--scene/resources/sky_box.h13
-rw-r--r--scene/resources/space_2d.cpp2
-rw-r--r--scene/resources/space_2d.h2
-rw-r--r--scene/resources/sphere_shape.cpp2
-rw-r--r--scene/resources/sphere_shape.h2
-rw-r--r--scene/resources/style_box.cpp587
-rw-r--r--scene/resources/style_box.h100
-rw-r--r--scene/resources/surface_tool.cpp37
-rw-r--r--scene/resources/surface_tool.h8
-rw-r--r--scene/resources/texture.cpp67
-rw-r--r--scene/resources/texture.h2
-rw-r--r--scene/resources/theme.cpp17
-rw-r--r--scene/resources/theme.h8
-rw-r--r--scene/resources/tile_set.cpp2
-rw-r--r--scene/resources/tile_set.h6
-rw-r--r--scene/resources/video_stream.cpp2
-rw-r--r--scene/resources/video_stream.h3
-rw-r--r--scene/resources/world.cpp4
-rw-r--r--scene/resources/world.h2
-rw-r--r--scene/resources/world_2d.cpp2
-rw-r--r--scene/resources/world_2d.h2
-rw-r--r--scene/scene_string_names.cpp2
-rw-r--r--scene/scene_string_names.h2
382 files changed, 4268 insertions, 7854 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 366c3a8bd8..26241df660 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index 80defac079..6c660d0381 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 02a0509449..1124904963 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -116,7 +116,7 @@ real_t Area2D::get_priority() const {
void Area2D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
@@ -134,7 +134,7 @@ void Area2D::_body_enter_tree(ObjectID p_id) {
void Area2D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -153,7 +153,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
Map<ObjectID, BodyState>::Element *E = body_map.find(objid);
@@ -217,7 +217,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
void Area2D::_area_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
@@ -235,7 +235,7 @@ void Area2D::_area_enter_tree(ObjectID p_id) {
void Area2D::_area_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -254,7 +254,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
Map<ObjectID, AreaState>::Element *E = area_map.find(objid);
@@ -330,7 +330,7 @@ void Area2D::_clear_monitoring() {
for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
if (!node) //node may have been deleted in previous frame or at other legiminate point
continue;
@@ -360,7 +360,7 @@ void Area2D::_clear_monitoring() {
for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
if (!node) //node may have been deleted in previous frame or at other legiminate point
continue;
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index 12d71f3911..c56cf651a1 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 1423a804ff..eb186a8e1f 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -1,7 +1,10 @@
#include "audio_stream_player_2d.h"
+
+#include "engine.h"
#include "scene/2d/area_2d.h"
#include "scene/main/viewport.h"
+
void AudioStreamPlayer2D::_mix_audio() {
if (!stream_playback.is_valid()) {
@@ -120,7 +123,7 @@ void AudioStreamPlayer2D::_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()) {
+ if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
}
}
@@ -154,10 +157,8 @@ void AudioStreamPlayer2D::_notification(int p_what) {
int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, Physics2DDirectSpaceState::TYPE_MASK_AREA);
for (int i = 0; i < areas; i++) {
- if (!sr[i].collider)
- continue;
- Area2D *area2d = sr[i].collider->cast_to<Area2D>();
+ Area2D *area2d = Object::cast_to<Area2D>(sr[i].collider);
if (!area2d)
continue;
@@ -223,6 +224,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
if (!active) {
set_fixed_process_internal(false);
_change_notify("playing"); //update property in editor
+ emit_signal("finished");
}
}
}
@@ -441,6 +443,9 @@ void AudioStreamPlayer2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING), "set_attenuation", "get_attenuation");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");
ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask");
+
+ ADD_SIGNAL(MethodInfo("finished"));
+
}
AudioStreamPlayer2D::AudioStreamPlayer2D() {
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index 748a527ca0..2858ddaad5 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -85,9 +85,9 @@ void BackBufferCopy::_bind_methods() {
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);
- BIND_CONSTANT(COPY_MODE_VIEWPORT);
+ BIND_ENUM_CONSTANT(COPY_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(COPY_MODE_RECT);
+ BIND_ENUM_CONSTANT(COPY_MODE_VIEWPORT);
}
BackBufferCopy::BackBufferCopy() {
diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h
index 4080f50696..2424dd7b19 100644
--- a/scene/2d/back_buffer_copy.h
+++ b/scene/2d/back_buffer_copy.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index b11c1dd642..e39e6fc6da 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,7 +38,7 @@ void Camera2D::_update_scroll() {
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update(); //will just be drawn
return;
}
@@ -85,7 +85,7 @@ Transform2D Camera2D::get_camera_transform() {
if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
- if (h_drag_enabled && !get_tree()->is_editor_hint()) {
+ if (h_drag_enabled && !Engine::get_singleton()->is_editor_hint()) {
camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT]));
camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * drag_margin[MARGIN_LEFT]));
} else {
@@ -97,7 +97,7 @@ Transform2D Camera2D::get_camera_transform() {
}
}
- if (v_drag_enabled && !get_tree()->is_editor_hint()) {
+ if (v_drag_enabled && !Engine::get_singleton()->is_editor_hint()) {
camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM]));
camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * drag_margin[MARGIN_TOP]));
@@ -136,7 +136,7 @@ Transform2D Camera2D::get_camera_transform() {
camera_pos.y -= screen_rect.position.y - limit[MARGIN_TOP];
}
- if (smoothing_enabled && !get_tree()->is_editor_hint()) {
+ if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) {
float c = smoothing * get_fixed_process_delta_time();
smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos;
@@ -240,7 +240,7 @@ void Camera2D::_notification(int p_what) {
add_to_group(group_name);
add_to_group(canvas_group_name);
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
set_fixed_process(false);
}
@@ -262,7 +262,7 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
- if (!is_inside_tree() || !get_tree()->is_editor_hint())
+ if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint())
break;
if (screen_drawing_enabled) {
@@ -497,7 +497,7 @@ void Camera2D::align() {
void Camera2D::set_follow_smoothing(float p_speed) {
smoothing = p_speed;
- if (smoothing > 0 && !(is_inside_tree() && get_tree()->is_editor_hint()))
+ if (smoothing > 0 && !(is_inside_tree() && Engine::get_singleton()->is_editor_hint()))
set_fixed_process(true);
else
set_fixed_process(false);
@@ -552,11 +552,11 @@ float Camera2D::get_h_offset() const {
return h_ofs;
}
-void Camera2D::_set_old_smoothing(float p_val) {
+void Camera2D::_set_old_smoothing(float p_enable) {
//compatibility
- if (p_val > 0) {
+ if (p_enable > 0) {
smoothing_enabled = true;
- set_follow_smoothing(p_val);
+ set_follow_smoothing(p_enable);
}
}
@@ -577,7 +577,7 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
remove_from_group(canvas_group_name);
}
- custom_viewport = p_viewport->cast_to<Viewport>();
+ custom_viewport = Object::cast_to<Viewport>(p_viewport);
if (custom_viewport) {
custom_viewport_id = custom_viewport->get_instance_id();
@@ -735,8 +735,8 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_limits"), "set_limit_drawing_enabled", "is_limit_drawing_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_drag_margin"), "set_margin_drawing_enabled", "is_margin_drawing_enabled");
- BIND_CONSTANT(ANCHOR_MODE_DRAG_CENTER);
- BIND_CONSTANT(ANCHOR_MODE_FIXED_TOP_LEFT);
+ BIND_ENUM_CONSTANT(ANCHOR_MODE_DRAG_CENTER);
+ BIND_ENUM_CONSTANT(ANCHOR_MODE_FIXED_TOP_LEFT);
}
Camera2D::Camera2D() {
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 8d9e76be85..dfcadf65a6 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 3d0b5047ae..4f00966e75 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -188,14 +188,15 @@ void CanvasItemMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,Premult Alpha"), "set_blend_mode", "get_blend_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mode", PROPERTY_HINT_ENUM, "Normal,Unshaded,Light Only"), "set_light_mode", "get_light_mode");
- BIND_CONSTANT(BLEND_MODE_MIX);
- BIND_CONSTANT(BLEND_MODE_ADD);
- BIND_CONSTANT(BLEND_MODE_SUB);
- BIND_CONSTANT(BLEND_MODE_MUL);
- BIND_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
- BIND_CONSTANT(LIGHT_MODE_NORMAL);
- BIND_CONSTANT(LIGHT_MODE_UNSHADED);
- BIND_CONSTANT(LIGHT_MODE_LIGHT_ONLY);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
+ BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
+ BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+ BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
+
+ BIND_ENUM_CONSTANT(LIGHT_MODE_NORMAL);
+ BIND_ENUM_CONSTANT(LIGHT_MODE_UNSHADED);
+ BIND_ENUM_CONSTANT(LIGHT_MODE_LIGHT_ONLY);
}
CanvasItemMaterial::CanvasItemMaterial()
@@ -259,7 +260,7 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
for (int i = 0; i < get_child_count(); i++) {
- CanvasItem *c = get_child(i)->cast_to<CanvasItem>();
+ CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i));
if (c && c->visible) //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
@@ -397,7 +398,7 @@ void CanvasItem::_toplevel_raise_self() {
void CanvasItem::_enter_canvas() {
- if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {
+ if ((!Object::cast_to<CanvasItem>(get_parent())) || toplevel) {
Node *n = this;
@@ -405,7 +406,7 @@ void CanvasItem::_enter_canvas() {
while (n) {
- canvas_layer = n->cast_to<CanvasLayer>();
+ canvas_layer = Object::cast_to<CanvasLayer>(n);
if (canvas_layer) {
break;
}
@@ -459,7 +460,7 @@ void CanvasItem::_notification(int p_what) {
first_draw = true;
if (get_parent()) {
- CanvasItem *ci = get_parent()->cast_to<CanvasItem>();
+ CanvasItem *ci = Object::cast_to<CanvasItem>(get_parent());
if (ci)
C = ci->children_items.push_back(this);
}
@@ -487,7 +488,7 @@ void CanvasItem::_notification(int p_what) {
get_tree()->xform_change_list.remove(&xform_change);
_exit_canvas();
if (C) {
- get_parent()->cast_to<CanvasItem>()->children_items.erase(C);
+ Object::cast_to<CanvasItem>(get_parent())->children_items.erase(C);
C = NULL;
}
global_invalid = true;
@@ -564,11 +565,7 @@ CanvasItem *CanvasItem::get_parent_item() const {
if (toplevel)
return NULL;
- Node *parent = get_parent();
- if (!parent)
- return NULL;
-
- return parent->cast_to<CanvasItem>();
+ return Object::cast_to<CanvasItem>(get_parent());
}
void CanvasItem::set_self_modulate(const Color &p_self_modulate) {
@@ -734,7 +731,7 @@ void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
-void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
+void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -744,10 +741,10 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, p_antialiased);
}
-void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
+void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -759,7 +756,7 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, p_antialiased);
}
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
@@ -829,8 +826,8 @@ RID CanvasItem::get_canvas() const {
CanvasItem *CanvasItem::get_toplevel() const {
CanvasItem *ci = const_cast<CanvasItem *>(this);
- while (!ci->toplevel && ci->get_parent() && ci->get_parent()->cast_to<CanvasItem>()) {
- ci = ci->get_parent()->cast_to<CanvasItem>();
+ while (!ci->toplevel && Object::cast_to<CanvasItem>(ci->get_parent())) {
+ ci = Object::cast_to<CanvasItem>(ci->get_parent());
}
return ci;
@@ -985,8 +982,8 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("draw_style_box", "style_box", "rect"), &CanvasItem::draw_style_box);
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
@@ -1042,11 +1039,11 @@ void CanvasItem::_bind_methods() {
ADD_SIGNAL(MethodInfo("hide"));
ADD_SIGNAL(MethodInfo("item_rect_changed"));
- BIND_CONSTANT(BLEND_MODE_MIX);
- BIND_CONSTANT(BLEND_MODE_ADD);
- BIND_CONSTANT(BLEND_MODE_SUB);
- BIND_CONSTANT(BLEND_MODE_MUL);
- BIND_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
+ BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
+ BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+ BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
BIND_CONSTANT(NOTIFICATION_DRAW);
BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
@@ -1061,8 +1058,8 @@ Transform2D CanvasItem::get_canvas_transform() const {
if (canvas_layer)
return canvas_layer->get_transform();
- else if (get_parent()->cast_to<CanvasItem>())
- return get_parent()->cast_to<CanvasItem>()->get_canvas_transform();
+ else if (Object::cast_to<CanvasItem>(get_parent()))
+ return Object::cast_to<CanvasItem>(get_parent())->get_canvas_transform();
else
return get_viewport()->get_canvas_transform();
}
@@ -1121,7 +1118,7 @@ Rect2 CanvasItem::get_item_and_children_rect() const {
Rect2 rect = get_item_rect();
for (int i = 0; i < get_child_count(); i++) {
- CanvasItem *c = get_child(i)->cast_to<CanvasItem>();
+ CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i));
if (c) {
Rect2 sir = c->get_transform().xform(c->get_item_and_children_rect());
rect = rect.merge(sir);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 27842727ac..5a0a9c6e6a 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -251,8 +251,8 @@ public:
void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true);
void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect);
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>());
- void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
- void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
+ void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false);
+ void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false);
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1);
float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1));
@@ -291,13 +291,13 @@ public:
RID get_canvas() const;
Ref<World2D> get_world_2d() const;
- void set_material(const Ref<Material> &p_material);
+ virtual void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- void set_use_parent_material(bool p_use_parent_material);
+ virtual void set_use_parent_material(bool p_use_parent_material);
bool get_use_parent_material() const;
- Ref<InputEvent> make_input_local(const Ref<InputEvent> &pevent) const;
+ Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const;
Vector2 make_canvas_pos_local(const Vector2 &screen_point) const;
Vector2 get_global_mouse_position() const;
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index a132c5e18c..05831609fc 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h
index 37d9d47ba5..4195c1386c 100644
--- a/scene/2d/canvas_modulate.h
+++ b/scene/2d/canvas_modulate.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index d3bb5a8d4e..ce56b85a9e 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index 36bf39ff4e..a828d8d8ea 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index bd669eb4c8..e2764a6e8d 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,6 +30,7 @@
#include "collision_polygon_2d.h"
#include "collision_object_2d.h"
+#include "engine.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
@@ -78,11 +79,6 @@ void CollisionPolygon2D::_build_polygon() {
Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() {
Vector<Vector<Vector2> > decomp;
-#if 0
- //fast but imprecise triangulator, gave us problems
- decomp = Geometry::decompose_polygon(polygon);
-#else
-
List<TriangulatorPoly> in_poly, out_poly;
TriangulatorPoly inp;
@@ -115,8 +111,6 @@ Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() {
idx++;
}
-#endif
-
return decomp;
}
@@ -125,7 +119,7 @@ void CollisionPolygon2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_PARENTED: {
- parent = get_parent()->cast_to<CollisionObject2D>();
+ parent = Object::cast_to<CollisionObject2D>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
_build_polygon();
@@ -134,7 +128,7 @@ void CollisionPolygon2D::_notification(int p_what) {
parent->shape_owner_set_one_way_collision(owner_id, one_way_collision);
}
- /*if (get_tree()->is_editor_hint()) {
+ /*if (Engine::get_singleton()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
set_z(VS::CANVAS_ITEM_Z_MAX - 1);
@@ -158,7 +152,7 @@ void CollisionPolygon2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -256,7 +250,7 @@ Rect2 CollisionPolygon2D::get_item_rect() const {
String CollisionPolygon2D::get_configuration_warning() const {
- if (!get_parent()->cast_to<CollisionObject2D>()) {
+ if (!Object::cast_to<CollisionObject2D>(get_parent())) {
return TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
}
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index f0666ba9de..c9ec860e36 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index ff4aa245ec..0758f4a9bf 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,7 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_shape_2d.h"
+
#include "collision_object_2d.h"
+#include "engine.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
@@ -48,7 +50,7 @@ void CollisionShape2D::_notification(int p_what) {
case NOTIFICATION_PARENTED: {
- parent = get_parent()->cast_to<CollisionObject2D>();
+ parent = Object::cast_to<CollisionObject2D>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
if (shape.is_valid()) {
@@ -59,7 +61,7 @@ void CollisionShape2D::_notification(int p_what) {
parent->shape_owner_set_one_way_collision(owner_id, one_way_collision);
}
- /*if (get_tree()->is_editor_hint()) {
+ /*if (Engine::get_singleton()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
set_z(VS::CANVAS_ITEM_Z_MAX - 1);
@@ -90,7 +92,7 @@ void CollisionShape2D::_notification(int p_what) {
} break;*/
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -163,7 +165,7 @@ Rect2 CollisionShape2D::get_item_rect() const {
String CollisionShape2D::get_configuration_warning() const {
- if (!get_parent()->cast_to<CollisionObject2D>()) {
+ if (!Object::cast_to<CollisionObject2D>(get_parent())) {
return TTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
}
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 1f2b96b91f..04203a75b4 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 1bb40a28b5..69bad1623f 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "joints_2d.h"
+
+#include "engine.h"
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
@@ -152,7 +154,7 @@ void PinJoint2D::_notification(int p_what) {
if (!is_inside_tree())
break;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -170,8 +172,8 @@ RID PinJoint2D::_configure_joint() {
if (!node_a && !node_b)
return RID();
- PhysicsBody2D *body_a = node_a ? node_a->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL;
- PhysicsBody2D *body_b = node_b ? node_b->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL;
+ PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
+ PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
if (!body_a && !body_b)
return RID();
@@ -227,7 +229,7 @@ void GrooveJoint2D::_notification(int p_what) {
if (!is_inside_tree())
break;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -247,8 +249,8 @@ RID GrooveJoint2D::_configure_joint() {
if (!node_a || !node_b)
return RID();
- PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>();
- PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
+ PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
if (!body_a || !body_b)
return RID();
@@ -317,7 +319,7 @@ void DampedSpringJoint2D::_notification(int p_what) {
if (!is_inside_tree())
break;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -336,8 +338,8 @@ RID DampedSpringJoint2D::_configure_joint() {
if (!node_a || !node_b)
return RID();
- PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>();
- PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
+ PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
if (!body_a || !body_b)
return RID();
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index b52b0f4670..685299abc6 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -81,7 +81,7 @@ protected:
static void _bind_methods();
public:
- void set_softness(real_t p_stiffness);
+ void set_softness(real_t p_softness);
real_t get_softness() const;
PinJoint2D();
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index e8c2122bd1..ab8277ecf3 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "light_2d.h"
+
+#include "engine.h"
#include "servers/visual_server.h"
void Light2D::edit_set_pivot(const Point2 &p_pivot) {
@@ -70,7 +72,7 @@ void Light2D::_update_light_visibility() {
#ifdef TOOLS_ENABLED
if (editor_only) {
- if (!get_tree()->is_editor_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint()) {
editor_ok = false;
} else {
editor_ok = (get_tree()->get_edited_scene_root() && (this == get_tree()->get_edited_scene_root() || get_owner() == get_tree()->get_edited_scene_root()));
@@ -416,7 +418,7 @@ void Light2D::_bind_methods() {
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::REAL, "texture_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");
@@ -432,15 +434,15 @@ void Light2D::_bind_methods() {
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_gradient_length", PROPERTY_HINT_RANGE, "0,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::REAL, "shadow_filter_smooth", PROPERTY_HINT_RANGE, "0,64,0.1"), "set_shadow_smooth", "get_shadow_smooth");
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);
- BIND_CONSTANT(MODE_MIX);
- BIND_CONSTANT(MODE_MASK);
+ BIND_ENUM_CONSTANT(MODE_ADD);
+ BIND_ENUM_CONSTANT(MODE_SUB);
+ BIND_ENUM_CONSTANT(MODE_MIX);
+ BIND_ENUM_CONSTANT(MODE_MASK);
}
Light2D::Light2D() {
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index 90e55aeda4..66b0aa2299 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index a1a8e7d9c4..92e0d8a2f6 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "light_occluder_2d.h"
+#include "engine.h"
+
void OccluderPolygon2D::set_polygon(const PoolVector<Vector2> &p_polygon) {
polygon = p_polygon;
@@ -87,9 +89,9 @@ void OccluderPolygon2D::_bind_methods() {
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);
- BIND_CONSTANT(CULL_COUNTER_CLOCKWISE);
+ BIND_ENUM_CONSTANT(CULL_DISABLED);
+ BIND_ENUM_CONSTANT(CULL_CLOCKWISE);
+ BIND_ENUM_CONSTANT(CULL_COUNTER_CLOCKWISE);
}
OccluderPolygon2D::OccluderPolygon2D() {
@@ -130,7 +132,7 @@ void LightOccluder2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
if (occluder_polygon.is_valid()) {
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
index 30c30b1a47..cca7bfecd6 100644
--- a/scene/2d/light_occluder_2d.h
+++ b/scene/2d/light_occluder_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 5438557d0b..c87a9a5b1e 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -322,16 +322,16 @@ void Line2D::_bind_methods() {
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_ENUM_CONSTANT(LINE_JOINT_SHARP);
+ BIND_ENUM_CONSTANT(LINE_JOINT_BEVEL);
+ BIND_ENUM_CONSTANT(LINE_JOINT_ROUND);
- BIND_CONSTANT(LINE_CAP_NONE);
- BIND_CONSTANT(LINE_CAP_BOX);
- BIND_CONSTANT(LINE_CAP_ROUND);
+ BIND_ENUM_CONSTANT(LINE_CAP_NONE);
+ BIND_ENUM_CONSTANT(LINE_CAP_BOX);
+ BIND_ENUM_CONSTANT(LINE_CAP_ROUND);
- BIND_CONSTANT(LINE_TEXTURE_NONE);
- BIND_CONSTANT(LINE_TEXTURE_TILE);
+ BIND_ENUM_CONSTANT(LINE_TEXTURE_NONE);
+ BIND_ENUM_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
index e8ca5e6e7c..017ccf13ff 100644
--- a/scene/2d/line_2d.h
+++ b/scene/2d/line_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp
index 3c1410edbb..9eea5191b9 100644
--- a/scene/2d/line_builder.cpp
+++ b/scene/2d/line_builder.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h
index 0e1a2aaf50..227e0abd08 100644
--- a/scene/2d/line_builder.h
+++ b/scene/2d/line_builder.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index e579838903..74d835dfb2 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -236,42 +236,6 @@ void Navigation2D::navpoly_remove(int p_id) {
_navpoly_unlink(p_id);
navpoly_map.erase(p_id);
}
-#if 0
-void Navigation2D::_clip_path(Vector<Vector2>& path, Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly) {
-
- Vector2 from = path[path.size()-1];
-
- if (from.distance_to(p_to_point)<CMP_EPSILON)
- return;
- Plane cut_plane;
- cut_plane.normal = (from-p_to_point).cross(up);
- if (cut_plane.normal==Vector2())
- return;
- cut_plane.normal.normalize();
- cut_plane.d = cut_plane.normal.dot(from);
-
-
- while(from_poly!=p_to_poly) {
-
- int pe = from_poly->prev_edge;
- Vector2 a = _get_vertex(from_poly->edges[pe].point);
- Vector2 b = _get_vertex(from_poly->edges[(pe+1)%from_poly->edges.size()].point);
-
- from_poly=from_poly->edges[pe].C;
- ERR_FAIL_COND(!from_poly);
-
- if (a.distance_to(b)>CMP_EPSILON) {
-
- Vector2 inters;
- if (cut_plane.intersects_segment(a,b,&inters)) {
- if (inters.distance_to(p_to_point)>CMP_EPSILON && inters.distance_to(path[path.size()-1])>CMP_EPSILON) {
- path.push_back(inters);
- }
- }
- }
- }
-}
-#endif
Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) {
@@ -498,29 +462,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
open_list.erase(least_cost_poly);
}
-#if 0
-debug path
- {
- Polygon *p=end_poly;
- int idx=0;
-
- while(true) {
- int prev = p->prev_edge;
- int prev_n = (p->prev_edge+1)%p->edges.size();
- Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5;
- String points;
- for(int i=0;i<p->edges.size();i++) {
- if (i>0)
- points+=", ";
- points+=_get_vertex(p->edges[i].point);
- }
- //print_line("poly "+itos(idx++)+" - "+points);
- p = p->edges[prev].C;
- if (p==begin_poly)
- break;
- }
- }
-#endif
+
if (found_route) {
Vector<Vector2> path;
@@ -534,7 +476,6 @@ debug path
Polygon *left_poly = end_poly;
Polygon *right_poly = end_poly;
Polygon *p = end_poly;
- path.push_back(end_point);
while (p) {
@@ -592,7 +533,7 @@ debug path
left_poly = p;
portal_left = apex_point;
portal_right = apex_point;
- if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
+ if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
path.push_back(apex_point);
skip = true;
//print_line("addpoint left");
@@ -613,7 +554,7 @@ debug path
right_poly = p;
portal_right = apex_point;
portal_left = apex_point;
- if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
+ if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
path.push_back(apex_point);
//print_line("addpoint right");
//print_line("***CLIP RIGHT");
@@ -626,16 +567,10 @@ debug path
p = NULL;
}
- if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON)
- path.push_back(begin_point);
-
- path.invert();
-
} else {
//midpoints
Polygon *p = end_poly;
- path.push_back(end_point);
while (true) {
int prev = p->prev_edge;
int prev_n = (p->prev_edge + 1) % p->edges.size();
@@ -645,10 +580,20 @@ debug path
if (p == begin_poly)
break;
}
+ }
+
+ if (!path.size() || path[path.size() - 1].distance_squared_to(begin_point) > CMP_EPSILON) {
+ path.push_back(begin_point); // Add the begin point
+ } else {
+ path[path.size() - 1] = begin_point; // Replace first midpoint by the exact begin point
+ }
- path.push_back(begin_point);
+ path.invert();
- path.invert();
+ if (path.size() <= 1 || path[path.size() - 1].distance_squared_to(end_point) > CMP_EPSILON) {
+ path.push_back(end_point); // Add the end point
+ } else {
+ path[path.size() - 1] = end_point; // Replace last midpoint by the exact end point
}
return path;
diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h
index 54e89de9e2..e87b01f7c5 100644
--- a/scene/2d/navigation2d.h
+++ b/scene/2d/navigation2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -153,9 +153,7 @@ class Navigation2D : public Node2D {
float cell_size;
Map<int, NavMesh> navpoly_map;
int last_id;
-#if 0
- void _clip_path(Vector<Vector2>& path,Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly);
-#endif
+
protected:
static void _bind_methods();
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 779751c1c5..352ec3b300 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,6 +30,7 @@
#include "navigation_polygon.h"
#include "core_string_names.h"
+#include "engine.h"
#include "navigation2d.h"
#include "thirdparty/misc/triangulator.h"
@@ -297,7 +298,7 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
}
}
- if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
+ if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
update();
//update_gizmo();
@@ -318,7 +319,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
Node2D *c = this;
while (c) {
- navigation = c->cast_to<Navigation2D>();
+ navigation = Object::cast_to<Navigation2D>(c);
if (navigation) {
if (enabled && navpoly.is_valid()) {
@@ -328,7 +329,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
break;
}
- c = c->get_parent()->cast_to<Node2D>();
+ c = Object::cast_to<Node2D>(get_parent());
}
} break;
@@ -352,7 +353,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
PoolVector<Vector2> verts = navpoly->get_vertices();
int vsize = verts.size();
@@ -432,7 +433,7 @@ Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const
void NavigationPolygonInstance::_navpoly_changed() {
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
update();
}
@@ -447,11 +448,11 @@ String NavigationPolygonInstance::get_configuration_warning() const {
const Node2D *c = this;
while (c) {
- if (c->cast_to<Navigation2D>()) {
+ if (Object::cast_to<Navigation2D>(c)) {
return String();
}
- c = c->get_parent()->cast_to<Node2D>();
+ c = Object::cast_to<Node2D>(get_parent());
}
return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h
index f6e6ed210a..5576a3abd2 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_polygon.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 98d6a467b1..0c7685a858 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -379,7 +379,7 @@ Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const
if (p_parent == this)
return Transform2D();
- Node2D *parent_2d = get_parent()->cast_to<Node2D>();
+ Node2D *parent_2d = Object::cast_to<Node2D>(get_parent());
ERR_FAIL_COND_V(!parent_2d, Transform2D());
if (p_parent == parent_2d)
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index df9a05ff79..19aafc81ff 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -49,7 +49,7 @@ class Node2D : public CanvasItem {
void _update_transform();
// Deprecated, should be removed in a future version.
- void _set_rotd(float p_angle);
+ void _set_rotd(float p_degrees);
float _get_rotd() const;
void _update_xform_values();
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 433ab5ff8d..0ddcb7b51b 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -101,7 +101,7 @@ void ParallaxBackground::_update_scroll() {
for (int i = 0; i < get_child_count(); i++) {
- ParallaxLayer *l = get_child(i)->cast_to<ParallaxLayer>();
+ ParallaxLayer *l = Object::cast_to<ParallaxLayer>(get_child(i));
if (!l)
continue;
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 99d8dd3811..0dad1daeab 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -60,7 +60,7 @@ public:
void set_scroll_offset(const Point2 &p_ofs);
Point2 get_scroll_offset() const;
- void set_scroll_scale(float p_ofs);
+ void set_scroll_scale(float p_scale);
float get_scroll_scale() const;
void set_scroll_base_offset(const Point2 &p_ofs);
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 0e83b9aaae..8fe651cb5f 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,14 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "parallax_layer.h"
+
+#include "engine.h"
#include "parallax_background.h"
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
motion_scale = p_scale;
- ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
- if (is_inside_tree() && pb) {
+ ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent());
+ if (pb && is_inside_tree()) {
Vector2 ofs = pb->get_final_offset();
float scale = pb->get_scroll_scale();
set_base_offset_and_scale(ofs, scale);
@@ -51,8 +53,8 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
motion_offset = p_offset;
- ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
- if (is_inside_tree() && pb) {
+ ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent());
+ if (pb && is_inside_tree()) {
Vector2 ofs = pb->get_final_offset();
float scale = pb->get_scroll_scale();
set_base_offset_and_scale(ofs, scale);
@@ -66,10 +68,7 @@ Size2 ParallaxLayer::get_motion_offset() const {
void ParallaxLayer::_update_mirroring() {
- if (!get_parent())
- return;
-
- ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
+ ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent());
if (pb) {
RID c = pb->get_world_2d()->get_canvas();
@@ -111,7 +110,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
Point2 new_ofs = ((orig_offset + p_offset) * motion_scale) * p_scale + motion_offset;
@@ -131,7 +130,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc
String ParallaxLayer::get_configuration_warning() const {
- if (!get_parent() || !get_parent()->cast_to<ParallaxBackground>()) {
+ if (!Object::cast_to<ParallaxBackground>(get_parent())) {
return TTR("ParallaxLayer node only works when set as child of a ParallaxBackground node.");
}
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index 85e70b0a51..95ca27c41a 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -48,7 +48,7 @@ protected:
static void _bind_methods();
public:
- void set_motion_offset(const Size2 &p_scale);
+ void set_motion_offset(const Size2 &p_offset);
Size2 get_motion_offset() const;
void set_motion_scale(const Size2 &p_scale);
@@ -57,7 +57,7 @@ public:
void set_mirroring(const Size2 &p_mirroring);
Size2 get_mirroring() const;
- void set_base_offset_and_scale(const Point2 &p_offsetf, float p_scale);
+ void set_base_offset_and_scale(const Point2 &p_offset, float p_scale);
virtual String get_configuration_warning() const;
ParallaxLayer();
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 4aa841131a..c146ac08c2 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "particles_2d.h"
+#include "engine.h"
#include "scene/3d/particles.h"
#include "scene/scene_string_names.h"
@@ -55,6 +56,8 @@ void Particles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
+ if (!one_shot && emitting)
+ VisualServer::get_singleton()->particles_restart(particles);
}
void Particles2D::set_pre_process_time(float p_time) {
@@ -293,7 +296,7 @@ void Particles2D::_notification(int p_what) {
VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid, h_frames, v_frames);
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
+ if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
}
@@ -386,8 +389,8 @@ void Particles2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "h_frames", PROPERTY_HINT_RANGE, "1,1024,1"), "set_h_frames", "get_h_frames");
ADD_PROPERTY(PropertyInfo(Variant::INT, "v_frames", PROPERTY_HINT_RANGE, "1,1024,1"), "set_v_frames", "get_v_frames");
- BIND_CONSTANT(DRAW_ORDER_INDEX);
- BIND_CONSTANT(DRAW_ORDER_LIFETIME);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
}
Particles2D::Particles2D() {
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 23278ce746..6946f2a799 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -80,7 +80,7 @@ public:
void set_emitting(bool p_emitting);
void set_amount(int p_amount);
void set_lifetime(float p_lifetime);
- void set_one_shot(bool p_enabled);
+ void set_one_shot(bool p_enable);
void set_pre_process_time(float p_time);
void set_explosiveness_ratio(float p_ratio);
void set_randomness_ratio(float p_ratio);
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 6b30e97de8..1d7bd8fc2a 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "path_2d.h"
+
+#include "engine.h"
#include "scene/scene_string_names.h"
void Path2D::_notification(int p_what) {
@@ -35,7 +37,7 @@ void Path2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && curve.is_valid()) {
//draw the curve!!
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
return;
}
@@ -56,7 +58,7 @@ void Path2D::_notification(int p_what) {
void Path2D::_curve_changed() {
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
update();
}
@@ -135,13 +137,8 @@ void PathFollow2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- Node *parent = get_parent();
- if (parent) {
-
- path = parent->cast_to<Path2D>();
- if (path) {
- _update_transform();
- }
+ if ((path = Object::cast_to<Path2D>(get_parent()))) {
+ _update_transform();
}
} break;
@@ -229,7 +226,7 @@ String PathFollow2D::get_configuration_warning() const {
if (!is_visible_in_tree() || !is_inside_tree())
return String();
- if (!get_parent() || !get_parent()->cast_to<Path2D>()) {
+ if (!Object::cast_to<Path2D>(get_parent())) {
return TTR("PathFollow2D only works when set as a child of a Path2D node.");
}
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index b2dae17735..88a0abdea9 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -96,7 +96,7 @@ public:
void set_loop(bool p_loop);
bool has_loop() const;
- void set_rotate(bool p_enabled);
+ void set_rotate(bool p_rotate);
bool is_rotating() const;
void set_cubic_interpolation(bool p_enable);
diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp
index e06c79dabd..13644f71cf 100644
--- a/scene/2d/path_texture.cpp
+++ b/scene/2d/path_texture.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h
index 163e914e4a..4639a6072b 100644
--- a/scene/2d/path_texture.h
+++ b/scene/2d/path_texture.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 2f1e8925b8..b1eb2ba267 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "physics_body_2d.h"
+
+#include "engine.h"
#include "scene/scene_string_names.h"
void PhysicsBody2D::_notification(int p_what) {
@@ -141,7 +143,7 @@ PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode)
void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
if (!physics_body) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
@@ -152,7 +154,7 @@ void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
if (!physics_body) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
@@ -180,29 +182,6 @@ real_t StaticBody2D::get_constant_angular_velocity() const {
return constant_angular_velocity;
}
-#if 0
-void StaticBody2D::_update_xform() {
-
- if (!pre_xform || !pending)
- return;
-
- setting=true;
-
-
- Transform2D new_xform = get_global_transform(); //obtain the new one
-
- set_block_transform_notify(true);
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,*pre_xform); //then simulate motion!
- set_global_transform(*pre_xform); //but restore state to previous one in both visual and physics
- set_block_transform_notify(false);
-
- Physics2DServer::get_singleton()->body_static_simulate_motion(get_rid(),new_xform); //then simulate motion!
-
- setting=false;
- pending=false;
-
-}
-#endif
void StaticBody2D::set_friction(real_t p_friction) {
@@ -260,7 +239,7 @@ StaticBody2D::~StaticBody2D() {
void RigidBody2D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
@@ -283,7 +262,7 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
void RigidBody2D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -308,7 +287,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid);
@@ -391,7 +370,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
//eh.. fuck
#ifdef DEBUG_ENABLED
- state = p_state->cast_to<Physics2DDirectBodyState>();
+ state = Object::cast_to<Physics2DDirectBodyState>(p_state);
#else
state = (Physics2DDirectBodyState *)p_state; //trust it
#endif
@@ -802,13 +781,13 @@ void RigidBody2D::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
set_notify_local_transform(true); //used for warnings and only in editor
}
}
if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update_configuration_warning();
}
}
@@ -904,7 +883,7 @@ void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody2D::get_colliding_bodies);
- BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state:Physics2DDirectBodyState")));
+ BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "Physics2DDirectBodyState")));
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");
@@ -931,14 +910,14 @@ void RigidBody2D::_bind_methods() {
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_CONSTANT(MODE_STATIC);
- BIND_CONSTANT(MODE_KINEMATIC);
- BIND_CONSTANT(MODE_RIGID);
- BIND_CONSTANT(MODE_CHARACTER);
+ BIND_ENUM_CONSTANT(MODE_STATIC);
+ BIND_ENUM_CONSTANT(MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(MODE_RIGID);
+ BIND_ENUM_CONSTANT(MODE_CHARACTER);
- BIND_CONSTANT(CCD_MODE_DISABLED);
- BIND_CONSTANT(CCD_MODE_CAST_RAY);
- BIND_CONSTANT(CCD_MODE_CAST_SHAPE);
+ BIND_ENUM_CONSTANT(CCD_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY);
+ BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE);
}
RigidBody2D::RigidBody2D()
@@ -982,11 +961,12 @@ Dictionary KinematicBody2D::_move(const Vector2 &p_motion) {
if (move(p_motion, col)) {
Dictionary d;
d["position"] = col.collision;
- d["normal"] = col.collision;
+ d["normal"] = col.normal;
d["local_shape"] = col.local_shape;
d["travel"] = col.travel;
d["remainder"] = col.remainder;
d["collider_id"] = col.collider;
+ d["collider_velocity"] = col.collider_vel;
if (col.collider) {
d["collider"] = ObjectDB::get_instance(col.collider);
} else {
@@ -1168,12 +1148,10 @@ ObjectID KinematicBody2D::get_collision_collider_id(int p_collision) const {
Object *KinematicBody2D::get_collision_collider_shape(int p_collision) const {
ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
Object *collider = get_collision_collider(p_collision);
- if (collider) {
- CollisionObject2D *obj2d = collider->cast_to<CollisionObject2D>();
- if (obj2d) {
- uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
- return obj2d->shape_owner_get_owner(owner);
- }
+ CollisionObject2D *obj2d = Object::cast_to<CollisionObject2D>(collider);
+ if (obj2d) {
+ uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
+ return obj2d->shape_owner_get_owner(owner);
}
return NULL;
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 54bd263b15..1a4b0c0f5c 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 5c1c953a37..197c74352e 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -143,9 +143,7 @@ void Polygon2D::_notification(int p_what) {
Transform2D texmat(tex_rot, tex_ofs);
texmat.scale(tex_scale);
- Size2 tex_size = Vector2(1, 1);
-
- tex_size = texture->get_size();
+ Size2 tex_size = texture->get_size();
uvs.resize(points.size());
if (points.size() == uv.size()) {
@@ -176,9 +174,10 @@ void Polygon2D::_notification(int p_what) {
}
}
- Vector<int> indices = Geometry::triangulate_polygon(points);
+ // Vector<int> indices = Geometry::triangulate_polygon(points);
+ // VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
+ VS::get_singleton()->canvas_item_add_polygon(get_canvas_item(), points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID(), RID(), antialiased);
} break;
}
@@ -294,6 +293,16 @@ bool Polygon2D::get_invert() const {
return invert;
}
+void Polygon2D::set_antialiased(bool p_antialiased) {
+
+ antialiased = p_antialiased;
+ update();
+}
+bool Polygon2D::get_antialiased() const {
+
+ return antialiased;
+}
+
void Polygon2D::set_invert_border(float p_invert_border) {
invert_border = p_invert_border;
@@ -348,6 +357,9 @@ void Polygon2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_invert", "invert"), &Polygon2D::set_invert);
ClassDB::bind_method(D_METHOD("get_invert"), &Polygon2D::get_invert);
+ ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &Polygon2D::set_antialiased);
+ ClassDB::bind_method(D_METHOD("get_antialiased"), &Polygon2D::get_antialiased);
+
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);
@@ -359,6 +371,7 @@ void Polygon2D::_bind_methods() {
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_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased");
ADD_GROUP("Texture", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
ADD_GROUP("Texture", "texture_");
@@ -375,6 +388,7 @@ Polygon2D::Polygon2D() {
invert = 0;
invert_border = 100;
+ antialiased = false;
tex_rot = 0;
tex_tile = true;
tex_scale = Vector2(1, 1);
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index f2cc9452b9..20c3324a50 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -47,6 +47,7 @@ class Polygon2D : public Node2D {
float tex_rot;
bool invert;
float invert_border;
+ bool antialiased;
Vector2 offset;
mutable bool rect_cache_dirty;
@@ -84,10 +85,13 @@ public:
void set_texture_scale(const Size2 &p_scale);
Size2 get_texture_scale() const;
- void set_invert(bool p_rot);
+ void set_invert(bool p_invert);
bool get_invert() const;
- void set_invert_border(float p_border);
+ void set_antialiased(bool p_antialiased);
+ bool get_antialiased() const;
+
+ void set_invert_border(float p_invert_border);
float get_invert_border() const;
void set_offset(const Vector2 &p_offset);
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index 74ad9c17e2..cde665d422 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "position_2d.h"
+
+#include "engine.h"
#include "scene/resources/texture.h"
void Position2D::_draw_cross() {
@@ -52,7 +54,7 @@ void Position2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
break;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
_draw_cross();
} break;
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index 67ff2c610d..af54fb919a 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index cfb4059714..f90331c411 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,14 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "ray_cast_2d.h"
+
#include "collision_object_2d.h"
+#include "engine.h"
#include "physics_body_2d.h"
#include "servers/physics_2d_server.h"
void RayCast2D::set_cast_to(const Vector2 &p_point) {
cast_to = p_point;
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
update();
}
@@ -92,7 +94,7 @@ Vector2 RayCast2D::get_collision_normal() const {
void RayCast2D::set_enabled(bool p_enabled) {
enabled = p_enabled;
- if (is_inside_tree() && !get_tree()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
set_fixed_process(p_enabled);
if (!p_enabled)
collided = false;
@@ -113,11 +115,11 @@ void RayCast2D::set_exclude_parent_body(bool p_exclude_parent_body) {
if (!is_inside_tree())
return;
- if (get_parent()->cast_to<PhysicsBody2D>()) {
+ if (Object::cast_to<PhysicsBody2D>(get_parent())) {
if (exclude_parent_body)
- exclude.insert(get_parent()->cast_to<PhysicsBody2D>()->get_rid());
+ exclude.insert(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
else
- exclude.erase(get_parent()->cast_to<PhysicsBody2D>()->get_rid());
+ exclude.erase(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
}
}
@@ -132,16 +134,16 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- if (enabled && !get_tree()->is_editor_hint())
+ if (enabled && !Engine::get_singleton()->is_editor_hint())
set_fixed_process(true);
else
set_fixed_process(false);
- if (get_parent()->cast_to<PhysicsBody2D>()) {
+ if (Object::cast_to<PhysicsBody2D>(get_parent())) {
if (exclude_parent_body)
- exclude.insert(get_parent()->cast_to<PhysicsBody2D>()->get_rid());
+ exclude.insert(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
else
- exclude.erase(get_parent()->cast_to<PhysicsBody2D>()->get_rid());
+ exclude.erase(Object::cast_to<PhysicsBody2D>(get_parent())->get_rid());
}
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -153,7 +155,7 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
break;
Transform2D xf;
xf.rotate(cast_to.angle());
@@ -225,7 +227,7 @@ void RayCast2D::add_exception_rid(const RID &p_rid) {
void RayCast2D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject2D *co = ((Object *)p_object)->cast_to<CollisionObject2D>();
+ const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
if (!co)
return;
add_exception_rid(co->get_rid());
@@ -239,7 +241,7 @@ void RayCast2D::remove_exception_rid(const RID &p_rid) {
void RayCast2D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject2D *co = ((Object *)p_object)->cast_to<CollisionObject2D>();
+ const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
if (!co)
return;
remove_exception_rid(co->get_rid());
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index 244f4302ad..338de814d2 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index cbd7ac06f5..c139573853 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -51,11 +51,7 @@ void RemoteTransform2D::_update_remote() {
if (!cache)
return;
- Object *obj = ObjectDB::get_instance(cache);
- if (!obj)
- return;
-
- Node2D *n = obj->cast_to<Node2D>();
+ Node2D *n = Object::cast_to<Node2D>(ObjectDB::get_instance(cache));
if (!n)
return;
@@ -182,7 +178,7 @@ bool RemoteTransform2D::get_update_scale() const {
String RemoteTransform2D::get_configuration_warning() const {
- if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Node2D>()) {
+ if (!has_node(remote_node) || !Object::cast_to<Node2D>(get_node(remote_node))) {
return TTR("Path property must point to a valid Node2D node to work.");
}
diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h
index d58ec14a95..30d5fd1e7c 100644
--- a/scene/2d/remote_transform_2d.h
+++ b/scene/2d/remote_transform_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 37139b2b93..c9bf6675d2 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -112,7 +112,7 @@ void TouchScreenButton::_notification(int p_what) {
if (!is_inside_tree())
return;
- if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
if (finger_pressed != -1) {
@@ -129,7 +129,7 @@ void TouchScreenButton::_notification(int p_what) {
if (!shape_visible)
return;
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
return;
if (shape.is_valid()) {
Color draw_col = get_tree()->get_debug_collisions_color();
@@ -141,11 +141,11 @@ void TouchScreenButton::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
- if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
update();
- if (!get_tree()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint())
set_process_input(is_visible_in_tree());
} break;
@@ -154,7 +154,7 @@ void TouchScreenButton::_notification(int p_what) {
_release(true);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
break;
if (is_visible_in_tree()) {
set_process_input(true);
@@ -196,11 +196,11 @@ void TouchScreenButton::_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(!is_visible_in_tree());
- const InputEventScreenTouch *st = p_event->cast_to<InputEventScreenTouch>();
+ const InputEventScreenTouch *st = Object::cast_to<InputEventScreenTouch>(*p_event);
if (passby_press) {
- const InputEventScreenDrag *sd = p_event->cast_to<InputEventScreenDrag>();
+ const InputEventScreenDrag *sd = Object::cast_to<InputEventScreenDrag>(*p_event);
if (st && !st->is_pressed() && finger_pressed == st->get_index()) {
diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h
index 8923da2ae4..7647070b26 100644
--- a/scene/2d/screen_button.h
+++ b/scene/2d/screen_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -61,7 +61,7 @@ private:
VisibilityMode visibility;
- void _input(const Ref<InputEvent> &p_Event);
+ void _input(const Ref<InputEvent> &p_event);
bool _is_point_inside(const Point2 &p_point);
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 2ec529a166..c53faab5f9 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -399,7 +399,7 @@ void ViewportSprite::_notification(int p_what) {
Node *n = get_node(viewport_path);
ERR_FAIL_COND(!n);
- Viewport *vp=n->cast_to<Viewport>();
+ Viewport *vp=Object::cast_to<Viewport>(n);
ERR_FAIL_COND(!vp);
Ref<RenderTargetTexture> rtt = vp->get_render_target_texture();
@@ -467,7 +467,7 @@ void ViewportSprite::set_viewport_path(const NodePath& p_viewport) {
Node *n = get_node(viewport_path);
ERR_FAIL_COND(!n);
- Viewport *vp=n->cast_to<Viewport>();
+ Viewport *vp=Object::cast_to<Viewport>(n);
ERR_FAIL_COND(!vp);
Ref<RenderTargetTexture> rtt = vp->get_render_target_texture();
@@ -544,13 +544,13 @@ Rect2 ViewportSprite::get_item_rect() const {
String ViewportSprite::get_configuration_warning() const {
- if (!has_node(viewport_path) || !get_node(viewport_path) || !get_node(viewport_path)->cast_to<Viewport>()) {
+ if (!has_node(viewport_path) || !Object::cast_to<Viewport>(get_node(viewport_path))) {
return TTR("Path property must point to a valid Viewport node to work. Such Viewport must be set to 'render target' mode.");
} else {
Node *n = get_node(viewport_path);
if (n) {
- Viewport *vp = n->cast_to<Viewport>();
+ Viewport *vp = Object::cast_to<Viewport>(n);
if (!vp->is_set_as_render_target()) {
return TTR("The Viewport set in the path property must be set as 'render target' in order for this sprite to work.");
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index d3f9a5f032..64d30325f2 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index e4494742a1..b1cc8c226a 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -50,12 +50,12 @@ void TileMap::_notification(int p_what) {
Node2D *c = this;
while (c) {
- navigation = c->cast_to<Navigation2D>();
+ navigation = Object::cast_to<Navigation2D>(c);
if (navigation) {
break;
}
- c = c->get_parent()->cast_to<Node2D>();
+ c = Object::cast_to<Node2D>(c->get_parent());
}
pending_update = true;
@@ -336,6 +336,7 @@ void TileMap::_update_dirty_quadrants() {
if (mat.is_valid())
vs->canvas_item_set_material(canvas_item, mat->get_rid());
vs->canvas_item_set_parent(canvas_item, get_canvas_item());
+ _update_item_material_state(canvas_item);
Transform2D xform;
xform.set_origin(q.pos);
vs->canvas_item_set_transform(canvas_item, xform);
@@ -370,15 +371,13 @@ void TileMap::_update_dirty_quadrants() {
s = tex->get_size();
else {
s = r.size;
- r.position.x += fp_adjust;
- r.position.y += fp_adjust;
- r.size.x -= fp_adjust * 2.0;
- r.size.y -= fp_adjust * 2.0;
}
Rect2 rect;
rect.position = offset.floor();
rect.size = s;
+ rect.size.x += fp_adjust;
+ rect.size.y += fp_adjust;
if (rect.size.y > rect.size.x) {
if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose))
@@ -782,6 +781,35 @@ void TileMap::_clear_quadrants() {
}
}
+void TileMap::set_material(const Ref<Material> &p_material) {
+
+ CanvasItem::set_material(p_material);
+ _update_all_items_material_state();
+}
+
+void TileMap::set_use_parent_material(bool p_use_parent_material) {
+
+ CanvasItem::set_use_parent_material(p_use_parent_material);
+ _update_all_items_material_state();
+}
+
+void TileMap::_update_all_items_material_state() {
+
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+
+ Quadrant &q = E->get();
+ for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
+
+ _update_item_material_state(E->get());
+ }
+ }
+}
+
+void TileMap::_update_item_material_state(const RID &p_canvas_item) {
+
+ VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid());
+}
+
void TileMap::clear() {
_clear_quadrants();
@@ -1068,20 +1096,20 @@ Transform2D TileMap::get_custom_transform() const {
return custom_transform;
}
-Vector2 TileMap::_map_to_world(int x, int y, bool p_ignore_ofs) const {
+Vector2 TileMap::_map_to_world(int p_x, int p_y, bool p_ignore_ofs) const {
- Vector2 ret = get_cell_transform().xform(Vector2(x, y));
+ Vector2 ret = get_cell_transform().xform(Vector2(p_x, p_y));
if (!p_ignore_ofs) {
switch (half_offset) {
case HALF_OFFSET_X: {
- if (ABS(y) & 1) {
+ if (ABS(p_y) & 1) {
ret += get_cell_transform()[0] * 0.5;
}
} break;
case HALF_OFFSET_Y: {
- if (ABS(x) & 1) {
+ if (ABS(p_x) & 1) {
ret += get_cell_transform()[1] * 0.5;
}
} break;
@@ -1315,15 +1343,18 @@ void TileMap::_bind_methods() {
ADD_SIGNAL(MethodInfo("settings_changed"));
BIND_CONSTANT(INVALID_CELL);
- BIND_CONSTANT(MODE_SQUARE);
- BIND_CONSTANT(MODE_ISOMETRIC);
- BIND_CONSTANT(MODE_CUSTOM);
- BIND_CONSTANT(HALF_OFFSET_X);
- BIND_CONSTANT(HALF_OFFSET_Y);
- BIND_CONSTANT(HALF_OFFSET_DISABLED);
- BIND_CONSTANT(TILE_ORIGIN_TOP_LEFT);
- BIND_CONSTANT(TILE_ORIGIN_CENTER);
- BIND_CONSTANT(TILE_ORIGIN_BOTTOM_LEFT);
+
+ BIND_ENUM_CONSTANT(MODE_SQUARE);
+ BIND_ENUM_CONSTANT(MODE_ISOMETRIC);
+ BIND_ENUM_CONSTANT(MODE_CUSTOM);
+
+ BIND_ENUM_CONSTANT(HALF_OFFSET_X);
+ BIND_ENUM_CONSTANT(HALF_OFFSET_Y);
+ BIND_ENUM_CONSTANT(HALF_OFFSET_DISABLED);
+
+ BIND_ENUM_CONSTANT(TILE_ORIGIN_TOP_LEFT);
+ BIND_ENUM_CONSTANT(TILE_ORIGIN_CENTER);
+ BIND_ENUM_CONSTANT(TILE_ORIGIN_BOTTOM_LEFT);
}
TileMap::TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 082e9d1018..c9d14e09d1 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -183,6 +183,9 @@ private:
void _update_quadrant_transform();
void _recompute_rect_cache();
+ void _update_all_items_material_state();
+ _FORCE_INLINE_ void _update_item_material_state(const RID &p_canvas_item);
+
_FORCE_INLINE_ int _get_quadrant_size() const;
void _set_tile_data(const PoolVector<int> &p_data);
@@ -278,6 +281,10 @@ public:
virtual void set_light_mask(int p_light_mask);
+ virtual void set_material(const Ref<Material> &p_material);
+
+ virtual void set_use_parent_material(bool p_use_parent_material);
+
void clear();
TileMap();
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index fb71b61d45..8fc8b65217 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,20 +29,20 @@
/*************************************************************************/
#include "visibility_notifier_2d.h"
+#include "engine.h"
#include "particles_2d.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
-#include "scene/scene_string_names.h"
void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(viewports.has(p_viewport));
viewports.insert(p_viewport);
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
return;
if (viewports.size() == 1) {
@@ -58,7 +58,7 @@ void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(!viewports.has(p_viewport));
viewports.erase(p_viewport);
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
return;
emit_signal(SceneStringNames::get_singleton()->viewport_exited, p_viewport);
@@ -74,7 +74,7 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
rect = p_rect;
if (is_inside_tree()) {
get_world_2d()->_update_notifier(this, get_global_transform().xform(rect));
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update();
item_rect_changed();
}
@@ -108,7 +108,7 @@ void VisibilityNotifier2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
draw_rect(rect, Color(1, 0.5, 1, 0.2));
}
@@ -184,7 +184,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
if (enabler[ENABLER_FREEZE_BODIES]) {
- RigidBody2D *rb2d = p_node->cast_to<RigidBody2D>();
+ RigidBody2D *rb2d = Object::cast_to<RigidBody2D>(p_node);
if (rb2d && ((rb2d->get_mode() == RigidBody2D::MODE_CHARACTER || (rb2d->get_mode() == RigidBody2D::MODE_RIGID && !rb2d->is_able_to_sleep())))) {
add = true;
@@ -194,7 +194,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
if (enabler[ENABLER_PAUSE_ANIMATIONS]) {
- AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
add = true;
}
@@ -202,7 +202,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
if (enabler[ENABLER_PAUSE_ANIMATED_SPRITES]) {
- AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
+ AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
if (as) {
add = true;
}
@@ -210,7 +210,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
if (enabler[ENABLER_PAUSE_PARTICLES]) {
- Particles2D *ps = p_node->cast_to<Particles2D>();
+ Particles2D *ps = Object::cast_to<Particles2D>(p_node);
if (ps) {
add = true;
}
@@ -236,7 +236,7 @@ void VisibilityEnabler2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
Node *from = this;
@@ -254,7 +254,7 @@ void VisibilityEnabler2D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
@@ -273,7 +273,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
ERR_FAIL_COND(!nodes.has(p_node));
{
- RigidBody2D *rb = p_node->cast_to<RigidBody2D>();
+ RigidBody2D *rb = Object::cast_to<RigidBody2D>(p_node);
if (rb) {
rb->set_sleeping(!p_enabled);
@@ -281,7 +281,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
}
{
- AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
@@ -289,7 +289,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
}
}
{
- AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
+ AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node);
if (as) {
@@ -301,7 +301,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
}
{
- Particles2D *ps = p_node->cast_to<Particles2D>();
+ Particles2D *ps = Object::cast_to<Particles2D>(p_node);
if (ps) {
@@ -341,13 +341,13 @@ void VisibilityEnabler2D::_bind_methods() {
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);
- BIND_CONSTANT(ENABLER_PAUSE_PARTICLES);
- BIND_CONSTANT(ENABLER_PAUSE_ANIMATED_SPRITES);
- BIND_CONSTANT(ENABLER_PARENT_PROCESS);
- BIND_CONSTANT(ENABLER_PARENT_FIXED_PROCESS);
- BIND_CONSTANT(ENABLER_MAX);
+ BIND_ENUM_CONSTANT(ENABLER_FREEZE_BODIES);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_PARTICLES);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_ANIMATED_SPRITES);
+ BIND_ENUM_CONSTANT(ENABLER_PARENT_PROCESS);
+ BIND_ENUM_CONSTANT(ENABLER_PARENT_FIXED_PROCESS);
+ BIND_ENUM_CONSTANT(ENABLER_MAX);
}
void VisibilityEnabler2D::set_enabler(Enabler p_enabler, bool p_enable) {
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index 38da69faef..ef0e1affd3 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp
index f258b7e2e0..e0fb3f0645 100644
--- a/scene/2d/y_sort.cpp
+++ b/scene/2d/y_sort.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h
index 3564cfc151..de7aa3a317 100644
--- a/scene/2d/y_sort.h
+++ b/scene/2d/y_sort.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index c64b807e43..217cb71230 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -115,7 +115,7 @@ real_t Area::get_priority() const {
void Area::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
@@ -133,7 +133,7 @@ void Area::_body_enter_tree(ObjectID p_id) {
void Area::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -152,7 +152,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
Map<ObjectID, BodyState>::Element *E = body_map.find(objid);
@@ -228,7 +228,7 @@ void Area::_clear_monitoring() {
for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
if (!node) //node may have been deleted in previous frame or at other legiminate point
continue;
@@ -258,7 +258,7 @@ void Area::_clear_monitoring() {
for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
if (!node) //node may have been deleted in previous frame or at other legiminate point
continue;
@@ -312,7 +312,7 @@ void Area::set_monitoring(bool p_enable) {
void Area::_area_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
@@ -330,7 +330,7 @@ void Area::_area_enter_tree(ObjectID p_id) {
void Area::_area_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -349,7 +349,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
Map<ObjectID, AreaState>::Element *E = area_map.find(objid);
diff --git a/scene/3d/area.h b/scene/3d/area.h
index 5df308fc47..7ea97d0a8c 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 3c99f7fb3a..caf313190b 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -40,14 +40,14 @@ void ARVRCamera::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
// need to find our ARVROrigin parent and let it know we're it's camera!
- ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
if (origin != NULL) {
origin->set_tracked_camera(this);
}
}; break;
case NOTIFICATION_EXIT_TREE: {
// need to find our ARVROrigin parent and let it know we're no longer it's camera!
- ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
if (origin != NULL) {
origin->clear_tracked_camera_if(this);
}
@@ -60,7 +60,7 @@ String ARVRCamera::get_configuration_warning() const {
return String();
// must be child node of ARVROrigin!
- ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
if (origin == NULL) {
return TTR("ARVRCamera must have an ARVROrigin node as its parent");
};
@@ -209,7 +209,7 @@ String ARVRController::get_configuration_warning() const {
return String();
// must be child node of ARVROrigin!
- ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
if (origin == NULL) {
return TTR("ARVRController must have an ARVROrigin node as its parent");
};
@@ -264,7 +264,7 @@ void ARVRAnchor::_notification(int p_what) {
// our basis is scaled to the size of the plane the anchor is tracking
// extract the size from our basis and reset the scale
size = transform.basis.get_scale() * world_scale;
- transform.basis.set_scale(Vector3(1.0, 1.0, 1.0));
+ transform.basis.orthonormalize();
// apply our reference frame and set our transform
set_transform(arvr_server->get_reference_frame() * transform);
@@ -321,7 +321,7 @@ String ARVRAnchor::get_configuration_warning() const {
return String();
// must be child node of ARVROrigin!
- ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
if (origin == NULL) {
return TTR("ARVRAnchor must have an ARVROrigin node as its parent");
};
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index 936519126b..4c14be71b5 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 6abc2caac8..6efdf25f0d 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -215,7 +215,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
velocity_tracker->reset(get_global_transform().origin);
AudioServer::get_singleton()->add_callback(_mix_audios, this);
- if (autoplay && !get_tree()->is_editor_hint()) {
+ if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
}
}
@@ -266,7 +266,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
if (!sr[i].collider)
continue;
- Area *tarea = sr[i].collider->cast_to<Area>();
+ Area *tarea = Object::cast_to<Area>(sr[i].collider);
if (!tarea)
continue;
@@ -533,6 +533,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
if (!active) {
set_fixed_process_internal(false);
_change_notify("playing"); //update property in editor
+ emit_signal("finished");
}
}
}
@@ -888,16 +889,18 @@ void AudioStreamPlayer3D::_bind_methods() {
ADD_GROUP("Doppler", "doppler_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "doppler_tracking", PROPERTY_HINT_ENUM, "Disabled,Idle,Fixed"), "set_doppler_tracking", "get_doppler_tracking");
- BIND_CONSTANT(ATTENUATION_INVERSE_DISTANCE);
- BIND_CONSTANT(ATTENUATION_INVERSE_SQUARE_DISTANCE);
- BIND_CONSTANT(ATTENUATION_LOGARITHMIC);
+ BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_DISTANCE);
+ BIND_ENUM_CONSTANT(ATTENUATION_INVERSE_SQUARE_DISTANCE);
+ BIND_ENUM_CONSTANT(ATTENUATION_LOGARITHMIC);
- BIND_CONSTANT(OUT_OF_RANGE_MIX);
- BIND_CONSTANT(OUT_OF_RANGE_PAUSE);
+ BIND_ENUM_CONSTANT(OUT_OF_RANGE_MIX);
+ BIND_ENUM_CONSTANT(OUT_OF_RANGE_PAUSE);
- BIND_CONSTANT(DOPPLER_TRACKING_DISABLED);
- BIND_CONSTANT(DOPPLER_TRACKING_IDLE_STEP);
- BIND_CONSTANT(DOPPLER_TRACKING_FIXED_STEP);
+ BIND_ENUM_CONSTANT(DOPPLER_TRACKING_DISABLED);
+ BIND_ENUM_CONSTANT(DOPPLER_TRACKING_IDLE_STEP);
+ BIND_ENUM_CONSTANT(DOPPLER_TRACKING_FIXED_STEP);
+
+ ADD_SIGNAL(MethodInfo("finished"));
}
AudioStreamPlayer3D::AudioStreamPlayer3D() {
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index b55b788b54..e1a5329fb0 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -51,9 +51,7 @@ bool BoneAttachment::_set(const StringName &p_name, const Variant &p_value) {
}
void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
- Skeleton *parent = NULL;
- if (get_parent())
- parent = get_parent()->cast_to<Skeleton>();
+ Skeleton *parent = Object::cast_to<Skeleton>(get_parent());
if (parent) {
@@ -73,8 +71,8 @@ void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
void BoneAttachment::_check_bind() {
- if (get_parent() && get_parent()->cast_to<Skeleton>()) {
- Skeleton *sk = get_parent()->cast_to<Skeleton>();
+ if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {
+
int idx = sk->find_bone(bone_name);
if (idx != -1) {
sk->bind_child_node_to_bone(idx, this);
@@ -88,8 +86,8 @@ void BoneAttachment::_check_unbind() {
if (bound) {
- if (get_parent() && get_parent()->cast_to<Skeleton>()) {
- Skeleton *sk = get_parent()->cast_to<Skeleton>();
+ if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {
+
int idx = sk->find_bone(bone_name);
if (idx != -1) {
sk->unbind_child_node_from_bone(idx, this);
diff --git a/scene/3d/bone_attachment.h b/scene/3d/bone_attachment.h
index 65908d98a8..159d16157a 100644
--- a/scene/3d/bone_attachment.h
+++ b/scene/3d/bone_attachment.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 3c5eb21d38..02a7845e0b 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -339,15 +339,8 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const {
ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
}
-#if 0
- Size2 viewport_size = get_viewport()->get_visible_rect().size;
- Vector2 cpos = p_pos;
-#else
-
Size2 viewport_size = get_viewport()->get_camera_rect_size();
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
-#endif
-
Vector3 ray;
if (mode == PROJECTION_ORTHOGONAL) {
@@ -371,17 +364,9 @@ Vector3 Camera::project_ray_origin(const Point2 &p_pos) const {
ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
}
-#if 0
- Size2 viewport_size = get_viewport()->get_visible_rect().size;
- Vector2 cpos = p_pos;
-#else
-
Size2 viewport_size = get_viewport()->get_camera_rect_size();
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
-#endif
-
ERR_FAIL_COND_V(viewport_size.y == 0, Vector3());
- //float aspect = viewport_size.x / viewport_size.y;
if (mode == PROJECTION_PERSPECTIVE) {
@@ -564,15 +549,15 @@ void Camera::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera::get_doppler_tracking);
//ClassDB::bind_method(D_METHOD("_camera_make_current"),&Camera::_camera_make_current );
- BIND_CONSTANT(PROJECTION_PERSPECTIVE);
- BIND_CONSTANT(PROJECTION_ORTHOGONAL);
+ BIND_ENUM_CONSTANT(PROJECTION_PERSPECTIVE);
+ BIND_ENUM_CONSTANT(PROJECTION_ORTHOGONAL);
- BIND_CONSTANT(KEEP_WIDTH);
- BIND_CONSTANT(KEEP_HEIGHT);
+ BIND_ENUM_CONSTANT(KEEP_WIDTH);
+ BIND_ENUM_CONSTANT(KEEP_HEIGHT);
- BIND_CONSTANT(DOPPLER_TRACKING_DISABLED)
- BIND_CONSTANT(DOPPLER_TRACKING_IDLE_STEP)
- BIND_CONSTANT(DOPPLER_TRACKING_FIXED_STEP)
+ BIND_ENUM_CONSTANT(DOPPLER_TRACKING_DISABLED)
+ BIND_ENUM_CONSTANT(DOPPLER_TRACKING_IDLE_STEP)
+ BIND_ENUM_CONSTANT(DOPPLER_TRACKING_FIXED_STEP)
}
float Camera::get_fov() const {
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 43975892b4..243a7b9b39 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -126,9 +126,9 @@ public:
virtual Transform get_camera_transform() const;
- Vector3 project_ray_normal(const Point2 &p_point) const;
- Vector3 project_ray_origin(const Point2 &p_point) const;
- Vector3 project_local_ray_normal(const Point2 &p_point) const;
+ Vector3 project_ray_normal(const Point2 &p_pos) const;
+ Vector3 project_ray_origin(const Point2 &p_pos) const;
+ Vector3 project_local_ray_normal(const Point2 &p_pos) const;
Point2 unproject_position(const Vector3 &p_pos) const;
bool is_position_behind(const Vector3 &p_pos) const;
Vector3 project_position(const Point2 &p_point) const;
diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp
deleted file mode 100644
index 065e21fccd..0000000000
--- a/scene/3d/character_camera.cpp
+++ /dev/null
@@ -1,718 +0,0 @@
-/*************************************************************************/
-/* character_camera.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "character_camera.h"
-
-#include "physics_body.h"
-#if 0
-void CharacterCamera::_set(const String& p_name, const Variant& p_value) {
-
- if (p_name=="type")
- set_camera_type((CameraType)((int)(p_value)));
- else if (p_name=="orbit")
- set_orbit(p_value);
- else if (p_name=="height")
- set_height(p_value);
- else if (p_name=="inclination")
- set_inclination(p_value);
- else if (p_name=="max_orbit_x")
- set_max_orbit_x(p_value);
- else if (p_name=="min_orbit_x")
- set_min_orbit_x(p_value);
- else if (p_name=="max_distance")
- set_max_distance(p_value);
- else if (p_name=="min_distance")
- set_min_distance(p_value);
- else if (p_name=="distance")
- set_distance(p_value);
- else if (p_name=="clip")
- set_clip(p_value);
- else if (p_name=="autoturn")
- set_autoturn(p_value);
- else if (p_name=="autoturn_tolerance")
- set_autoturn_tolerance(p_value);
- else if (p_name=="autoturn_speed")
- set_autoturn_speed(p_value);
-
-}
-Variant CharacterCamera::_get(const String& p_name) const {
-
- if (p_name=="type")
- return get_camera_type();
- else if (p_name=="orbit")
- return get_orbit();
- else if (p_name=="height")
- return get_height();
- else if (p_name=="inclination")
- return get_inclination();
- else if (p_name=="max_orbit_x")
- return get_max_orbit_x();
- else if (p_name=="min_orbit_x")
- return get_min_orbit_x();
- else if (p_name=="max_distance")
- return get_max_distance();
- else if (p_name=="min_distance")
- return get_min_distance();
- else if (p_name=="distance")
- return get_distance();
- else if (p_name=="clip")
- return has_clip();
- else if (p_name=="autoturn")
- return has_autoturn();
- else if (p_name=="autoturn_tolerance")
- return get_autoturn_tolerance();
- else if (p_name=="autoturn_speed")
- return get_autoturn_speed();
-
- return Variant();
-}
-
-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, "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" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "max_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "distance", PROPERTY_HINT_RANGE,"0.01,1024,0,01") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "clip") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "autoturn") );
- p_list->push_back( PropertyInfo( Variant::REAL, "autoturn_tolerance", PROPERTY_HINT_RANGE,"1,90,0.01") );
- p_list->push_back( PropertyInfo( Variant::REAL, "autoturn_speed", PROPERTY_HINT_RANGE,"1,90,0.01") );
-
-
-}
-
-void CharacterCamera::_compute_camera() {
-
-
- // update the transform with the next proposed transform (camera is 1 logic frame delayed)
-
- /*
- float time = get_root_node()->get_frame_time();
- Vector3 oldp = accepted.get_origin();
- Vector3 newp = proposed.get_origin();
-
- float frame_dist = time *
- if (oldp.distance_to(newp) >
- */
-
- float time = get_root_node()->get_frame_time();
-
- if (true) {
-
- if (clip_ray[0].clipped && clip_ray[1].clipped && clip_ray[2].clipped) {
- //all have been clipped
- proposed.origin=clip_ray[1].clip_pos;
-
-
- } else {
-
- Vector3 rel=proposed.origin-target_pos;
-
- if (clip_ray[0].clipped && !clip_ray[2].clipped) {
-
- float distance = target_pos.distance_to(clip_ray[0].clip_pos);
- real_t amount = 1.0-(distance/clip_len);
- amount = CLAMP(amount,0,1);
-
-
- rel=Matrix3(Vector3(0,1,0)),
- rotate_orbit(Vector2(0,autoturn_speed*time*amount));
- }
- if (clip_ray[2].clipped && !clip_ray[0].clipped) {
-
- float distance = target_pos.distance_to(clip_ray[2].clip_pos);
- real_t amount = 1.0-(distance/clip_len);
- amount = CLAMP(amount,0,1);
-
- rotate_orbit(Vector2(0,-autoturn_speed*time*amount));
- }
-
- }
- }
-
-
- Transform final;
-
- static float pos_ratio = 0.9;
- static float rot_ratio = 10;
-
- Vector3 vec1 = accepted.origin;
- Vector3 vec2 = proposed.origin;
- final.origin = vec2.linear_interpolate(vec1, pos_ratio * time);
-
- Quat q1 = accepted.basis;
- Quat q2 = proposed.basis;
- final.basis = q1.slerp(q2, rot_ratio * time);
-
- accepted=final;
-
- _update_camera();
-
- // calculate the next proposed transform
-
-
- Vector3 new_pos;
- Vector3 character_pos = get_global_transform().origin;
- character_pos.y+=height; // height compensate
-
- if(type==CAMERA_FOLLOW) {
-
-
-
- /* calculate some variables */
-
- Vector3 rel = follow_pos - character_pos;
-
- float l = rel.length();
- Vector3 rel_n = (l > 0) ? (rel/l) : Vector3();
-#if 1
- float ang = Math::acos(rel_n.dot( Vector3(0,1,0) ));
-
- Vector3 tangent = rel_n;
- tangent.y=0; // get rid of y
- if (tangent.length_squared() < CMP_EPSILON2)
- tangent=Vector3(0,0,1); // use Z as tangent if rel is parallel to y
- else
- tangent.normalize();
-
- /* now start applying the rules */
-
- //clip distance
- if (l > max_distance)
- l=max_distance;
- if (l < min_distance)
- l=min_distance;
-
- //fix angle
-
- float ang_min = Math_PI * 0.5 + Math::deg2rad(min_orbit_x);
- float ang_max = Math_PI * 0.5 + Math::deg2rad(max_orbit_x);
-
- if (ang<ang_min)
- ang=ang_min;
- if (ang>ang_max)
- ang=ang_max;
-
- /* finally, rebuild the validated camera position */
-
- new_pos=Vector3(0,Math::cos(ang),0);
- new_pos+=tangent*Math::sin(ang);
- new_pos*=l;
- new_pos+=character_pos;
-#else
- if (l > max_distance)
- l=max_distance;
- if (l < min_distance)
- l=min_distance;
-
- new_pos = character_pos + rel_n * l;
-
-#endif
- follow_pos=new_pos;
-
- } else if (type==CAMERA_FIXED) {
-
-
- if (distance<min_distance)
- distance=min_distance;
- if (distance>max_distance)
- distance=max_distance;
-
- if (orbit.x<min_orbit_x)
- orbit.x=min_orbit_x;
- if (orbit.x>max_orbit_x)
- orbit.x=max_orbit_x;
-
- Matrix3 m;
- m.rotate(Vector3(0,1,0),-Math::deg2rad(orbit.y));
- m.rotate(Vector3(1,0,0),-Math::deg2rad(orbit.x));
-
- new_pos = (m.get_axis(2) * distance) + character_pos;
-
- if (use_lookat_target) {
-
- Transform t = get_global_transform();
- Vector3 y = t.basis.get_axis(1).normalized();
- Vector3 z = lookat_target - character_pos;
- z= (z - y * y.dot(z)).normalized();
- orbit.y = -Math::rad2deg(Math::atan2(z.x,z.z)) + 180;
-
- /*
- Transform t = get_global_transform();
- Vector3 y = t.basis.get_axis(1).normalized();
- Vector3 z = lookat_target - t.origin;
- z= (z - y * y.dot(z)).normalized();
- Vector3 x = z.cross(y).normalized();
- Transform t2;
- t2.basis.set_axis(0,x);
- t2.basis.set_axis(1,y);
- t2.basis.set_axis(2,z);
- t2.origin=t.origin;
-
- Vector3 local = t2.xform_inv(camera_pos);
-
- float ang = Math::atan2(local.x,local.y);
- */
-
- /*
-
- Vector3 vec1 = lookat_target - new_pos;
- vec1.normalize();
- Vector3 vec2 = character_pos - new_pos;
- vec2.normalize();
-
- float dot = vec1.dot(vec2);
- printf("dot %f\n", dot);
- if ( dot < 0.5) {
-
- rotate_orbit(Vector2(0, 90));
- };
- */
-
-
- };
- }
-
- Vector3 target;
- if (use_lookat_target) {
-
- target = lookat_target;
- } else {
- target = character_pos;
- };
-
- proposed.set_look_at(new_pos,target,Vector3(0,1,0));
- proposed = proposed * Transform(Matrix3(Vector3(1,0,0),Math::deg2rad(inclination)),Vector3()); //inclination
-
-
- Vector<RID> exclude;
- exclude.push_back(target_body);
-
-
-
- Vector3 rel = new_pos-target;
-
- for(int i=0;i<3;i++) {
-
- PhysicsServer::get_singleton()->query_intersection(clip_ray[i].query,get_world().get_space(),exclude);
- PhysicsServer::get_singleton()->query_intersection_segment(clip_ray[i].query,target,target+Matrix3(Vector3(0,1,0),Math::deg2rad(autoturn_tolerance*(i-1.0))).xform(rel));
- clip_ray[i].clipped=false;
- clip_ray[i].clip_pos=Vector3();
- }
- target_pos=target;
- clip_len=rel.length();
-
-
-
-}
-
-void CharacterCamera::set_use_lookat_target(bool p_use, const Vector3 &p_lookat) {
-
- use_lookat_target = p_use;
- lookat_target = p_lookat;
-};
-
-
-void CharacterCamera::_notification(int p_what) {
-
- switch(p_what) {
-
- case NOTIFICATION_PROCESS: {
-
-
- _compute_camera();
- } break;
-
- case NOTIFICATION_ENTER_SCENE: {
-
- if (type==CAMERA_FOLLOW) {
-
- set_orbit(orbit);
- set_distance(distance);
- }
-
- accepted=get_global_transform();
- proposed=accepted;
-
- target_body = RID();
-
- Node* parent = get_parent();
- while (parent) {
- PhysicsBody* p = parent->cast_to<PhysicsBody>();
- if (p) {
- target_body = p->get_body();
- break;
- };
- parent = parent->get_parent();
- };
-
- } break;
-
- case NOTIFICATION_TRANSFORM_CHANGED: {
-
- } break;
- case NOTIFICATION_EXIT_SCENE: {
-
- if (type==CAMERA_FOLLOW) {
- distance=get_distance();
- orbit=get_orbit();
-
- }
- } break;
-
- case NOTIFICATION_BECAME_CURRENT: {
-
- set_process(true);
- } break;
- case NOTIFICATION_LOST_CURRENT: {
-
- set_process(false);
- } break;
- }
-
-}
-
-
-void CharacterCamera::set_camera_type(CameraType p_camera_type) {
-
-
- if (p_camera_type==type)
- return;
-
- type=p_camera_type;
-
- // do conversions
-}
-
-CharacterCamera::CameraType CharacterCamera::get_camera_type() const {
-
- return type;
-
-}
-
-void CharacterCamera::set_orbit(const Vector2& p_orbit) {
-
- orbit=p_orbit;
-
- if(type == CAMERA_FOLLOW && is_inside_scene()) {
-
- Vector3 char_pos = get_global_transform().origin;
- char_pos.y+=height;
- float d = char_pos.distance_to(follow_pos);
-
- Matrix3 m;
- m.rotate(Vector3(0,1,0),-orbit.y);
- m.rotate(Vector3(1,0,0),-orbit.x);
-
- follow_pos=char_pos + m.get_axis(2) * d;
-
- }
-
-}
-void CharacterCamera::set_orbit_x(float p_x) {
-
- orbit.x=p_x;
- if(type == CAMERA_FOLLOW && is_inside_scene())
- set_orbit(Vector2( p_x, get_orbit().y ));
-}
-void CharacterCamera::set_orbit_y(float p_y) {
-
-
- orbit.y=p_y;
- if(type == CAMERA_FOLLOW && is_inside_scene())
- set_orbit(Vector2( get_orbit().x, p_y ));
-
-}
-Vector2 CharacterCamera::get_orbit() const {
-
-
- if (type == CAMERA_FOLLOW && is_inside_scene()) {
-
- Vector3 char_pos = get_global_transform().origin;
- char_pos.y+=height;
- Vector3 rel = (follow_pos - char_pos).normalized();
- Vector2 ret_orbit;
- ret_orbit.x = Math::acos( Vector3(0,1,0).dot( rel ) ) - Math_PI * 0.5;
- ret_orbit.y = Math::atan2(rel.x,rel.z);
- return ret_orbit;
- }
- return orbit;
-}
-
-void CharacterCamera::rotate_orbit(const Vector2& p_relative) {
-
- if (type == CAMERA_FOLLOW && is_inside_scene()) {
-
- Matrix3 m;
- m.rotate(Vector3(0,1,0),-Math::deg2rad(p_relative.y));
- m.rotate(Vector3(1,0,0),-Math::deg2rad(p_relative.x));
-
- Vector3 char_pos = get_global_transform().origin;
- char_pos.y+=height;
- Vector3 rel = (follow_pos - char_pos);
- rel = m.xform(rel);
- follow_pos=char_pos+rel;
-
- }
-
- orbit+=p_relative;
-}
-
-void CharacterCamera::set_height(float p_height) {
-
-
- height=p_height;
-}
-
-float CharacterCamera::get_height() const {
-
- return height;
-
-}
-
-void CharacterCamera::set_max_orbit_x(float p_max) {
-
- max_orbit_x=p_max;
-}
-
-float CharacterCamera::get_max_orbit_x() const {
-
- return max_orbit_x;
-}
-
-void CharacterCamera::set_min_orbit_x(float p_min) {
-
- min_orbit_x=p_min;
-}
-
-float CharacterCamera::get_min_orbit_x() const {
-
- return min_orbit_x;
-}
-
-float CharacterCamera::get_min_distance() const {
-
- return min_distance;
-}
-float CharacterCamera::get_max_distance() const {
-
- return max_distance;
-}
-
-void CharacterCamera::set_min_distance(float p_min) {
-
- min_distance=p_min;
-}
-
-void CharacterCamera::set_max_distance(float p_max) {
-
- max_distance = p_max;
-}
-
-
-void CharacterCamera::set_distance(float p_distance) {
-
- if (type == CAMERA_FOLLOW && is_inside_scene()) {
-
- Vector3 char_pos = get_global_transform().origin;
- char_pos.y+=height;
- Vector3 rel = (follow_pos - char_pos).normalized();
- rel*=p_distance;
- follow_pos=char_pos+rel;
-
- }
-
- distance=p_distance;
-}
-
-float CharacterCamera::get_distance() const {
-
- if (type == CAMERA_FOLLOW && is_inside_scene()) {
-
- Vector3 char_pos = get_global_transform().origin;
- char_pos.y+=height;
- return (follow_pos - char_pos).length();
-
- }
-
- return distance;
-}
-
-void CharacterCamera::set_clip(bool p_enabled) {
-
-
- clip=p_enabled;
-}
-
-bool CharacterCamera::has_clip() const {
-
- return clip;
-
-}
-
-
-void CharacterCamera::set_autoturn(bool p_enabled) {
-
-
- autoturn=p_enabled;
-}
-
-bool CharacterCamera::has_autoturn() const {
-
- return autoturn;
-
-}
-
-void CharacterCamera::set_autoturn_tolerance(float p_degrees) {
-
-
- autoturn_tolerance=p_degrees;
-}
-float CharacterCamera::get_autoturn_tolerance() const {
-
-
- return autoturn_tolerance;
-}
-
-void CharacterCamera::set_inclination(float p_degrees) {
-
-
- inclination=p_degrees;
-}
-float CharacterCamera::get_inclination() const {
-
-
- return inclination;
-}
-
-
-void CharacterCamera::set_autoturn_speed(float p_speed) {
-
-
- autoturn_speed=p_speed;
-}
-float CharacterCamera::get_autoturn_speed() const {
-
- return autoturn_speed;
-
-}
-
-
-
-
-
-void CharacterCamera::_bind_methods() {
-
- 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 );
-}
-
-void CharacterCamera::_ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx) {
-
-
- clip_ray[p_idx].clip_pos=p_point;
- clip_ray[p_idx].clipped=true;
-};
-
-Transform CharacterCamera::get_camera_transform() const {
-
- return accepted;
-}
-
-
-CharacterCamera::CharacterCamera() {
-
-
- type=CAMERA_FOLLOW;
- height=1;
-
- orbit=Vector2(0,0);
-
- distance=3;
- min_distance=2;
- max_distance=5;
-
- autoturn=false;
- autoturn_tolerance=15;
- autoturn_speed=20;
-
- min_orbit_x=-50;
- max_orbit_x=70;
- inclination=0;
-
- clip=false;
- use_lookat_target = false;
-
- for(int i=0;i<3;i++) {
- clip_ray[i].query=PhysicsServer::get_singleton()->query_create(this, "_ray_collision", i, true);
- clip_ray[i].clipped=false;
- }
-
-
-}
-
-CharacterCamera::~CharacterCamera() {
-
- for(int i=0;i<3;i++) {
- PhysicsServer::get_singleton()->free(clip_ray[i].query);
- }
-
-
-}
-#endif
diff --git a/scene/3d/character_camera.h b/scene/3d/character_camera.h
deleted file mode 100644
index c3a1c70d5e..0000000000
--- a/scene/3d/character_camera.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*************************************************************************/
-/* character_camera.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef CHARACTER_CAMERA_H
-#define CHARACTER_CAMERA_H
-
-#include "scene/3d/camera.h"
-#if 0
-class CharacterCamera : public Camera {
-
- GDCLASS( CharacterCamera, Camera );
-public:
-
- enum CameraType {
- CAMERA_FIXED,
- CAMERA_FOLLOW
- };
-
-private:
-
-
- CameraType type;
-
- //used for follow
- Vector3 follow_pos;
- //used for fixed
- Vector2 orbit;
- float distance;
-
- float height;
-
- float min_distance;
- float max_distance;
-
- float max_orbit_x;
- float min_orbit_x;
-
- float inclination;
-
- bool clip;
- bool autoturn;
- float autoturn_tolerance;
- float autoturn_speed;
-
-
-
- struct ClipRay {
- RID query;
- bool clipped;
- Vector3 clip_pos;
- };
-
- ClipRay clip_ray[3];
- Vector3 target_pos;
- float clip_len;
-
-
- Transform accepted;
- Vector3 proposed_pos;
-
- bool use_lookat_target;
- Vector3 lookat_target;
-
- void _compute_camera();
-
- RID ray_query;
- RID left_turn_query;
- RID right_turn_query;
- RID target_body;
-
-protected:
-
- virtual void _request_camera_update() {} //ignore
-
- 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();
-
- void _ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx);
-
-public:
-
-
- void set_camera_type(CameraType p_camera_type);
- CameraType get_camera_type() const;
-
- void set_orbit(const Vector2& p_orbit);
- void set_orbit_x(float p_x);
- void set_orbit_y(float p_y);
- Vector2 get_orbit() const;
-
- void set_height(float p_height);
- float get_height() const;
-
- void set_inclination(float p_degrees);
- float get_inclination() const;
-
- void set_max_orbit_x(float p_max);
- float get_max_orbit_x() const;
-
- void set_min_orbit_x(float p_min);
- float get_min_orbit_x() const;
-
- void rotate_orbit(const Vector2& p_relative);
-
- void set_distance(float p_distance);
- float get_distance() const;
-
- float get_min_distance() const;
- float get_max_distance() const;
- void set_min_distance(float p_min);
- void set_max_distance(float p_max);
-
-
- void set_clip(bool p_enabled);
- bool has_clip() const;
-
- void set_autoturn(bool p_enabled);
- bool has_autoturn() const;
-
- void set_autoturn_tolerance(float p_degrees);
- float get_autoturn_tolerance() const;
-
- void set_autoturn_speed(float p_speed);
- float get_autoturn_speed() const;
-
- void set_use_lookat_target(bool p_use, const Vector3 &p_lookat = Vector3());
-
- virtual Transform get_camera_transform() const;
-
- CharacterCamera();
- ~CharacterCamera();
-};
-
-VARIANT_ENUM_CAST( CharacterCamera::CameraType );
-
-#endif
-#endif // CHARACTER_CAMERA_H
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 1aba26673c..c121ef4566 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_object.h"
+
#include "scene/scene_string_names.h"
#include "servers/physics_server.h"
diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h
index 6c13e5d505..ac35de697c 100644
--- a/scene/3d/collision_object.h
+++ b/scene/3d/collision_object.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index 0c61c96d07..382cbb8f38 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -77,7 +77,7 @@ void CollisionPolygon::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_PARENTED: {
- parent = get_parent()->cast_to<CollisionObject>();
+ parent = Object::cast_to<CollisionObject>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
_build_polygon();
@@ -147,7 +147,7 @@ bool CollisionPolygon::is_disabled() const {
String CollisionPolygon::get_configuration_warning() const {
- if (!get_parent()->cast_to<CollisionObject>()) {
+ if (!Object::cast_to<CollisionObject>(get_parent())) {
return TTR("CollisionPolygon only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
}
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index beefae182c..dbed1d7154 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
index 4fd215bd1a..4d4ed30d03 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -50,9 +50,8 @@ void CollisionShape::make_convex_from_brothers() {
for (int i = 0; i < p->get_child_count(); i++) {
Node *n = p->get_child(i);
- if (n->cast_to<MeshInstance>()) {
+ if (MeshInstance *mi = Object::cast_to<MeshInstance>(n)) {
- MeshInstance *mi = n->cast_to<MeshInstance>();
Ref<Mesh> m = mi->get_mesh();
if (m.is_valid()) {
@@ -68,7 +67,7 @@ void CollisionShape::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_PARENTED: {
- parent = get_parent()->cast_to<CollisionObject>();
+ parent = Object::cast_to<CollisionObject>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
if (shape.is_valid()) {
@@ -89,13 +88,6 @@ void CollisionShape::_notification(int p_what) {
parent->shape_owner_set_transform(owner_id, get_transform());
}
} break;
- case NOTIFICATION_EXIT_TREE: {
- if (parent) {
- parent->remove_shape_owner(owner_id);
- }
- owner_id = 0;
- parent = NULL;
- } break;
case NOTIFICATION_UNPARENTED: {
if (parent) {
parent->remove_shape_owner(owner_id);
@@ -113,7 +105,7 @@ void CollisionShape::resource_changed(RES res) {
String CollisionShape::get_configuration_warning() const {
- if (!get_parent()->cast_to<CollisionObject>()) {
+ if (!Object::cast_to<CollisionObject>(get_parent())) {
return TTR("CollisionShape only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
}
diff --git a/scene/3d/collision_shape.h b/scene/3d/collision_shape.h
index 277e0dfa77..6d849f42af 100644
--- a/scene/3d/collision_shape.h
+++ b/scene/3d/collision_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 2174f924ac..0232ce7653 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -1091,7 +1091,7 @@ void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_b
void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
- MeshInstance *mi = p_at_node->cast_to<MeshInstance>();
+ MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
@@ -1113,9 +1113,8 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
}
}
- if (p_at_node->cast_to<Spatial>()) {
+ if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) {
- 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) {
@@ -1488,10 +1487,10 @@ void GIProbe::_bind_methods() {
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);
- BIND_CONSTANT(SUBDIV_128);
- BIND_CONSTANT(SUBDIV_256);
- BIND_CONSTANT(SUBDIV_MAX);
+ BIND_ENUM_CONSTANT(SUBDIV_64);
+ BIND_ENUM_CONSTANT(SUBDIV_128);
+ BIND_ENUM_CONSTANT(SUBDIV_256);
+ BIND_ENUM_CONSTANT(SUBDIV_MAX);
}
GIProbe::GIProbe() {
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index 8346437ebd..5a06984a47 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 060e088750..64d3f4fcab 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index 2eb4bf1e6b..b2bcb5af1a 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -52,8 +52,8 @@ public:
void set_normal(const Vector3 &p_normal);
void set_tangent(const Plane &p_tangent);
void set_color(const Color &p_color);
- void set_uv(const Vector2 &tex_uv);
- void set_uv2(const Vector2 &tex_uv);
+ void set_uv(const Vector2 &p_uv);
+ void set_uv2(const Vector2 &p_uv2);
void add_vertex(const Vector3 &p_vertex);
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index 36a6660bf9..157ae42571 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,12 +29,14 @@
/*************************************************************************/
#include "interpolated_camera.h"
+#include "engine.h"
+
void InterpolatedCamera::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- if (get_tree()->is_editor_hint() && enabled)
+ if (Engine::get_singleton()->is_editor_hint() && enabled)
set_fixed_process(false);
} break;
@@ -44,7 +46,7 @@ void InterpolatedCamera::_notification(int p_what) {
break;
if (has_node(target)) {
- Spatial *node = get_node(target)->cast_to<Spatial>();
+ Spatial *node = Object::cast_to<Spatial>(get_node(target));
if (!node)
break;
@@ -54,8 +56,8 @@ void InterpolatedCamera::_notification(int p_what) {
local_transform = local_transform.interpolate_with(target_xform, delta);
set_global_transform(local_transform);
- if (node->cast_to<Camera>()) {
- Camera *cam = node->cast_to<Camera>();
+ if (Camera *cam = Object::cast_to<Camera>(node)) {
+
if (cam->get_projection() == get_projection()) {
float new_near = Math::lerp(get_znear(), cam->get_znear(), delta);
@@ -81,7 +83,7 @@ void InterpolatedCamera::_notification(int p_what) {
void InterpolatedCamera::_set_target(const Object *p_target) {
ERR_FAIL_NULL(p_target);
- set_target(p_target->cast_to<Spatial>());
+ set_target(Object::cast_to<Spatial>(p_target));
}
void InterpolatedCamera::set_target(const Spatial *p_target) {
@@ -106,7 +108,7 @@ void InterpolatedCamera::set_interpolation_enabled(bool p_enable) {
return;
enabled = p_enable;
if (p_enable) {
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
return;
set_process(true);
} else
diff --git a/scene/3d/interpolated_camera.h b/scene/3d/interpolated_camera.h
index c302c32fc9..26e7278c99 100644
--- a/scene/3d/interpolated_camera.h
+++ b/scene/3d/interpolated_camera.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 977f1f81a7..09b253b309 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "light.h"
+#include "engine.h"
#include "project_settings.h"
#include "scene/resources/surface_tool.h"
@@ -106,6 +107,16 @@ Color Light::get_shadow_color() const {
return shadow_color;
}
+void Light::set_shadow_reverse_cull_face(bool p_enable) {
+ reverse_cull = p_enable;
+ VS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull);
+}
+
+bool Light::get_shadow_reverse_cull_face() const {
+
+ return reverse_cull;
+}
+
Rect3 Light::get_aabb() const {
if (type == VisualServer::LIGHT_DIRECTIONAL) {
@@ -140,7 +151,7 @@ void Light::_update_visibility() {
#ifdef TOOLS_ENABLED
if (editor_only) {
- if (!get_tree()->is_editor_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint()) {
editor_ok = false;
} else {
editor_ok = (get_tree()->get_edited_scene_root() && (this == get_tree()->get_edited_scene_root() || get_owner() == get_tree()->get_edited_scene_root()));
@@ -202,6 +213,9 @@ void Light::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_color", "color"), &Light::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &Light::get_color);
+ ClassDB::bind_method(D_METHOD("set_shadow_reverse_cull_face", "enable"), &Light::set_shadow_reverse_cull_face);
+ ClassDB::bind_method(D_METHOD("get_shadow_reverse_cull_face"), &Light::get_shadow_reverse_cull_face);
+
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);
@@ -217,25 +231,26 @@ void Light::_bind_methods() {
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_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face");
ADD_GROUP("Editor", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
ADD_GROUP("", "");
- BIND_CONSTANT(PARAM_ENERGY);
- BIND_CONSTANT(PARAM_SPECULAR);
- BIND_CONSTANT(PARAM_RANGE);
- 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);
- BIND_CONSTANT(PARAM_SHADOW_SPLIT_3_OFFSET);
- BIND_CONSTANT(PARAM_SHADOW_NORMAL_BIAS);
- BIND_CONSTANT(PARAM_SHADOW_BIAS);
+ BIND_ENUM_CONSTANT(PARAM_ENERGY);
+ BIND_ENUM_CONSTANT(PARAM_SPECULAR);
+ BIND_ENUM_CONSTANT(PARAM_RANGE);
+ BIND_ENUM_CONSTANT(PARAM_ATTENUATION);
+ BIND_ENUM_CONSTANT(PARAM_SPOT_ANGLE);
+ BIND_ENUM_CONSTANT(PARAM_SPOT_ATTENUATION);
+ BIND_ENUM_CONSTANT(PARAM_CONTACT_SHADOW_SIZE);
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_MAX_DISTANCE);
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_1_OFFSET);
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_2_OFFSET);
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_SPLIT_3_OFFSET);
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_NORMAL_BIAS);
+ BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS);
- BIND_CONSTANT(PARAM_MAX);
+ BIND_ENUM_CONSTANT(PARAM_MAX);
}
Light::Light(VisualServer::LightType p_type) {
@@ -244,6 +259,8 @@ Light::Light(VisualServer::LightType p_type) {
light = VisualServer::get_singleton()->light_create(p_type);
VS::get_singleton()->instance_set_base(get_instance(), light);
+ reverse_cull = false;
+
editor_only = false;
set_color(Color(1, 1, 1, 1));
set_shadow(false);
@@ -317,18 +334,20 @@ void DirectionalLight::_bind_methods() {
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,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE);
- BIND_CONSTANT(SHADOW_ORTHOGONAL);
- BIND_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
- BIND_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
+ BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL);
+ BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
+ BIND_ENUM_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
}
DirectionalLight::DirectionalLight()
: Light(VisualServer::LIGHT_DIRECTIONAL) {
- set_param(PARAM_SHADOW_NORMAL_BIAS, 0.2);
- set_param(PARAM_SHADOW_BIAS, 1.0);
+ set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8);
+ set_param(PARAM_SHADOW_BIAS, 0.1);
set_param(PARAM_SHADOW_MAX_DISTANCE, 200);
+ set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
blend_splits = false;
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 22ff5c0763..5d589d33e5 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,8 +38,6 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-class BakedLight;
-
class Light : public VisualInstance {
GDCLASS(Light, VisualInstance);
@@ -60,6 +58,7 @@ public:
PARAM_SHADOW_SPLIT_3_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET,
PARAM_SHADOW_NORMAL_BIAS = VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS,
PARAM_SHADOW_BIAS = VS::LIGHT_PARAM_SHADOW_BIAS,
+ PARAM_SHADOW_BIAS_SPLIT_SCALE = VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE,
PARAM_MAX = VS::LIGHT_PARAM_MAX
};
@@ -69,6 +68,7 @@ private:
Color shadow_color;
bool shadow;
bool negative;
+ bool reverse_cull;
uint32_t cull_mask;
VS::LightType type;
bool editor_only;
@@ -110,6 +110,9 @@ public:
void set_shadow_color(const Color &p_shadow_color);
Color get_shadow_color() const;
+ void set_shadow_reverse_cull_face(bool p_enable);
+ bool get_shadow_reverse_cull_face() const;
+
virtual Rect3 get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
diff --git a/scene/3d/listener.cpp b/scene/3d/listener.cpp
index c7d3bac2f8..51cf9fb89b 100644
--- a/scene/3d/listener.cpp
+++ b/scene/3d/listener.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/listener.h b/scene/3d/listener.h
index b66fc7fc38..2c800443b4 100644
--- a/scene/3d/listener.h
+++ b/scene/3d/listener.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index da25afbf57..c8215971c4 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -148,7 +148,7 @@ void MeshInstance::_resolve_skeleton_path() {
if (skeleton_path.is_empty())
return;
- Skeleton *skeleton = get_node(skeleton_path) ? get_node(skeleton_path)->cast_to<Skeleton>() : NULL;
+ Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path));
if (skeleton)
VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), skeleton->get_skeleton());
}
@@ -202,13 +202,13 @@ Node *MeshInstance::create_trimesh_collision_node() {
void MeshInstance::create_trimesh_collision() {
- StaticBody *static_body = create_trimesh_collision_node()->cast_to<StaticBody>();
+ StaticBody *static_body = Object::cast_to<StaticBody>(create_trimesh_collision_node());
ERR_FAIL_COND(!static_body);
static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
if (get_owner()) {
- CollisionShape *cshape = static_body->get_child(0)->cast_to<CollisionShape>();
+ CollisionShape *cshape = Object::cast_to<CollisionShape>(static_body->get_child(0));
static_body->set_owner(get_owner());
cshape->set_owner(get_owner());
}
@@ -232,13 +232,13 @@ Node *MeshInstance::create_convex_collision_node() {
void MeshInstance::create_convex_collision() {
- StaticBody *static_body = create_convex_collision_node()->cast_to<StaticBody>();
+ StaticBody *static_body = Object::cast_to<StaticBody>(create_convex_collision_node());
ERR_FAIL_COND(!static_body);
static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
if (get_owner()) {
- CollisionShape *cshape = static_body->get_child(0)->cast_to<CollisionShape>();
+ CollisionShape *cshape = Object::cast_to<CollisionShape>(static_body->get_child(0));
static_body->set_owner(get_owner());
cshape->set_owner(get_owner());
}
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index 1bb2c97d10..8e8c12a592 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index b51953f27c..f90489f1f0 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h
index 7e14d567ac..cd0e7b463c 100644
--- a/scene/3d/multimesh_instance.h
+++ b/scene/3d/multimesh_instance.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index a1183326d7..d8c7a78648 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -584,7 +584,7 @@ Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Ve
}
if (closest_navmesh && closest_navmesh->owner) {
- //print_line("navmesh is: "+closest_navmesh->owner->cast_to<Node>()->get_name());
+ //print_line("navmesh is: "+Object::cast_to<Node>(closest_navmesh->owner)->get_name());
}
return closest_point;
diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h
index 80699fce72..010d16dedd 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp
index 4c93bcfb5e..7a55f956e0 100644
--- a/scene/3d/navigation_mesh.cpp
+++ b/scene/3d/navigation_mesh.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -208,6 +208,8 @@ void NavigationMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_polygon", "idx"), &NavigationMesh::get_polygon);
ClassDB::bind_method(D_METHOD("clear_polygons"), &NavigationMesh::clear_polygons);
+ ClassDB::bind_method(D_METHOD("create_from_mesh", "mesh"), &NavigationMesh::create_from_mesh);
+
ClassDB::bind_method(D_METHOD("_set_polygons", "polygons"), &NavigationMesh::_set_polygons);
ClassDB::bind_method(D_METHOD("_get_polygons"), &NavigationMesh::_get_polygons);
@@ -245,7 +247,7 @@ void NavigationMeshInstance::set_enabled(bool p_enabled) {
}
if (debug_view) {
- MeshInstance *dm = debug_view->cast_to<MeshInstance>();
+ MeshInstance *dm = Object::cast_to<MeshInstance>(debug_view);
if (is_enabled()) {
dm->set_material_override(get_tree()->get_debug_navigation_material());
} else {
@@ -271,7 +273,7 @@ void NavigationMeshInstance::_notification(int p_what) {
Spatial *c = this;
while (c) {
- navigation = c->cast_to<Navigation>();
+ navigation = Object::cast_to<Navigation>(c);
if (navigation) {
if (enabled && navmesh.is_valid()) {
@@ -340,7 +342,7 @@ void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh> &p_na
}
if (debug_view && navmesh.is_valid()) {
- debug_view->cast_to<MeshInstance>()->set_mesh(navmesh->get_debug_mesh());
+ Object::cast_to<MeshInstance>(debug_view)->set_mesh(navmesh->get_debug_mesh());
}
update_gizmo();
@@ -363,10 +365,10 @@ String NavigationMeshInstance::get_configuration_warning() const {
const Spatial *c = this;
while (c) {
- if (c->cast_to<Navigation>())
+ if (Object::cast_to<Navigation>(c))
return String();
- c = c->get_parent()->cast_to<Spatial>();
+ c = Object::cast_to<Spatial>(c->get_parent());
}
return TTR("NavigationMeshInstance must be a child or grandchild to a Navigation node. It only provides navigation data.");
diff --git a/scene/3d/navigation_mesh.h b/scene/3d/navigation_mesh.h
index e5a3dc7b43..36fe3ee34b 100644
--- a/scene/3d/navigation_mesh.h
+++ b/scene/3d/navigation_mesh.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 081caf4419..80c706898d 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -63,6 +63,8 @@ void Particles::set_one_shot(bool p_one_shot) {
one_shot = p_one_shot;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
+ if (!one_shot && emitting)
+ VisualServer::get_singleton()->particles_restart(particles);
}
void Particles::set_pre_process_time(float p_time) {
@@ -345,9 +347,10 @@ void Particles::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "draw_pass_" + itos(i + 1), PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_draw_pass_mesh", "get_draw_pass_mesh", i);
}
- BIND_CONSTANT(DRAW_ORDER_INDEX);
- BIND_CONSTANT(DRAW_ORDER_LIFETIME);
- BIND_CONSTANT(DRAW_ORDER_VIEW_DEPTH);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME);
+ BIND_ENUM_CONSTANT(DRAW_ORDER_VIEW_DEPTH);
+
BIND_CONSTANT(MAX_DRAW_PASSES);
}
@@ -406,7 +409,7 @@ void ParticlesMaterial::init_shaders() {
shader_names->anim_speed = "anim_speed";
shader_names->anim_offset = "anim_offset";
- shader_names->initial_linear_velocity = "initial_linear_velocity_random";
+ shader_names->initial_linear_velocity_random = "initial_linear_velocity_random";
shader_names->initial_angle_random = "initial_angle_random";
shader_names->angular_velocity_random = "angular_velocity_random";
shader_names->orbit_velocity_random = "orbit_velocity_random";
@@ -753,18 +756,20 @@ void ParticlesMaterial::_update_shader() {
code += " pos.z=0.0; \n";
}
code += " //apply linear acceleration\n";
- code += " force+=normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random);\n";
+ code += " force+= length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n";
code += " //apply radial acceleration\n";
code += " vec3 org = vec3(0.0);\n";
- code += " // if (!p_system->local_coordinates)\n";
- code += " //org=p_transform.origin;\n";
- code += " force+=normalize(pos-org) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random);\n";
+ code += " // if (!p_system->local_coordinates)\n";
+ code += " //org=p_transform.origin;\n";
+ code += " vec3 diff = pos-org;\n";
+ code += " force+=length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n";
code += " //apply tangential acceleration;\n";
if (flags[FLAG_DISABLE_Z]) {
- code += " force+=vec3(normalize((pos-org).yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random));\n";
+ code += " force+=length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n";
} else {
- code += " force+=normalize(cross(normalize(pos-org),normalize(gravity))) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random));\n";
+ code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n";
+ code += " force+=length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n";
}
code += " //apply attractor forces\n";
code += " VELOCITY+=force * DELTA;\n";
@@ -1264,9 +1269,8 @@ int ParticlesMaterial::get_emission_point_count() const {
void ParticlesMaterial::set_trail_divisor(int p_divisor) {
- VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
trail_divisor = p_divisor;
- _change_notify();
+ VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
}
int ParticlesMaterial::get_trail_divisor() const {
@@ -1484,29 +1488,29 @@ void ParticlesMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_offset_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_OFFSET);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anim_loop"), "set_flag", "get_flag", FLAG_ANIM_LOOP);
- BIND_CONSTANT(PARAM_INITIAL_LINEAR_VELOCITY);
- BIND_CONSTANT(PARAM_ANGULAR_VELOCITY);
- BIND_CONSTANT(PARAM_ORBIT_VELOCITY);
- BIND_CONSTANT(PARAM_LINEAR_ACCEL);
- BIND_CONSTANT(PARAM_RADIAL_ACCEL);
- BIND_CONSTANT(PARAM_TANGENTIAL_ACCEL);
- BIND_CONSTANT(PARAM_DAMPING);
- BIND_CONSTANT(PARAM_ANGLE);
- BIND_CONSTANT(PARAM_SCALE);
- BIND_CONSTANT(PARAM_HUE_VARIATION);
- BIND_CONSTANT(PARAM_ANIM_SPEED);
- BIND_CONSTANT(PARAM_ANIM_OFFSET);
- BIND_CONSTANT(PARAM_MAX);
-
- BIND_CONSTANT(FLAG_ALIGN_Y_TO_VELOCITY);
- BIND_CONSTANT(FLAG_ROTATE_Y);
- BIND_CONSTANT(FLAG_MAX);
-
- BIND_CONSTANT(EMISSION_SHAPE_POINT);
- BIND_CONSTANT(EMISSION_SHAPE_SPHERE);
- BIND_CONSTANT(EMISSION_SHAPE_BOX);
- BIND_CONSTANT(EMISSION_SHAPE_POINTS);
- BIND_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
+ BIND_ENUM_CONSTANT(PARAM_INITIAL_LINEAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_ORBIT_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_ACCEL);
+ BIND_ENUM_CONSTANT(PARAM_RADIAL_ACCEL);
+ BIND_ENUM_CONSTANT(PARAM_TANGENTIAL_ACCEL);
+ BIND_ENUM_CONSTANT(PARAM_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_ANGLE);
+ BIND_ENUM_CONSTANT(PARAM_SCALE);
+ BIND_ENUM_CONSTANT(PARAM_HUE_VARIATION);
+ BIND_ENUM_CONSTANT(PARAM_ANIM_SPEED);
+ BIND_ENUM_CONSTANT(PARAM_ANIM_OFFSET);
+ BIND_ENUM_CONSTANT(PARAM_MAX);
+
+ BIND_ENUM_CONSTANT(FLAG_ALIGN_Y_TO_VELOCITY);
+ BIND_ENUM_CONSTANT(FLAG_ROTATE_Y);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
+
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINT);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_SPHERE);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
}
ParticlesMaterial::ParticlesMaterial()
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 31ca85a59a..2c109d6ec8 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -88,7 +88,7 @@ public:
void set_emitting(bool p_emitting);
void set_amount(int p_amount);
void set_lifetime(float p_lifetime);
- void set_one_shot(bool p_enabled);
+ void set_one_shot(bool p_one_shot);
void set_pre_process_time(float p_time);
void set_explosiveness_ratio(float p_ratio);
void set_randomness_ratio(float p_ratio);
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index f8df21004e..ed4d88417c 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,32 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "path.h"
+
+#include "engine.h"
#include "scene/scene_string_names.h"
void Path::_notification(int p_what) {
-#if 0
- if (p_what==NOTIFICATION_DRAW && curve.is_valid() && is_inside_scene() && get_scene()->is_editor_hint()) {
- //draw the curve!!
-
- for(int i=0;i<curve->get_point_count();i++) {
-
- Vector2 prev_p=curve->get_point_pos(i);
-
- for(int j=1;j<=8;j++) {
-
- real_t frac = j/8.0;
- Vector2 p = curve->interpolate(i,frac);
- draw_line(prev_p,p,Color(0.5,0.6,1.0,0.7),2);
- prev_p=p;
- }
- }
- }
-#endif
}
void Path::_curve_changed() {
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
update_gizmo();
}
@@ -172,8 +156,7 @@ void PathFollow::_notification(int p_what) {
Node *parent = get_parent();
if (parent) {
- path = parent->cast_to<Path>();
- if (path) {
+ if ((path = Object::cast_to<Path>(parent))) {
_update_transform();
}
}
@@ -281,10 +264,10 @@ void PathFollow::_bind_methods() {
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);
- BIND_CONSTANT(ROTATION_XY);
- BIND_CONSTANT(ROTATION_XYZ);
+ BIND_ENUM_CONSTANT(ROTATION_NONE);
+ BIND_ENUM_CONSTANT(ROTATION_Y);
+ BIND_ENUM_CONSTANT(ROTATION_XY);
+ BIND_ENUM_CONSTANT(ROTATION_XYZ);
}
void PathFollow::set_offset(float p_offset) {
diff --git a/scene/3d/path.h b/scene/3d/path.h
index eeae0668a7..0f9a169f72 100644
--- a/scene/3d/path.h
+++ b/scene/3d/path.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index dc8f72d77e..a0a393e8ed 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "physics_body.h"
+
+#include "engine.h"
#include "method_bind_ext.gen.inc"
#include "scene/scene_string_names.h"
@@ -114,7 +116,7 @@ bool PhysicsBody::get_collision_layer_bit(int p_bit) const {
void PhysicsBody::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- PhysicsBody *physics_body = p_node->cast_to<PhysicsBody>();
+ PhysicsBody *physics_body = Object::cast_to<PhysicsBody>(p_node);
if (!physics_body) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
@@ -125,7 +127,7 @@ void PhysicsBody::add_collision_exception_with(Node *p_node) {
void PhysicsBody::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
- PhysicsBody *physics_body = p_node->cast_to<PhysicsBody>();
+ PhysicsBody *physics_body = Object::cast_to<PhysicsBody>(p_node);
if (!physics_body) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
@@ -252,7 +254,7 @@ StaticBody::~StaticBody() {
void RigidBody::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
@@ -276,7 +278,7 @@ void RigidBody::_body_enter_tree(ObjectID p_id) {
void RigidBody::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -301,7 +303,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
- Node *node = obj ? obj->cast_to<Node>() : NULL;
+ Node *node = Object::cast_to<Node>(obj);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid);
@@ -367,7 +369,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
//eh.. fuck
#ifdef DEBUG_ENABLED
- state = p_state->cast_to<PhysicsDirectBodyState>();
+ state = Object::cast_to<PhysicsDirectBodyState>(p_state);
#else
state = (PhysicsDirectBodyState *)p_state; //trust it
#endif
@@ -476,13 +478,13 @@ void RigidBody::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
set_notify_local_transform(true); //used for warnings and only in editor
}
}
if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
update_configuration_warning();
}
}
@@ -840,7 +842,7 @@ void RigidBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody::get_colliding_bodies);
- BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state:PhysicsDirectBodyState")));
+ BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectBodyState")));
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");
@@ -868,10 +870,10 @@ void RigidBody::_bind_methods() {
ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body")));
ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_CONSTANT(MODE_STATIC);
- BIND_CONSTANT(MODE_KINEMATIC);
- BIND_CONSTANT(MODE_RIGID);
- BIND_CONSTANT(MODE_CHARACTER);
+ BIND_ENUM_CONSTANT(MODE_STATIC);
+ BIND_ENUM_CONSTANT(MODE_KINEMATIC);
+ BIND_ENUM_CONSTANT(MODE_RIGID);
+ BIND_ENUM_CONSTANT(MODE_CHARACTER);
}
RigidBody::RigidBody()
@@ -1103,7 +1105,7 @@ Object *KinematicBody::get_collision_collider_shape(int p_collision) const {
ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
Object *collider = get_collision_collider(p_collision);
if (collider) {
- CollisionObject *obj2d = collider->cast_to<CollisionObject>();
+ CollisionObject *obj2d = Object::cast_to<CollisionObject>(collider);
if (obj2d) {
uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
return obj2d->shape_owner_get_owner(owner);
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 83811a1d93..23d752ad76 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index 61d496935b..aa127ab79f 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -55,8 +55,8 @@ void Joint::_update_joint(bool p_only_free) {
if (!node_a && !node_b)
return;
- PhysicsBody *body_a = node_a ? node_a->cast_to<PhysicsBody>() : (PhysicsBody *)NULL;
- PhysicsBody *body_b = node_b ? node_b->cast_to<PhysicsBody>() : (PhysicsBody *)NULL;
+ PhysicsBody *body_a = Object::cast_to<PhysicsBody>(node_a);
+ PhysicsBody *body_b = Object::cast_to<PhysicsBody>(node_b);
if (!body_a && !body_b)
return;
@@ -188,9 +188,9 @@ void PinJoint::_bind_methods() {
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);
- BIND_CONSTANT(PARAM_IMPULSE_CLAMP);
+ BIND_ENUM_CONSTANT(PARAM_BIAS);
+ BIND_ENUM_CONSTANT(PARAM_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_IMPULSE_CLAMP);
}
void PinJoint::set_param(Param p_param, float p_value) {
@@ -282,19 +282,19 @@ void HingeJoint::_bind_methods() {
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);
- BIND_CONSTANT(PARAM_LIMIT_UPPER);
- BIND_CONSTANT(PARAM_LIMIT_LOWER);
- BIND_CONSTANT(PARAM_LIMIT_BIAS);
- BIND_CONSTANT(PARAM_LIMIT_SOFTNESS);
- BIND_CONSTANT(PARAM_LIMIT_RELAXATION);
- BIND_CONSTANT(PARAM_MOTOR_TARGET_VELOCITY);
- BIND_CONSTANT(PARAM_MOTOR_MAX_IMPULSE);
- BIND_CONSTANT(PARAM_MAX);
+ BIND_ENUM_CONSTANT(PARAM_BIAS);
+ BIND_ENUM_CONSTANT(PARAM_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PARAM_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PARAM_LIMIT_BIAS);
+ BIND_ENUM_CONSTANT(PARAM_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_LIMIT_RELAXATION);
+ BIND_ENUM_CONSTANT(PARAM_MOTOR_TARGET_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_MOTOR_MAX_IMPULSE);
+ BIND_ENUM_CONSTANT(PARAM_MAX);
- BIND_CONSTANT(FLAG_USE_LIMIT);
- BIND_CONSTANT(FLAG_ENABLE_MOTOR);
- BIND_CONSTANT(FLAG_MAX);
+ BIND_ENUM_CONSTANT(FLAG_USE_LIMIT);
+ BIND_ENUM_CONSTANT(FLAG_ENABLE_MOTOR);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
}
void HingeJoint::set_param(Param p_param, float p_value) {
@@ -428,31 +428,31 @@ void SliderJoint::_bind_methods() {
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);
- BIND_CONSTANT(PARAM_LINEAR_LIMIT_LOWER);
- BIND_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
- BIND_CONSTANT(PARAM_LINEAR_LIMIT_RESTITUTION);
- BIND_CONSTANT(PARAM_LINEAR_LIMIT_DAMPING);
- BIND_CONSTANT(PARAM_LINEAR_MOTION_SOFTNESS);
- BIND_CONSTANT(PARAM_LINEAR_MOTION_RESTITUTION);
- BIND_CONSTANT(PARAM_LINEAR_MOTION_DAMPING);
- BIND_CONSTANT(PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
- BIND_CONSTANT(PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
- BIND_CONSTANT(PARAM_LINEAR_ORTHOGONAL_DAMPING);
-
- BIND_CONSTANT(PARAM_ANGULAR_LIMIT_UPPER);
- BIND_CONSTANT(PARAM_ANGULAR_LIMIT_LOWER);
- BIND_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
- BIND_CONSTANT(PARAM_ANGULAR_LIMIT_RESTITUTION);
- BIND_CONSTANT(PARAM_ANGULAR_LIMIT_DAMPING);
- BIND_CONSTANT(PARAM_ANGULAR_MOTION_SOFTNESS);
- BIND_CONSTANT(PARAM_ANGULAR_MOTION_RESTITUTION);
- BIND_CONSTANT(PARAM_ANGULAR_MOTION_DAMPING);
- BIND_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
- BIND_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
- BIND_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_DAMPING);
-
- BIND_CONSTANT(PARAM_MAX);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTION_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTION_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTION_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_ORTHOGONAL_DAMPING);
+
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_UPPER);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_LOWER);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTION_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTION_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTION_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_DAMPING);
+
+ BIND_ENUM_CONSTANT(PARAM_MAX);
}
void SliderJoint::set_param(Param p_param, float p_value) {
@@ -560,12 +560,12 @@ void ConeTwistJoint::_bind_methods() {
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);
- BIND_CONSTANT(PARAM_BIAS);
- BIND_CONSTANT(PARAM_SOFTNESS);
- BIND_CONSTANT(PARAM_RELAXATION);
- BIND_CONSTANT(PARAM_MAX);
+ BIND_ENUM_CONSTANT(PARAM_SWING_SPAN);
+ BIND_ENUM_CONSTANT(PARAM_TWIST_SPAN);
+ BIND_ENUM_CONSTANT(PARAM_BIAS);
+ BIND_ENUM_CONSTANT(PARAM_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_RELAXATION);
+ BIND_ENUM_CONSTANT(PARAM_MAX);
}
void ConeTwistJoint::set_param(Param p_param, float p_value) {
@@ -773,26 +773,26 @@ void Generic6DOFJoint::_bind_methods() {
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);
- BIND_CONSTANT(PARAM_LINEAR_UPPER_LIMIT);
- BIND_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
- BIND_CONSTANT(PARAM_LINEAR_RESTITUTION);
- BIND_CONSTANT(PARAM_LINEAR_DAMPING);
- BIND_CONSTANT(PARAM_ANGULAR_LOWER_LIMIT);
- BIND_CONSTANT(PARAM_ANGULAR_UPPER_LIMIT);
- BIND_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
- BIND_CONSTANT(PARAM_ANGULAR_DAMPING);
- BIND_CONSTANT(PARAM_ANGULAR_RESTITUTION);
- BIND_CONSTANT(PARAM_ANGULAR_FORCE_LIMIT);
- BIND_CONSTANT(PARAM_ANGULAR_ERP);
- BIND_CONSTANT(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- BIND_CONSTANT(PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
- BIND_CONSTANT(PARAM_MAX);
-
- BIND_CONSTANT(FLAG_ENABLE_LINEAR_LIMIT);
- BIND_CONSTANT(FLAG_ENABLE_ANGULAR_LIMIT);
- BIND_CONSTANT(FLAG_ENABLE_MOTOR);
- BIND_CONSTANT(FLAG_MAX);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LOWER_LIMIT);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_UPPER_LIMIT);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_LINEAR_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LOWER_LIMIT);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_UPPER_LIMIT);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_DAMPING);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_RESTITUTION);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_FORCE_LIMIT);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_ERP);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+ BIND_ENUM_CONSTANT(PARAM_MAX);
+
+ BIND_ENUM_CONSTANT(FLAG_ENABLE_LINEAR_LIMIT);
+ BIND_ENUM_CONSTANT(FLAG_ENABLE_ANGULAR_LIMIT);
+ BIND_ENUM_CONSTANT(FLAG_ENABLE_MOTOR);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
}
void Generic6DOFJoint::set_param_x(Param p_param, float p_value) {
@@ -973,301 +973,3 @@ Generic6DOFJoint::Generic6DOFJoint() {
set_flag_z(FLAG_ENABLE_LINEAR_LIMIT, true);
set_flag_z(FLAG_ENABLE_MOTOR, false);
}
-
-#if 0
-
-void PhysicsJoint::_set(const String& p_name, const Variant& p_value) {
-
- if (p_name=="body_A")
- set_body_a(p_value);
- else if (p_name=="body_B")
- set_body_b(p_value);
- else if (p_name=="active")
- set_active(p_value);
- else if (p_name=="no_collision")
- set_disable_collision(p_value);
-}
-Variant PhysicsJoint::_get(const String& p_name) const {
-
- if (p_name=="body_A")
- return get_body_a();
- else if (p_name=="body_B")
- return get_body_b();
- else if (p_name=="active")
- return is_active();
- else if (p_name=="no_collision")
- return has_disable_collision();
-
- return Variant();
-}
-void PhysicsJoint::_get_property_list( List<PropertyInfo> *p_list) const {
-
-
- p_list->push_back( PropertyInfo( Variant::NODE_PATH, "body_A" ) );
- p_list->push_back( PropertyInfo( Variant::NODE_PATH, "body_B" ) );
- p_list->push_back( PropertyInfo( Variant::BOOL, "active" ) );
- p_list->push_back( PropertyInfo( Variant::BOOL, "no_collision" ) );
-}
-void PhysicsJoint::_notification(int p_what) {
-
-
- switch(p_what) {
-
- case NOTIFICATION_PARENT_CONFIGURED: {
-
- _connect();
- if (get_root_node()->get_editor() && !indicator.is_valid()) {
-
- indicator=VisualServer::get_singleton()->poly_create();
- RID mat=VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_UNSHADED, true );
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_ONTOP, true );
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_WIREFRAME, true );
- VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED, true );
- VisualServer::get_singleton()->material_set_line_width( mat, 3 );
-
- VisualServer::get_singleton()->poly_set_material(indicator,mat,true);
- _update_indicator();
-
- }
-
- if (indicator.is_valid()) {
-
- indicator_instance=VisualServer::get_singleton()->instance_create(indicator,get_world()->get_scenario());
- VisualServer::get_singleton()->instance_attach_object_instance_id( indicator_instance,get_instance_id() );
- }
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
-
- if (indicator_instance.is_valid()) {
-
- VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
- }
- } break;
- case NOTIFICATION_EXIT_SCENE: {
-
- if (indicator_instance.is_valid()) {
-
- VisualServer::get_singleton()->free(indicator_instance);
- }
- _disconnect();
-
- } break;
-
- }
-}
-
-
-RID PhysicsJoint::_get_visual_instance_rid() const {
-
- return indicator_instance;
-
-}
-
-void PhysicsJoint::_bind_methods() {
-
- 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(D_METHOD("set_active","active"),&PhysicsJoint::set_active);
- ClassDB::bind_method(D_METHOD("is_active"),&PhysicsJoint::is_active);
-
- 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(D_METHOD("get_rid"),&PhysicsJoint::get_rid);
-
-}
-
-void PhysicsJoint::set_body_a(const NodePath& p_path) {
-
- _disconnect();
- body_A=p_path;
- _connect();
- _change_notify("body_A");
-}
-void PhysicsJoint::set_body_b(const NodePath& p_path) {
-
- _disconnect();
- body_B=p_path;
- _connect();
- _change_notify("body_B");
-
-}
-NodePath PhysicsJoint::get_body_a() const {
-
- return body_A;
-}
-NodePath PhysicsJoint::get_body_b() const {
-
- return body_B;
-}
-
-void PhysicsJoint::set_active(bool p_active) {
-
- active=p_active;
- if (is_inside_scene()) {
- PhysicsServer::get_singleton()->joint_set_active(joint,active);
- }
- _change_notify("active");
-}
-
-void PhysicsJoint::set_disable_collision(bool p_active) {
-
- if (no_collision==p_active)
- return;
- _disconnect();
- no_collision=p_active;
- _connect();
-
- _change_notify("no_collision");
-}
-bool PhysicsJoint::has_disable_collision() const {
-
- return no_collision;
-}
-
-
-
-bool PhysicsJoint::is_active() const {
-
- return active;
-}
-
-void PhysicsJoint::_disconnect() {
-
- if (!is_inside_scene())
- return;
-
- if (joint.is_valid())
- PhysicsServer::get_singleton()->free(joint);
-
- joint=RID();
-
- Node *nA = get_node(body_A);
- Node *nB = get_node(body_B);
-
- PhysicsBody *A = nA?nA->cast_to<PhysicsBody>():NULL;
- PhysicsBody *B = nA?nB->cast_to<PhysicsBody>():NULL;
-
- if (!A ||!B)
- return;
-
- if (no_collision)
- PhysicsServer::get_singleton()->body_remove_collision_exception(A->get_body(),B->get_body());
-
-}
-void PhysicsJoint::_connect() {
-
- if (!is_inside_scene())
- return;
-
- ERR_FAIL_COND(joint.is_valid());
-
- Node *nA = get_node(body_A);
- Node *nB = get_node(body_B);
-
- PhysicsBody *A = nA?nA->cast_to<PhysicsBody>():NULL;
- PhysicsBody *B = nA?nB->cast_to<PhysicsBody>():NULL;
-
- if (!A && !B)
- return;
-
- if (B && !A)
- SWAP(B,A);
-
- joint = create(A,B);
-
- if (A<B)
- SWAP(A,B);
-
- if (no_collision)
- PhysicsServer::get_singleton()->body_add_collision_exception(A->get_body(),B->get_body());
-
-
-
-}
-
-void PhysicsJoint::reconnect() {
-
- _disconnect();
- _connect();
-
-}
-
-
-RID PhysicsJoint::get_rid() {
-
- return joint;
-}
-
-
-PhysicsJoint::PhysicsJoint() {
-
- active=true;
- no_collision=true;
-}
-
-
-PhysicsJoint::~PhysicsJoint() {
-
- if (indicator.is_valid()) {
-
- VisualServer::get_singleton()->free(indicator);
- }
-
-}
-
-/* PIN */
-
-void PhysicsJointPin::_update_indicator() {
-
-
- VisualServer::get_singleton()->poly_clear(indicator);
-
- Vector<Color> colors;
- colors.push_back( Color(0.3,0.9,0.2,0.7) );
- colors.push_back( Color(0.3,0.9,0.2,0.7) );
-
- Vector<Vector3> points;
- points.resize(2);
- points[0]=Vector3(Vector3(-0.2,0,0));
- points[1]=Vector3(Vector3(0.2,0,0));
- VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>());
-
- points[0]=Vector3(Vector3(0,-0.2,0));
- points[1]=Vector3(Vector3(0,0.2,0));
- VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>());
-
- points[0]=Vector3(Vector3(0,0,-0.2));
- points[1]=Vector3(Vector3(0,0,0.2));
- VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>());
-
-}
-
-RID PhysicsJointPin::create(PhysicsBody*A,PhysicsBody*B) {
-
- RID body_A = A->get_body();
- RID body_B = B?B->get_body():RID();
-
- ERR_FAIL_COND_V( !body_A.is_valid(), RID() );
-
- Vector3 pin_pos = get_global_transform().origin;
-
- if (body_B.is_valid())
- return PhysicsServer::get_singleton()->joint_create_double_pin_global(body_A,pin_pos,body_B,pin_pos);
- else
- return PhysicsServer::get_singleton()->joint_create_pin(body_A,A->get_global_transform().xform_inv(pin_pos),pin_pos);
-}
-
-PhysicsJointPin::PhysicsJointPin() {
-
-
-}
-#endif
diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h
index b834aaf6d2..b94297da30 100644
--- a/scene/3d/physics_joint.h
+++ b/scene/3d/physics_joint.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -321,73 +321,4 @@ public:
VARIANT_ENUM_CAST(Generic6DOFJoint::Param);
VARIANT_ENUM_CAST(Generic6DOFJoint::Flag);
-#if 0
-class PhysicsJoint : public Spatial {
-
- GDCLASS(PhysicsJoint,Spatial);
- OBJ_CATEGORY("3D Physics Nodes");
-
- NodePath body_A;
- NodePath body_B;
- bool active;
- bool no_collision;
-
-
- RID indicator_instance;
-
- RID _get_visual_instance_rid() const;
-protected:
-
- RID joint;
- RID indicator;
-
- 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();
-
- virtual RID create(PhysicsBody*A,PhysicsBody*B)=0;
- virtual void _update_indicator()=0;
-
- void _disconnect();
- void _connect();
-public:
-
- void set_body_a(const NodePath& p_path);
- void set_body_b(const NodePath& p_path);
- NodePath get_body_a() const;
- NodePath get_body_b() const;
-
- void set_active(bool p_active);
- bool is_active() const;
-
- void set_disable_collision(bool p_active);
- bool has_disable_collision() const;
-
- void reconnect();
-
- RID get_rid();
-
- PhysicsJoint();
- ~PhysicsJoint();
-};
-
-
-
-class PhysicsJointPin : public PhysicsJoint {
-
- GDCLASS( PhysicsJointPin, PhysicsJoint );
-
-protected:
-
- virtual void _update_indicator();
- virtual RID create(PhysicsBody*A,PhysicsBody*B);
-public:
-
-
- PhysicsJointPin();
-};
-
#endif // PHYSICS_JOINT_H
-#endif
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index d77dde1dd8..6c14f7dbc9 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,6 +32,8 @@
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
+// FIXME: This will be removed, kept as reference for new implementation
+#if 0
bool Portal::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "shape") {
@@ -226,3 +228,4 @@ Portal::~Portal() {
VisualServer::get_singleton()->free(portal);
}
+#endif
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 7c25e4904b..6de3df8553 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -39,7 +39,8 @@
If a portal is placed next (very close to) a similar, opposing portal, they automatically connect,
otherwise, a portal connects to the parent room
*/
-
+//this will be redone and replaced by area portals, left for reference since a new class with this name will have to exist and want to reuse the gizmos
+#if 0
class Portal : public VisualInstance {
GDCLASS(Portal, VisualInstance);
@@ -85,3 +86,4 @@ public:
};
#endif
+#endif
diff --git a/scene/3d/position_3d.cpp b/scene/3d/position_3d.cpp
index 4e66ef13c0..d0df985ac4 100644
--- a/scene/3d/position_3d.cpp
+++ b/scene/3d/position_3d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h
index 0adde19342..8083c33196 100644
--- a/scene/3d/position_3d.h
+++ b/scene/3d/position_3d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp
index 5441904d81..2288d8b08b 100644
--- a/scene/3d/proximity_group.cpp
+++ b/scene/3d/proximity_group.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -116,9 +116,9 @@ void ProximityGroup::set_group_name(String p_group_name) {
group_name = p_group_name;
};
-void ProximityGroup::_notification(int what) {
+void ProximityGroup::_notification(int p_what) {
- switch (what) {
+ switch (p_what) {
case NOTIFICATION_EXIT_TREE:
++group_version;
diff --git a/scene/3d/proximity_group.h b/scene/3d/proximity_group.h
index fec3add41f..d003d2f525 100644
--- a/scene/3d/proximity_group.h
+++ b/scene/3d/proximity_group.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 67e7fb0e12..72b7706b77 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,12 +30,14 @@
#include "ray_cast.h"
#include "collision_object.h"
+#include "engine.h"
#include "mesh_instance.h"
#include "servers/physics_server.h"
+
void RayCast::set_cast_to(const Vector3 &p_point) {
cast_to = p_point;
- if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
update_gizmo();
if (is_inside_tree() && get_tree()->is_debugging_collisions_hint())
_update_debug_shape();
@@ -94,7 +96,7 @@ Vector3 RayCast::get_collision_normal() const {
void RayCast::set_enabled(bool p_enabled) {
enabled = p_enabled;
- if (is_inside_tree() && !get_tree()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
set_fixed_process(p_enabled);
if (!p_enabled)
collided = false;
@@ -118,7 +120,7 @@ void RayCast::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- if (enabled && !get_tree()->is_editor_hint()) {
+ if (enabled && !Engine::get_singleton()->is_editor_hint()) {
set_fixed_process(true);
if (get_tree()->is_debugging_collisions_hint())
@@ -194,7 +196,7 @@ void RayCast::add_exception_rid(const RID &p_rid) {
void RayCast::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject *co = ((Object *)p_object)->cast_to<CollisionObject>();
+ const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co)
return;
add_exception_rid(co->get_rid());
@@ -208,7 +210,7 @@ void RayCast::remove_exception_rid(const RID &p_rid) {
void RayCast::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject *co = ((Object *)p_object)->cast_to<CollisionObject>();
+ const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co)
return;
remove_exception_rid(co->get_rid());
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index e9b34c4f75..fd566cd343 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 0dc5b58e45..46b105cd21 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -252,8 +252,8 @@ void ReflectionProbe::_bind_methods() {
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);
- BIND_CONSTANT(UPDATE_ALWAYS);
+ BIND_ENUM_CONSTANT(UPDATE_ONCE);
+ BIND_ENUM_CONSTANT(UPDATE_ALWAYS);
}
ReflectionProbe::ReflectionProbe() {
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index d2a5facb5f..7c328a8f16 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
index 492930ea9b..3d402fa5af 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform.cpp
@@ -4,7 +4,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -51,11 +51,7 @@ void RemoteTransform::_update_remote() {
if (!cache)
return;
- Object *obj = ObjectDB::get_instance(cache);
- if (!obj)
- return;
-
- Spatial *n = obj->cast_to<Spatial>();
+ Spatial *n = Object::cast_to<Spatial>(ObjectDB::get_instance(cache));
if (!n)
return;
@@ -177,7 +173,7 @@ bool RemoteTransform::get_update_scale() const {
String RemoteTransform::get_configuration_warning() const {
- if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Spatial>()) {
+ if (!has_node(remote_node) || !Object::cast_to<Spatial>(get_node(remote_node))) {
return TTR("Path property must point to a valid Spatial node to work.");
}
diff --git a/scene/3d/remote_transform.h b/scene/3d/remote_transform.h
index c25b57966e..51a0bf35a3 100644
--- a/scene/3d/remote_transform.h
+++ b/scene/3d/remote_transform.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index c5ea6c54da..439b6bfdf8 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -31,6 +31,8 @@
#include "servers/visual_server.h"
+// FIXME: Will be removed, kept as reference for new implementation
+#if 0
#include "geometry.h"
#include "project_settings.h"
#include "scene/resources/surface_tool.h"
@@ -45,7 +47,7 @@ void Room::_notification(int p_what) {
while (parent_room) {
- Room *r = parent_room->cast_to<Room>();
+ Room *r = Object::cast_to<Room>(parent_room);
if (r) {
level = r->level + 1;
@@ -103,7 +105,7 @@ Ref<RoomBounds> Room::get_room() const {
void Room::_parse_node_faces(PoolVector<Face3> &all_faces, const Node *p_node) const {
- const VisualInstance *vi = p_node->cast_to<VisualInstance>();
+ const VisualInstance *vi = Object::cast_to<VisualInstance>(p_node);
if (vi) {
PoolVector<Face3> faces = vi->get_faces(FACES_ENCLOSING);
@@ -158,3 +160,4 @@ Room::Room() {
Room::~Room() {
}
+#endif
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index 4176da92e8..b9a64b6670 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -44,6 +44,9 @@
*/
+//this will be removed, left for reference
+#if 0
+
class Room : public VisualInstance {
GDCLASS(Room, VisualInstance);
@@ -77,5 +80,5 @@ public:
Room();
~Room();
};
-
+#endif
#endif // ROOM_INSTANCE_H
diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp
index 0780ce22ff..8102b3f15c 100644
--- a/scene/3d/scenario_fx.cpp
+++ b/scene/3d/scenario_fx.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/scenario_fx.h b/scene/3d/scenario_fx.h
index d1e0a63130..acf6a18526 100644
--- a/scene/3d/scenario_fx.h
+++ b/scene/3d/scenario_fx.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 0d91014314..d0e0937eca 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -82,9 +82,9 @@ bool Skeleton::_set(const StringName &p_path, const Variant &p_value) {
return true;
}
-bool Skeleton::_get(const StringName &p_name, Variant &r_ret) const {
+bool Skeleton::_get(const StringName &p_path, Variant &r_ret) const {
- String path = p_name;
+ String path = p_path;
if (!path.begins_with("bones/"))
return false;
@@ -111,7 +111,7 @@ bool Skeleton::_get(const StringName &p_name, Variant &r_ret) const {
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- Node *node = obj->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(obj);
ERR_CONTINUE(!node);
NodePath path = get_path_to(node);
children.push_back(path);
@@ -245,7 +245,7 @@ void Skeleton::_notification(int p_what) {
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- Spatial *sp = obj->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(obj);
ERR_CONTINUE(!sp);
sp->set_transform(b.pose_global);
}
@@ -433,7 +433,7 @@ void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound)
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- p_bound->push_back(obj->cast_to<Node>());
+ p_bound->push_back(Object::cast_to<Node>(obj));
}
}
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index dc0adbb337..fdc1100472 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -91,8 +91,8 @@ class Skeleton : public Spatial {
}
protected:
- bool _get(const StringName &p_name, Variant &r_ret) const;
- bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_path, Variant &r_ret) const;
+ bool _set(const StringName &p_path, const Variant &p_value);
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
@@ -113,7 +113,7 @@ public:
void set_bone_parent(int p_bone, int p_parent);
int get_bone_parent(int p_bone) const;
- void unparent_bone_and_rest(int p_idx);
+ void unparent_bone_and_rest(int p_bone);
void set_bone_disable_rest(int p_bone, bool p_disable);
bool is_bone_rest_disabled(int p_bone) const;
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 848b08eb8f..7db3bb18bd 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "spatial.h"
+#include "engine.h"
#include "message_queue.h"
#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
@@ -127,14 +128,14 @@ void Spatial::_notification(int p_what) {
Node *p = get_parent();
if (p)
- data.parent = p->cast_to<Spatial>();
+ data.parent = Object::cast_to<Spatial>(p);
if (data.parent)
data.C = data.parent->data.children.push_back(this);
else
data.C = NULL;
- if (data.toplevel && !get_tree()->is_editor_hint()) {
+ if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) {
if (data.parent) {
data.local_transform = data.parent->get_global_transform() * get_transform();
@@ -166,7 +167,7 @@ void Spatial::_notification(int p_what) {
data.viewport = NULL;
Node *parent = get_parent();
while (parent && !data.viewport) {
- data.viewport = parent->cast_to<Viewport>();
+ data.viewport = Object::cast_to<Viewport>(parent);
parent = parent->get_parent();
}
@@ -178,14 +179,19 @@ void Spatial::_notification(int p_what) {
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, NULL, 0);
}
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->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_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
if (!data.gizmo_disabled) {
- if (data.gizmo.is_valid())
+ if (data.gizmo.is_valid()) {
data.gizmo->create();
+ if (data.gizmo->can_draw()) {
+ data.gizmo->redraw();
+ }
+ data.gizmo->transform();
+ }
}
}
#endif
@@ -280,37 +286,6 @@ Transform Spatial::get_global_transform() const {
return data.global_transform;
}
-#if 0
-void Spatial::add_child_notify(Node *p_child) {
-/*
- Spatial *s=p_child->cast_to<Spatial>();
- if (!s)
- return;
-
- ERR_FAIL_COND(data.children_lock>0);
-
- s->data.dirty=DIRTY_GLOBAL; // don't allow global transform to be valid
- s->data.parent=this;
- data.children.push_back(s);
- s->data.C=data.children.back();
-*/
-}
-
-void Spatial::remove_child_notify(Node *p_child) {
-/*
- Spatial *s=p_child->cast_to<Spatial>();
- if (!s)
- return;
-
- ERR_FAIL_COND(data.children_lock>0);
-
- if (s->data.C)
- data.children.erase(s->data.C);
- s->data.parent=NULL;
- s->data.C=NULL;
-*/
-}
-#endif
Spatial *Spatial::get_parent_spatial() const {
@@ -448,7 +423,9 @@ void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->create();
- data.gizmo->redraw();
+ if (data.gizmo->can_draw()) {
+ data.gizmo->redraw();
+ }
data.gizmo->transform();
}
@@ -470,12 +447,16 @@ Ref<SpatialGizmo> Spatial::get_gizmo() const {
void Spatial::_update_gizmo() {
+ if (!is_inside_world())
+ return;
data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
- if (is_visible_in_tree())
- data.gizmo->redraw();
- else
- data.gizmo->clear();
+ if (data.gizmo->can_draw()) {
+ if (is_visible_in_tree())
+ data.gizmo->redraw();
+ else
+ data.gizmo->clear();
+ }
}
}
@@ -492,7 +473,7 @@ void Spatial::set_as_toplevel(bool p_enabled) {
if (data.toplevel == p_enabled)
return;
- if (is_inside_tree() && !get_tree()->is_editor_hint()) {
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
if (p_enabled)
set_transform(get_global_transform());
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index f22b19d3cc..3f205ea86b 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -47,6 +47,7 @@ public:
virtual void clear() = 0;
virtual void redraw() = 0;
virtual void free() = 0;
+ virtual bool can_draw() const = 0;
SpatialGizmo();
};
diff --git a/scene/3d/spatial_indexer.cpp b/scene/3d/spatial_indexer.cpp
deleted file mode 100644
index 7090c974a3..0000000000
--- a/scene/3d/spatial_indexer.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*************************************************************************/
-/* spatial_indexer.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "spatial_indexer.h"
-
-#if 0
-
-#include "camera.h"
-#include "proximity_area.h"
-#include "scene/scene_string_names.h"
-
-void SpatialIndexer::add_camera(Camera* p_camera) {
-
- cameras.insert(p_camera);
-}
-
-void SpatialIndexer::remove_camera(Camera* p_camera){
-
- for (Set<ProximityArea*>::Element *F=proximity_areas.front();F;F=F->next()) {
-
- ProximityArea *prox = F->get();
- TK<Camera> k;
- k.against=p_camera;
- k.area=prox;
- if (camera_pairs.has(k)) {
- camera_pairs.erase(k);
- prox->area_exit(ProximityArea::TRACK_CAMERAS,p_camera);
- }
- }
- cameras.erase(p_camera);
-
-}
-
-void SpatialIndexer::update_camera(Camera* p_camera) {
-
-
- _request_update();
-}
-
-void SpatialIndexer::_update_pairs() {
-
- // brute force interseciton code, no broadphase
- // will implement broadphase in the future
-
- for (Set<Camera*>::Element *E=cameras.front();E;E=E->next()) {
-
- Camera *cam = E->get();
- Vector<Plane> cplanes = cam->get_frustum();
-
- for (Set<ProximityArea*>::Element *F=proximity_areas.front();F;F=F->next()) {
-
- ProximityArea *prox = F->get();
-
- bool inters=false;
-
- if (prox->get_track_flag(ProximityArea::TRACK_CAMERAS)) {
-
- AABB aabb = prox->get_global_transform().xform(prox->get_aabb());
- if (aabb.intersects_convex_shape(cplanes.ptr(),cplanes.size()))
- inters=true;
- }
-
- TK<Camera> k;
- k.against=cam;
- k.area=prox;
-
- bool has = camera_pairs.has(k);
-
- if (inters==has)
- continue;
-
- if (inters) {
- camera_pairs.insert(k);
- prox->area_enter(ProximityArea::TRACK_CAMERAS,cam);
- } else {
-
- camera_pairs.erase(k);
- prox->area_exit(ProximityArea::TRACK_CAMERAS,cam);
- }
- }
-
- }
-
- pending_update=false;
-}
-
-void SpatialIndexer::_bind_methods() {
-
-
- ClassDB::bind_method(D_METHOD("_update_pairs"),&SpatialIndexer::_update_pairs);
-}
-
-
-void SpatialIndexer::add_proximity_area(ProximityArea* p_area) {
-
- proximity_areas.insert(p_area);
-
-}
-
-void SpatialIndexer::remove_proximity_area(ProximityArea* p_area) {
-
- for (Set<Camera*>::Element *E=cameras.front();E;E=E->next()) {
-
- Camera *cam = E->get();
- TK<Camera> k;
- k.against=cam;
- k.area=p_area;
- if (camera_pairs.has(k)) {
- camera_pairs.erase(k);
- p_area->area_exit(ProximityArea::TRACK_CAMERAS,cam);
- }
- }
- proximity_areas.erase(p_area);
-
-}
-
-void SpatialIndexer::_request_update() {
-
- if (pending_update)
- return;
- pending_update=true;
- call_deferred(SceneStringNames::get_singleton()->_update_pairs);
-
-}
-
-void SpatialIndexer::update_proximity_area_transform(ProximityArea* p_area) {
-
- _request_update();
-}
-
-void SpatialIndexer::update_proximity_area_flags(ProximityArea* p_area) {
-
- _request_update();
-}
-
-SpatialIndexer::SpatialIndexer() {
-
- pending_update=false;
-}
-#endif
diff --git a/scene/3d/spatial_indexer.h b/scene/3d/spatial_indexer.h
deleted file mode 100644
index c8bdf8950d..0000000000
--- a/scene/3d/spatial_indexer.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*************************************************************************/
-/* spatial_indexer.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SPATIAL_INDEXER_H
-#define SPATIAL_INDEXER_H
-
-#include "scene/3d/spatial.h"
-#if 0
-
-class Camera;
-class ProximityArea;
-
-class SpatialIndexer : public Object {
-
- GDCLASS( SpatialIndexer, Object );
-
- template<class T>
- struct TK {
-
- T *against;
- ProximityArea *area;
- bool operator<(const TK<T>& p_k) const { return against==p_k.against ? area < p_k.area : against < p_k.against; }
- };
-
-
- Set<Camera*> cameras; //cameras
- Set<ProximityArea*> proximity_areas;
-
- Set<TK<Camera> > camera_pairs;
-
- bool pending_update;
- void _update_pairs();
- void _request_update();
-
-protected:
-
- static void _bind_methods();
-
-friend class ProximityArea;
-friend class Camera;
-
- void add_proximity_area(ProximityArea* p_area);
- void remove_proximity_area(ProximityArea* p_area);
- void update_proximity_area_transform(ProximityArea* p_area);
- void update_proximity_area_flags(ProximityArea* p_area);
-
- void add_camera(Camera* p_camera);
- void remove_camera(Camera* p_camera);
- void update_camera(Camera* p_camera);
-
-public:
-
-
- SpatialIndexer();
-
-};
-#endif
-#endif // SPATIAL_INDEXER_H
diff --git a/scene/3d/spatial_velocity_tracker.h b/scene/3d/spatial_velocity_tracker.h
index 65f3eaca93..b8237613a7 100644
--- a/scene/3d/spatial_velocity_tracker.h
+++ b/scene/3d/spatial_velocity_tracker.h
@@ -20,7 +20,7 @@ protected:
public:
void reset(const Vector3 &p_new_pos);
- void set_track_fixed_step(bool p_use_fixed_step);
+ void set_track_fixed_step(bool p_track_fixed_step);
bool is_tracking_fixed_step() const;
void update_position(const Vector3 &p_position);
Vector3 get_tracked_linear_velocity() const;
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 978662f7dc..49a3205f21 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -70,13 +70,9 @@ void SpriteBase3D::_notification(int p_what) {
if (!pending_update)
_im_update();
- Node *parent = get_parent();
- if (parent) {
-
- parent_sprite = parent->cast_to<SpriteBase3D>();
- if (parent_sprite) {
- pI = parent_sprite->children.push_back(this);
- }
+ parent_sprite = Object::cast_to<SpriteBase3D>(get_parent());
+ if (parent_sprite) {
+ pI = parent_sprite->children.push_back(this);
}
}
@@ -276,14 +272,14 @@ void SpriteBase3D::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "double_sided"), "set_draw_flag", "get_draw_flag", FLAG_DOUBLE_SIDED);
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);
- BIND_CONSTANT(FLAG_SHADED);
- BIND_CONSTANT(FLAG_DOUBLE_SIDED);
- BIND_CONSTANT(FLAG_MAX);
+ BIND_ENUM_CONSTANT(FLAG_TRANSPARENT);
+ BIND_ENUM_CONSTANT(FLAG_SHADED);
+ BIND_ENUM_CONSTANT(FLAG_DOUBLE_SIDED);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
- BIND_CONSTANT(ALPHA_CUT_DISABLED);
- BIND_CONSTANT(ALPHA_CUT_DISCARD);
- BIND_CONSTANT(ALPHA_CUT_OPAQUE_PREPASS);
+ BIND_ENUM_CONSTANT(ALPHA_CUT_DISABLED);
+ BIND_ENUM_CONSTANT(ALPHA_CUT_DISCARD);
+ BIND_ENUM_CONSTANT(ALPHA_CUT_OPAQUE_PREPASS);
}
SpriteBase3D::SpriteBase3D() {
@@ -602,219 +598,6 @@ Sprite3D::Sprite3D() {
////////////////////////////////////////
-#if 0
-
-void AnimatedSprite3D::_draw() {
-
- RID immediate = get_immediate();
- VS::get_singleton()->immediate_clear(immediate);
-
- if (!frames.is_valid() || !frames->get_frame_count(animation) || frame<0 || frame>=frames->get_frame_count(animation)) {
- return;
- }
-
- Ref<Texture> texture = frames->get_frame(animation,frame);
- if (!texture.is_valid())
- return; //no texuture no life
- Vector2 tsize = texture->get_size();
- if (tsize.x==0 || tsize.y==0)
- return;
-
- Size2i s=tsize;
- Rect2i src_rect;
-
- src_rect.size=s;
-
- Point2i ofs=get_offset();
- if (is_centered())
- ofs-=s/2;
-
- Rect2i dst_rect(ofs,s);
-
-
- Rect2 final_rect;
- Rect2 final_src_rect;
- if (!texture->get_rect_region(dst_rect,src_rect,final_rect,final_src_rect))
- return;
-
-
- if (final_rect.size.x==0 || final_rect.size.y==0)
- return;
-
- Color color=_get_color_accum();
- color.a*=get_opacity();
-
- float pixel_size=get_pixel_size();
-
- Vector2 vertices[4]={
-
- (final_rect.pos+Vector2(0,final_rect.size.y)) * pixel_size,
- (final_rect.pos+final_rect.size) * pixel_size,
- (final_rect.pos+Vector2(final_rect.size.x,0)) * pixel_size,
- final_rect.pos * pixel_size,
-
-
- };
- Vector2 uvs[4]={
- final_src_rect.pos / tsize,
- (final_src_rect.pos+Vector2(final_src_rect.size.x,0)) / tsize,
- (final_src_rect.pos+final_src_rect.size) / tsize,
- (final_src_rect.pos+Vector2(0,final_src_rect.size.y)) / tsize,
- };
-
- if (is_flipped_h()) {
- SWAP(uvs[0],uvs[1]);
- SWAP(uvs[2],uvs[3]);
- }
- if (is_flipped_v()) {
-
- SWAP(uvs[0],uvs[3]);
- SWAP(uvs[1],uvs[2]);
- }
-
-
- Vector3 normal;
- int axis = get_axis();
- normal[axis]=1.0;
-
- RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED),get_draw_flag(FLAG_TRANSPARENT),get_alpha_cut_mode()==ALPHA_CUT_DISCARD,get_alpha_cut_mode()==ALPHA_CUT_OPAQUE_PREPASS);
- VS::get_singleton()->immediate_set_material(immediate,mat);
-
- VS::get_singleton()->immediate_begin(immediate,VS::PRIMITIVE_TRIANGLE_FAN,texture->get_rid());
-
- int x_axis = ((axis + 1) % 3);
- int y_axis = ((axis + 2) % 3);
-
- if (axis!=Vector3::AXIS_Z) {
- SWAP(x_axis,y_axis);
-
- for(int i=0;i<4;i++) {
- //uvs[i] = Vector2(1.0,1.0)-uvs[i];
- //SWAP(vertices[i].x,vertices[i].y);
- if (axis==Vector3::AXIS_Y) {
- vertices[i].y = - vertices[i].y;
- } else if (axis==Vector3::AXIS_X) {
- vertices[i].x = - vertices[i].x;
- }
- }
- }
-
- AABB aabb;
-
- for(int i=0;i<4;i++) {
- VS::get_singleton()->immediate_normal(immediate,normal);
- VS::get_singleton()->immediate_color(immediate,color);
- VS::get_singleton()->immediate_uv(immediate,uvs[i]);
-
- Vector3 vtx;
- vtx[x_axis]=vertices[i][0];
- vtx[y_axis]=vertices[i][1];
- VS::get_singleton()->immediate_vertex(immediate,vtx);
- if (i==0) {
- aabb.pos=vtx;
- aabb.size=Vector3();
- } else {
- aabb.expand_to(vtx);
- }
- }
- set_aabb(aabb);
- VS::get_singleton()->immediate_end(immediate);
-
-}
-
-void AnimatedSprite3D::_bind_methods(){
-
- ClassDB::bind_method(D_METHOD("set_sprite_frames","sprite_frames"),&AnimatedSprite3D::set_sprite_frames);
- ClassDB::bind_method(D_METHOD("get_sprite_frames"),&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"), "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"));
-
-}
-
-
-
-
-void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames>& p_sprite_frames) {
-
-
- if (frames==p_sprite_frames)
- return;
-
- if (frames.is_valid())
- frames->disconnect("changed",this,"_queue_update");
- frames=p_sprite_frames;
- if (frames.is_valid())
- frames->connect("changed",this,"_queue_update");
-
- if (!frames.is_valid() || frame >=frames->get_frame_count(animation)) {
- frame=0;
-
- }
- _queue_update();
-
-}
-
-Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const{
-
- return frames;
-}
-
-void AnimatedSprite3D::set_frame(int p_frame){
-
- if (frames.is_null())
- return;
-
- ERR_FAIL_INDEX(p_frame,frames->get_frame_count(animation));
-
- if (frame==p_frame)
- return;
-
- frame=p_frame;
- _queue_update();
- emit_signal(SceneStringNames::get_singleton()->frame_changed);
-
-}
-int AnimatedSprite3D::get_frame() const{
-
- return frame;
-}
-
-Rect2 AnimatedSprite3D::get_item_rect() const {
-
- if (!frames.is_valid() || !frames->get_frame_count(animation) || frame<0 || frame>=frames->get_frame_count(animation)) {
- return Rect2(0,0,1,1);
- }
-
- Ref<Texture> t = frames->get_frame(animation,frame);
- if (t.is_null())
- return Rect2(0,0,1,1);
- Size2i s = t->get_size();
-
- Point2i ofs=get_offset();
- if (is_centered())
- ofs-=s/2;
-
- if (s==Size2(0,0))
- s=Size2(1,1);
-
- return Rect2(ofs,s);
-}
-
-
-
-AnimatedSprite3D::AnimatedSprite3D() {
-
- animation="current";
- frame=0;
-}
-
-#endif
-
void AnimatedSprite3D::_draw() {
RID immediate = get_immediate();
@@ -1026,63 +809,6 @@ void AnimatedSprite3D::_notification(int p_what) {
timeout -= to_process;
}
} break;
-#if 0
- case NOTIFICATION_DRAW: {
-
- if (frames.is_null()) {
- print_line("no draw no faemos");
- return;
- }
-
- if (frame<0) {
- print_line("no draw frame <0");
- return;
- }
-
- if (!frames->has_animation(animation)) {
- print_line("no draw no anim: "+String(animation));
- return;
- }
-
-
-
- Ref<Texture> texture = frames->get_frame(animation,frame);
- if (texture.is_null()) {
- print_line("no draw texture is null");
- return;
- }
-
- //print_line("DECIDED TO DRAW");
-
- RID ci = get_canvas_item();
-
- /*
- texture->draw(ci,Point2());
- break;
- */
-
- Size2i s;
- s = texture->get_size();
- Point2 ofs=offset;
- if (centered)
- ofs-=s/2;
-
- if (OS::get_singleton()->get_use_pixel_snap()) {
- ofs=ofs.floor();
- }
- Rect2 dst_rect(ofs,s);
-
- if (hflip)
- dst_rect.size.x=-dst_rect.size.x;
- if (vflip)
- dst_rect.size.y=-dst_rect.size.y;
-
- //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);
-
- } break;
-#endif
}
}
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index b4600c00b8..1165392cb2 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -119,7 +119,7 @@ public:
void set_pixel_size(float p_amount);
float get_pixel_size() const;
- void set_axis(Vector3::Axis p_amount);
+ void set_axis(Vector3::Axis p_axis);
Vector3::Axis get_axis() const;
void set_draw_flag(DrawFlags p_flag, bool p_enable);
@@ -181,37 +181,6 @@ public:
//~Sprite3D();
};
-#if 0
-class AnimatedSprite3D : public SpriteBase3D {
-
- GDCLASS(AnimatedSprite3D,SpriteBase3D);
- Ref<SpriteFrames> frames;
-
-
- StringName animation;
- int frame;
-
-protected:
- virtual void _draw();
- static void _bind_methods();
-public:
-
-
-
- void set_sprite_frames(const Ref<SpriteFrames>& p_sprite_frames);
- Ref<SpriteFrames> get_sprite_frames() const;
-
- void set_frame(int p_frame);
- int get_frame() const;
-
-
- virtual Rect2 get_item_rect() const;
-
- AnimatedSprite3D();
- //~AnimatedSprite3D();
-};
-#endif
-
class AnimatedSprite3D : public SpriteBase3D {
GDCLASS(AnimatedSprite3D, SpriteBase3D);
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index 8d927e529e..d6b3206fbf 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -81,9 +81,7 @@ void VehicleWheel::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (!get_parent())
- return;
- VehicleBody *cb = get_parent()->cast_to<VehicleBody>();
+ VehicleBody *cb = Object::cast_to<VehicleBody>(get_parent());
if (!cb)
return;
body = cb;
@@ -96,9 +94,7 @@ void VehicleWheel::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
- if (!get_parent())
- return;
- VehicleBody *cb = get_parent()->cast_to<VehicleBody>();
+ VehicleBody *cb = Object::cast_to<VehicleBody>(get_parent());
if (!cb)
return;
cb->wheels.erase(this);
@@ -416,7 +412,7 @@ real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
wheel.m_raycastInfo.m_isInContact = true;
if (rr.collider)
- wheel.m_raycastInfo.m_groundObject = rr.collider->cast_to<PhysicsBody>();
+ wheel.m_raycastInfo.m_groundObject = Object::cast_to<PhysicsBody>(rr.collider);
real_t hitDistance = param * raylen;
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
@@ -559,6 +555,9 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
b2invinertia,
b2invmass);
+ // FIXME: rel_vel assignment here is overwritten by the following assignment.
+ // What seemes to be intented in the next next assignment is: rel_vel = normal.dot(rel_vel);
+ // Investigate why.
real_t rel_vel = jac.getRelativeVelocity(
s->get_linear_velocity(),
s->get_transform().basis.transposed().xform(s->get_angular_velocity()),
@@ -801,7 +800,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
void VehicleBody::_direct_state_changed(Object *p_state) {
- PhysicsDirectBodyState *s = p_state->cast_to<PhysicsDirectBodyState>();
+ PhysicsDirectBodyState *s = Object::cast_to<PhysicsDirectBodyState>(p_state);
set_ignore_transform_notification(true);
set_global_transform(s->get_transform());
@@ -893,9 +892,9 @@ real_t VehicleBody::get_friction() const {
return friction;
}
-void VehicleBody::set_engine_force(float p_force) {
+void VehicleBody::set_engine_force(float p_engine_force) {
- engine_force = p_force;
+ engine_force = p_engine_force;
}
float VehicleBody::get_engine_force() const {
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index 7ed9bce730..d67209c58f 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -196,7 +196,7 @@ public:
void set_engine_force(float p_engine_force);
float get_engine_force() const;
- void set_brake(float p_force);
+ void set_brake(float p_brake);
float get_brake() const;
void set_steering(float p_steering);
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index cc81a4cb56..d3203bacec 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,11 +29,11 @@
/*************************************************************************/
#include "visibility_notifier.h"
+#include "engine.h"
#include "scene/3d/camera.h"
#include "scene/3d/physics_body.h"
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
-#include "scene/scene_string_names.h"
void VisibilityNotifier::_enter_camera(Camera *p_camera) {
@@ -151,7 +151,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
if (enabler[ENABLER_FREEZE_BODIES]) {
- RigidBody *rb = p_node->cast_to<RigidBody>();
+ RigidBody *rb = Object::cast_to<RigidBody>(p_node);
if (rb && ((rb->get_mode() == RigidBody::MODE_CHARACTER || (rb->get_mode() == RigidBody::MODE_RIGID && !rb->is_able_to_sleep())))) {
add = true;
@@ -161,7 +161,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
if (enabler[ENABLER_PAUSE_ANIMATIONS]) {
- AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
add = true;
}
@@ -187,7 +187,7 @@ void VisibilityEnabler::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
Node *from = this;
@@ -200,7 +200,7 @@ void VisibilityEnabler::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
@@ -219,14 +219,14 @@ void VisibilityEnabler::_change_node_state(Node *p_node, bool p_enabled) {
ERR_FAIL_COND(!nodes.has(p_node));
{
- RigidBody *rb = p_node->cast_to<RigidBody>();
+ RigidBody *rb = Object::cast_to<RigidBody>(p_node);
if (rb)
rb->set_sleeping(!p_enabled);
}
{
- AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
@@ -252,9 +252,9 @@ void VisibilityEnabler::_bind_methods() {
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);
- BIND_CONSTANT(ENABLER_MAX);
+ BIND_ENUM_CONSTANT(ENABLER_FREEZE_BODIES);
+ BIND_ENUM_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
+ BIND_ENUM_CONSTANT(ENABLER_MAX);
}
void VisibilityEnabler::set_enabler(Enabler p_enabler, bool p_enable) {
diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h
index 316b2c3575..0b83e0534e 100644
--- a/scene/3d/visibility_notifier.h
+++ b/scene/3d/visibility_notifier.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 1a294d016a..0464a82f65 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "visual_instance.h"
-#include "room_instance.h"
#include "scene/scene_string_names.h"
#include "servers/visual_server.h"
#include "skeleton.h"
@@ -54,32 +53,9 @@ void VisualInstance::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- // CHECK ROOM
- Spatial *parent = get_parent_spatial();
- Room *room = NULL;
- bool is_geom = cast_to<GeometryInstance>();
-
- /* while(parent) {
-
- room = parent->cast_to<Room>();
- if (room)
- break;
-
- if (is_geom && parent->cast_to<BakedLightSampler>()) {
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(get_instance(),parent->cast_to<BakedLightSampler>()->get_instance());
- break;
- }
-
- parent=parent->get_parent_spatial();
- }*/
-
- if (room) {
-
- VisualServer::get_singleton()->instance_set_room(instance, room->get_instance());
- }
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
/*
- Skeleton *skeleton=get_parent()?get_parent()->cast_to<Skeleton>():NULL;
+ Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent());
if (skeleton)
VisualServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
*/
@@ -96,7 +72,6 @@ void VisualInstance::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
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() );
@@ -231,14 +206,6 @@ void GeometryInstance::_notification(int p_what) {
void GeometryInstance::set_flag(Flags p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
- if (p_flag == FLAG_CAST_SHADOW) {
- if (p_value == true) {
- set_cast_shadows_setting(SHADOW_CASTING_SETTING_ON);
- } else {
- set_cast_shadows_setting(SHADOW_CASTING_SETTING_OFF);
- }
- }
-
if (flags[p_flag] == p_value)
return;
@@ -252,14 +219,6 @@ bool GeometryInstance::get_flag(Flags p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
- if (p_flag == FLAG_CAST_SHADOW) {
- if (shadow_casting_setting == SHADOW_CASTING_SETTING_OFF) {
- return false;
- } else {
- return true;
- }
- }
-
return flags[p_flag];
}
@@ -319,7 +278,6 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "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, "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_");
@@ -330,8 +288,6 @@ void GeometryInstance::_bind_methods() {
//ADD_SIGNAL( MethodInfo("visibility_changed"));
- BIND_CONSTANT(FLAG_CAST_SHADOW);
- BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS);
BIND_CONSTANT(FLAG_MAX);
BIND_CONSTANT(SHADOW_CASTING_SETTING_OFF);
@@ -350,8 +306,6 @@ GeometryInstance::GeometryInstance() {
flags[i] = false;
}
- flags[FLAG_CAST_SHADOW] = true;
-
shadow_casting_setting = SHADOW_CASTING_SETTING_ON;
extra_cull_margin = 0;
//VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index 9318198e54..c405236d2c 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -76,16 +76,12 @@ public:
~VisualInstance();
};
-class BakedLight;
-
class GeometryInstance : public VisualInstance {
GDCLASS(GeometryInstance, VisualInstance);
public:
enum Flags {
- FLAG_CAST_SHADOW = VS::INSTANCE_FLAG_CAST_SHADOW,
- FLAG_VISIBLE_IN_ALL_ROOMS = VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
FLAG_MAX = VS::INSTANCE_FLAG_MAX,
};
diff --git a/scene/SCsub b/scene/SCsub
index df52e9c6cb..513adeffda 100644
--- a/scene/SCsub
+++ b/scene/SCsub
@@ -27,7 +27,6 @@ SConscript('2d/SCsub')
SConscript('animation/SCsub')
SConscript('audio/SCsub')
SConscript('resources/SCsub')
-SConscript('io/SCsub')
# Build it all as a library
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index 31fee0e347..b35b2568d1 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -120,7 +120,7 @@ void AnimationCache::_update_cache() {
StringName property = np.get_property();
String ps = property;
- Spatial *sp = node->cast_to<Spatial>();
+ Spatial *sp = Object::cast_to<Spatial>(node);
if (!sp) {
@@ -131,7 +131,7 @@ void AnimationCache::_update_cache() {
if (ps != "") {
- Skeleton *sk = node->cast_to<Skeleton>();
+ Skeleton *sk = Object::cast_to<Skeleton>(node);
if (!sk) {
path_cache.push_back(Path());
diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h
index 6687098d00..e593668df6 100644
--- a/scene/animation/animation_cache.h
+++ b/scene/animation/animation_cache.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index e2a0636466..be0b652276 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "animation_player.h"
+#include "engine.h"
#include "message_queue.h"
#include "scene/scene_string_names.h"
@@ -199,7 +200,7 @@ void AnimationPlayer::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
- if (!get_tree()->is_editor_hint() && animation_set.has(autoplay)) {
+ if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
play(autoplay);
set_autoplay(""); //this line is the fix for autoplay issues with animatio
_animation_process(0);
@@ -250,9 +251,9 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
uint32_t id = resource.is_valid() ? resource->get_instance_id() : child->get_instance_id();
int bone_idx = -1;
- if (a->track_get_path(i).get_property() && child->cast_to<Skeleton>()) {
+ if (a->track_get_path(i).get_property() && Object::cast_to<Skeleton>(child)) {
- bone_idx = child->cast_to<Skeleton>()->find_bone(a->track_get_path(i).get_property());
+ bone_idx = Object::cast_to<Skeleton>(child)->find_bone(a->track_get_path(i).get_property());
if (bone_idx == -1) {
continue;
@@ -279,14 +280,14 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
p_anim->node_cache[i]->path = a->track_get_path(i);
p_anim->node_cache[i]->node = child;
p_anim->node_cache[i]->resource = resource;
- p_anim->node_cache[i]->node_2d = child->cast_to<Node2D>();
+ p_anim->node_cache[i]->node_2d = Object::cast_to<Node2D>(child);
if (a->track_get_type(i) == Animation::TYPE_TRANSFORM) {
// special cases and caches for transform tracks
// cache spatial
- p_anim->node_cache[i]->spatial = child->cast_to<Spatial>();
+ p_anim->node_cache[i]->spatial = Object::cast_to<Spatial>(child);
// cache skeleton
- p_anim->node_cache[i]->skeleton = child->cast_to<Skeleton>();
+ p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child);
if (p_anim->node_cache[i]->skeleton) {
StringName bone_name = a->track_get_path(i).get_property();
@@ -344,7 +345,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count());
Animation *a = p_anim->animation.operator->();
- bool can_call = is_inside_tree() && !get_tree()->is_editor_hint();
+ bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
for (int i = 0; i < a->get_track_count(); i++) {
@@ -607,16 +608,6 @@ void AnimationPlayer::_animation_update_transforms() {
ERR_CONTINUE(pa->accum_pass != accum_pass);
-#if 1
- /* switch(pa->special) {
-
-
- case SP_NONE: pa->object->set(pa->prop,pa->value_accum); break; //you are not speshul
- case SP_NODE2D_POS: static_cast<Node2D*>(pa->object)->set_position(pa->value_accum); break;
- case SP_NODE2D_ROT: static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum)); break;
- case SP_NODE2D_SCALE: static_cast<Node2D*>(pa->object)->set_scale(pa->value_accum); break;
- }*/
-
switch (pa->special) {
case SP_NONE: {
@@ -656,10 +647,6 @@ void AnimationPlayer::_animation_update_transforms() {
static_cast<Node2D *>(pa->object)->set_scale(pa->value_accum);
} break;
}
-#else
-
- pa->object->set(pa->prop, pa->value_accum);
-#endif
}
cache_update_prop_size = 0;
@@ -667,8 +654,6 @@ void AnimationPlayer::_animation_update_transforms() {
void AnimationPlayer::_animation_process(float p_delta) {
- //bool any_active=false;
-
if (playback.current.from) {
end_notify = false;
@@ -955,7 +940,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
emit_signal(SceneStringNames::get_singleton()->animation_started, c.assigned);
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
return; // no next in this case
StringName next = animation_get_next(p_name);
@@ -1277,8 +1262,8 @@ void AnimationPlayer::_bind_methods() {
ADD_SIGNAL(MethodInfo("animation_changed", PropertyInfo(Variant::STRING, "old_name"), PropertyInfo(Variant::STRING, "new_name")));
ADD_SIGNAL(MethodInfo("animation_started", PropertyInfo(Variant::STRING, "name")));
- BIND_CONSTANT(ANIMATION_PROCESS_FIXED);
- BIND_CONSTANT(ANIMATION_PROCESS_IDLE);
+ BIND_ENUM_CONSTANT(ANIMATION_PROCESS_FIXED);
+ BIND_ENUM_CONSTANT(ANIMATION_PROCESS_IDLE);
}
AnimationPlayer::AnimationPlayer() {
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 96fc70a3ad..c6e52145a8 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -271,7 +271,7 @@ public:
void set_speed_scale(float p_speed);
float get_speed_scale() const;
- void set_autoplay(const String &pname);
+ void set_autoplay(const String &p_name);
String get_autoplay() const;
void set_animation_process_mode(AnimationProcessMode p_mode);
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index c12e97c4a5..e2330eb0d4 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -1487,8 +1487,8 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p
if (p_path.get_property()) {
- if (child->cast_to<Skeleton>())
- bone_idx = child->cast_to<Skeleton>()->find_bone(p_path.get_property());
+ if (Object::cast_to<Skeleton>(child))
+ bone_idx = Object::cast_to<Skeleton>(child)->find_bone(p_path.get_property());
if (bone_idx == -1)
property = p_path.get_property();
}
@@ -1503,8 +1503,8 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p
Track tr;
tr.id = id;
tr.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child;
- tr.skeleton = child->cast_to<Skeleton>();
- tr.spatial = child->cast_to<Spatial>();
+ tr.skeleton = Object::cast_to<Skeleton>(child);
+ tr.spatial = Object::cast_to<Spatial>(child);
tr.bone_idx = bone_idx;
tr.property = property;
@@ -1644,7 +1644,7 @@ void AnimationTreePlayer::_update_sources() {
ERR_FAIL_COND(!m);
}
- AnimationPlayer *ap = m->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(m);
if (!ap) {
@@ -1797,16 +1797,16 @@ void AnimationTreePlayer::_bind_methods() {
ADD_GROUP("Playback", "playback_");
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);
- BIND_CONSTANT(NODE_ONESHOT);
- BIND_CONSTANT(NODE_MIX);
- BIND_CONSTANT(NODE_BLEND2);
- BIND_CONSTANT(NODE_BLEND3);
- BIND_CONSTANT(NODE_BLEND4);
- BIND_CONSTANT(NODE_TIMESCALE);
- BIND_CONSTANT(NODE_TIMESEEK);
- BIND_CONSTANT(NODE_TRANSITION);
+ BIND_ENUM_CONSTANT(NODE_OUTPUT);
+ BIND_ENUM_CONSTANT(NODE_ANIMATION);
+ BIND_ENUM_CONSTANT(NODE_ONESHOT);
+ BIND_ENUM_CONSTANT(NODE_MIX);
+ BIND_ENUM_CONSTANT(NODE_BLEND2);
+ BIND_ENUM_CONSTANT(NODE_BLEND3);
+ BIND_ENUM_CONSTANT(NODE_BLEND4);
+ BIND_ENUM_CONSTANT(NODE_TIMESCALE);
+ BIND_ENUM_CONSTANT(NODE_TIMESEEK);
+ BIND_ENUM_CONSTANT(NODE_TRANSITION);
}
AnimationTreePlayer::AnimationTreePlayer() {
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index 062b4e1eeb..71d7277118 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -312,7 +312,7 @@ private:
Map<StringName, NodeBase *> node_map;
// return time left to finish animation
- float _process_node(const StringName &p_node, AnimationNode **r_prev_anim, float p_step, bool p_seek = false, float p_fallback_weight = 1.0, HashMap<NodePath, float> *p_weights = NULL);
+ float _process_node(const StringName &p_node, AnimationNode **r_prev_anim, float p_time, bool p_seek = false, float p_fallback_weight = 1.0, HashMap<NodePath, float> *p_weights = NULL);
void _process_animation(float p_delta);
bool reset_request;
@@ -367,7 +367,7 @@ public:
float oneshot_node_get_autorestart_delay(const StringName &p_node) const;
float oneshot_node_get_autorestart_random_delay(const StringName &p_node) const;
- void oneshot_node_set_mix_mode(const StringName &p_node, bool p_enabled);
+ void oneshot_node_set_mix_mode(const StringName &p_node, bool p_mix);
bool oneshot_node_get_mix_mode(const StringName &p_node) const;
void oneshot_node_start(const StringName &p_node);
@@ -428,8 +428,8 @@ public:
void remove_node(const StringName &p_node);
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);
+ bool are_nodes_connected(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input) const;
+ void disconnect_nodes(const StringName &p_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 78d3357bb4..fb61c43d5c 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -224,25 +224,25 @@ void Tween::_bind_methods() {
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);
-
- BIND_CONSTANT(TRANS_LINEAR);
- BIND_CONSTANT(TRANS_SINE);
- BIND_CONSTANT(TRANS_QUINT);
- BIND_CONSTANT(TRANS_QUART);
- BIND_CONSTANT(TRANS_QUAD);
- BIND_CONSTANT(TRANS_EXPO);
- BIND_CONSTANT(TRANS_ELASTIC);
- BIND_CONSTANT(TRANS_CUBIC);
- BIND_CONSTANT(TRANS_CIRC);
- BIND_CONSTANT(TRANS_BOUNCE);
- BIND_CONSTANT(TRANS_BACK);
-
- BIND_CONSTANT(EASE_IN);
- BIND_CONSTANT(EASE_OUT);
- BIND_CONSTANT(EASE_IN_OUT);
- BIND_CONSTANT(EASE_OUT_IN);
+ BIND_ENUM_CONSTANT(TWEEN_PROCESS_FIXED);
+ BIND_ENUM_CONSTANT(TWEEN_PROCESS_IDLE);
+
+ BIND_ENUM_CONSTANT(TRANS_LINEAR);
+ BIND_ENUM_CONSTANT(TRANS_SINE);
+ BIND_ENUM_CONSTANT(TRANS_QUINT);
+ BIND_ENUM_CONSTANT(TRANS_QUART);
+ BIND_ENUM_CONSTANT(TRANS_QUAD);
+ BIND_ENUM_CONSTANT(TRANS_EXPO);
+ BIND_ENUM_CONSTANT(TRANS_ELASTIC);
+ BIND_ENUM_CONSTANT(TRANS_CUBIC);
+ BIND_ENUM_CONSTANT(TRANS_CIRC);
+ BIND_ENUM_CONSTANT(TRANS_BOUNCE);
+ BIND_ENUM_CONSTANT(TRANS_BACK);
+
+ BIND_ENUM_CONSTANT(EASE_IN);
+ BIND_ENUM_CONSTANT(EASE_OUT);
+ BIND_ENUM_CONSTANT(EASE_IN_OUT);
+ BIND_ENUM_CONSTANT(EASE_OUT_IN);
}
Variant &Tween::_get_initial_val(InterpolateData &p_data) {
@@ -560,12 +560,16 @@ void Tween::_tween_process(float p_delta) {
switch (data.type) {
case INTER_PROPERTY:
- case INTER_METHOD:
- break;
+ case INTER_METHOD: {
+ Variant result = _run_equation(data);
+ emit_signal("tween_step", object, data.key, data.elapsed, result);
+ _apply_tween_value(data, result);
+ if (data.finish)
+ _apply_tween_value(data, data.final_val);
+ } break;
+
case INTER_CALLBACK:
if (data.finish) {
-
- Variant::CallError error;
if (data.call_deferred) {
switch (data.args) {
@@ -588,8 +592,8 @@ void Tween::_tween_process(float p_delta) {
object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
break;
}
-
} else {
+ Variant::CallError error;
Variant *arg[5] = {
&data.arg[0],
&data.arg[1],
@@ -599,19 +603,11 @@ void Tween::_tween_process(float p_delta) {
};
object->call(data.key, (const Variant **)arg, data.args, error);
}
- if (!repeat)
- call_deferred("_remove", object, data.key, true);
}
- continue;
+ break;
}
- Variant result = _run_equation(data);
- emit_signal("tween_step", object, data.key, data.elapsed, result);
-
- _apply_tween_value(data, result);
-
if (data.finish) {
- _apply_tween_value(data, data.final_val);
emit_signal("tween_completed", object, data.key);
// not repeat mode, remove completed action
if (!repeat)
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index f89f3bdc44..929d63a7fc 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -132,7 +132,7 @@ private:
void _tween_process(float p_delta);
void _set_process(bool p_process, bool p_force = false);
- void _remove(Object *p_node, String p_key, bool first_only);
+ void _remove(Object *p_object, String p_key, bool first_only);
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -156,34 +156,34 @@ public:
float get_speed_scale() const;
bool start();
- bool reset(Object *p_node, String p_key);
+ bool reset(Object *p_object, String p_key);
bool reset_all();
- bool stop(Object *p_node, String p_key);
+ bool stop(Object *p_object, String p_key);
bool stop_all();
- bool resume(Object *p_node, String p_key);
+ bool resume(Object *p_object, String p_key);
bool resume_all();
- bool remove(Object *p_node, String p_key);
+ bool remove(Object *p_object, String p_key);
bool remove_all();
bool seek(real_t p_time);
real_t tell() const;
real_t get_runtime() const;
- bool interpolate_property(Object *p_node, String p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool interpolate_property(Object *p_object, String p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool interpolate_method(Object *p_node, String p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool interpolate_method(Object *p_object, String p_method, Variant p_initial_val, Variant p_final_val, 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_duration, String p_callback, VARIANT_ARG_DECLARE);
bool interpolate_deferred_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE);
- bool follow_property(Object *p_node, String p_property, Variant p_initial_val, Object *p_target, String p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool follow_property(Object *p_object, String p_property, Variant p_initial_val, Object *p_target, String p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool follow_method(Object *p_node, String p_method, Variant p_initial_val, Object *p_target, String p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool follow_method(Object *p_object, String p_method, Variant p_initial_val, Object *p_target, String p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool targeting_property(Object *p_node, String p_property, Object *p_initial, String p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool targeting_property(Object *p_object, String p_property, Object *p_initial, String p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool targeting_method(Object *p_node, String p_method, Object *p_initial, String p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool targeting_method(Object *p_object, String p_method, Object *p_initial, String p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
Tween();
~Tween();
diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp
index 434f4df3e1..8f543a575a 100644
--- a/scene/animation/tween_interpolaters.cpp
+++ b/scene/animation/tween_interpolaters.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index a8ddcbbb45..5d71f702df 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "audio_player.h"
+#include "engine.h"
+
void AudioStreamPlayer::_mix_audio() {
if (!stream_playback.is_valid()) {
@@ -100,11 +102,20 @@ void AudioStreamPlayer::_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()) {
+ if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
}
}
+ if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
+
+ if (!active || (setseek < 0 && !stream_playback->is_playing())) {
+ active = false;
+ emit_signal("finished");
+ set_process_internal(false);
+ }
+ }
+
if (p_what == NOTIFICATION_EXIT_TREE) {
AudioServer::get_singleton()->remove_callback(_mix_audios, this);
@@ -156,6 +167,7 @@ void AudioStreamPlayer::play(float p_from_pos) {
mix_volume_db = volume_db; //reset volume ramp
setseek = p_from_pos;
active = true;
+ set_process_internal(true);
}
}
@@ -170,6 +182,7 @@ void AudioStreamPlayer::stop() {
if (stream_playback.is_valid()) {
active = false;
+ set_process_internal(false);
}
}
@@ -295,6 +308,8 @@ void AudioStreamPlayer::_bind_methods() {
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");
+
+ ADD_SIGNAL(MethodInfo("finished"));
}
AudioStreamPlayer::AudioStreamPlayer() {
diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h
index 8bd6844dec..4bfa84f766 100644
--- a/scene/audio/audio_player.h
+++ b/scene/audio/audio_player.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 9c20decef0..8fd19e8655 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "base_button.h"
+
#include "os/keyboard.h"
#include "print_string.h"
#include "scene/main/viewport.h"
@@ -514,13 +515,13 @@ void BaseButton::_bind_methods() {
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);
- BIND_CONSTANT(DRAW_PRESSED);
- BIND_CONSTANT(DRAW_HOVER);
- BIND_CONSTANT(DRAW_DISABLED);
+ BIND_ENUM_CONSTANT(DRAW_NORMAL);
+ BIND_ENUM_CONSTANT(DRAW_PRESSED);
+ BIND_ENUM_CONSTANT(DRAW_HOVER);
+ BIND_ENUM_CONSTANT(DRAW_DISABLED);
- BIND_CONSTANT(ACTION_MODE_BUTTON_PRESS);
- BIND_CONSTANT(ACTION_MODE_BUTTON_RELEASE);
+ BIND_ENUM_CONSTANT(ACTION_MODE_BUTTON_PRESS);
+ BIND_ENUM_CONSTANT(ACTION_MODE_BUTTON_RELEASE);
}
BaseButton::BaseButton() {
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index dfcf3b0f8a..0c08dc53a3 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index 16b2cfa083..739fd84b38 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -54,7 +54,7 @@ void BoxContainer::_resort() {
Map<Control *, _MinSizeCache> min_size_cache;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
@@ -106,7 +106,7 @@ void BoxContainer::_resort() {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
@@ -159,7 +159,7 @@ void BoxContainer::_resort() {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
@@ -211,7 +211,7 @@ Size2 BoxContainer::get_minimum_size() const {
bool first = true;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -295,9 +295,9 @@ void BoxContainer::_bind_methods() {
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);
+ BIND_ENUM_CONSTANT(ALIGN_BEGIN);
+ BIND_ENUM_CONSTANT(ALIGN_CENTER);
+ BIND_ENUM_CONSTANT(ALIGN_END);
ADD_PROPERTY(PropertyInfo(Variant::INT, "alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), "set_alignment", "get_alignment");
}
diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h
index d544ff79d1..4d00a2011f 100644
--- a/scene/gui/box_container.h
+++ b/scene/gui/box_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 9a0b3b3c89..1fa03f81f4 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -59,7 +59,7 @@ void Button::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- xl_text = XL_MESSAGE(text);
+ xl_text = tr(text);
minimum_size_changed();
update();
}
@@ -172,7 +172,7 @@ void Button::set_text(const String &p_text) {
if (text == p_text)
return;
text = p_text;
- xl_text = XL_MESSAGE(p_text);
+ xl_text = tr(p_text);
update();
_change_notify("text");
minimum_size_changed();
@@ -245,9 +245,9 @@ void Button::_bind_methods() {
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);
+ BIND_ENUM_CONSTANT(ALIGN_LEFT);
+ BIND_ENUM_CONSTANT(ALIGN_CENTER);
+ BIND_ENUM_CONSTANT(ALIGN_RIGHT);
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");
diff --git a/scene/gui/button.h b/scene/gui/button.h
index 499e44c0e1..dd6e730b86 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
index e54e810d7d..336c88fe9d 100644
--- a/scene/gui/button_group.cpp
+++ b/scene/gui/button_group.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -56,7 +56,7 @@ void ButtonGroup::set_pressed_button(BaseButton *p_button) {
void ButtonGroup::_pressed(Object *p_button) {
ERR_FAIL_NULL(p_button);
- BaseButton *b=p_button->cast_to<BaseButton>();
+ BaseButton *b=Object::cast_to<BaseButton>(p_button);
ERR_FAIL_COND(!b);
for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h
index 93c3aaaeb3..6ebc0575d2 100644
--- a/scene/gui/button_group.h
+++ b/scene/gui/button_group.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index bdc811870d..8c9c9d8720 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -36,7 +36,7 @@ Size2 CenterContainer::get_minimum_size() const {
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -69,7 +69,7 @@ void CenterContainer::_notification(int p_what) {
Size2 size = get_size();
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h
index 30b526e893..4397539046 100644
--- a/scene/gui/center_container.h
+++ b/scene/gui/center_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index b61d516599..21e2269141 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h
index ec8e097bae..4a1adb5f2f 100644
--- a/scene/gui/check_box.h
+++ b/scene/gui/check_box.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index 1c3d4df308..e68159e27f 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h
index 8634858cfe..af3b80fe04 100644
--- a/scene/gui/check_button.h
+++ b/scene/gui/check_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index dddd53dd95..704c00b1d6 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -56,11 +56,10 @@ void ColorPicker::_notification(int p_what) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (get_parent()) {
- Popup *p = get_parent()->cast_to<Popup>();
- if (p)
- p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
- }
+
+ Popup *p = Object::cast_to<Popup>(get_parent());
+ if (p)
+ p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
} break;
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
@@ -204,7 +203,7 @@ void ColorPicker::_update_presets() {
}
void ColorPicker::_text_type_toggled() {
- if (!get_tree()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint())
return;
text_is_constructor = !text_is_constructor;
if (text_is_constructor) {
@@ -314,9 +313,9 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) {
}
}
-void ColorPicker::_uv_input(const Ref<InputEvent> &ev) {
+void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventMouseButton> bev = ev;
+ Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
@@ -335,7 +334,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &ev) {
}
}
- Ref<InputEventMouseMotion> mev = ev;
+ Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
if (!changing_color)
@@ -352,9 +351,9 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &ev) {
}
}
-void ColorPicker::_w_input(const Ref<InputEvent> &ev) {
+void ColorPicker::_w_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventMouseButton> bev = ev;
+ Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
@@ -372,7 +371,7 @@ void ColorPicker::_w_input(const Ref<InputEvent> &ev) {
emit_signal("color_changed", color);
}
- Ref<InputEventMouseMotion> mev = ev;
+ Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
@@ -388,9 +387,9 @@ void ColorPicker::_w_input(const Ref<InputEvent> &ev) {
}
}
-void ColorPicker::_preset_input(const Ref<InputEvent> &ev) {
+void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventMouseButton> bev = ev;
+ Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
@@ -407,7 +406,7 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &ev) {
emit_signal("color_changed", color);
}
- Ref<InputEventMouseMotion> mev = ev;
+ Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
@@ -423,9 +422,9 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &ev) {
}
}
-void ColorPicker::_screen_input(const Ref<InputEvent> &ev) {
+void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
- Ref<InputEventMouseButton> bev = ev;
+ Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
@@ -435,7 +434,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &ev) {
}
}
- Ref<InputEventMouseMotion> mev = ev;
+ Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
Viewport *r = get_tree()->get_root();
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 1a79266409..7de67a707c 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -81,10 +81,10 @@ private:
void _sample_draw();
void _hsv_draw(int p_which, Control *c);
- void _uv_input(const Ref<InputEvent> &p_input);
- void _w_input(const Ref<InputEvent> &p_input);
- void _preset_input(const Ref<InputEvent> &p_input);
- void _screen_input(const Ref<InputEvent> &p_input);
+ void _uv_input(const Ref<InputEvent> &p_event);
+ void _w_input(const Ref<InputEvent> &p_event);
+ void _preset_input(const Ref<InputEvent> &p_event);
+ void _screen_input(const Ref<InputEvent> &p_event);
void _add_preset_pressed();
void _screen_pick_pressed();
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
index 0641302b1c..6b5247648e 100644
--- a/scene/gui/color_rect.cpp
+++ b/scene/gui/color_rect.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h
index 65da3d9a7c..382648fddf 100644
--- a/scene/gui/color_rect.h
+++ b/scene/gui/color_rect.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 4bbe15ed7e..ba5d92620b 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -43,7 +43,7 @@ void Container::add_child_notify(Node *p_child) {
Control::add_child_notify(p_child);
- Control *control = p_child->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(p_child);
if (!control)
return;
@@ -57,7 +57,7 @@ void Container::move_child_notify(Node *p_child) {
Control::move_child_notify(p_child);
- if (!p_child->cast_to<Control>())
+ if (!Object::cast_to<Control>(p_child))
return;
queue_sort();
@@ -67,7 +67,7 @@ void Container::remove_child_notify(Node *p_child) {
Control::remove_child_notify(p_child);
- Control *control = p_child->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(p_child);
if (!control)
return;
diff --git a/scene/gui/container.h b/scene/gui/container.h
index bff24c6d55..60a7a9efcb 100644
--- a/scene/gui/container.h
+++ b/scene/gui/container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 01570e28c4..961fccc804 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -51,6 +51,12 @@ Variant Control::edit_get_state() const {
s["rect"] = get_rect();
s["rot"] = get_rotation();
s["scale"] = get_scale();
+ Array anchors;
+ anchors.push_back(get_anchor(MARGIN_LEFT));
+ anchors.push_back(get_anchor(MARGIN_TOP));
+ anchors.push_back(get_anchor(MARGIN_RIGHT));
+ anchors.push_back(get_anchor(MARGIN_BOTTOM));
+ s["anchors"] = anchors;
return s;
}
void Control::edit_set_state(const Variant &p_state) {
@@ -62,6 +68,11 @@ void Control::edit_set_state(const Variant &p_state) {
set_size(state.size);
set_rotation(s["rot"]);
set_scale(s["scale"]);
+ Array anchors = s["anchors"];
+ set_anchor(MARGIN_LEFT, anchors[0]);
+ set_anchor(MARGIN_TOP, anchors[1]);
+ set_anchor(MARGIN_RIGHT, anchors[2]);
+ set_anchor(MARGIN_BOTTOM, anchors[3]);
}
void Control::set_custom_minimum_size(const Size2 &p_custom) {
@@ -342,7 +353,7 @@ void Control::_resize(const Size2 &p_size) {
void Control::add_child_notify(Node *p_child) {
- Control *child_c = p_child->cast_to<Control>();
+ Control *child_c = Object::cast_to<Control>(p_child);
if (!child_c)
return;
@@ -353,7 +364,7 @@ void Control::add_child_notify(Node *p_child) {
void Control::remove_child_notify(Node *p_child) {
- Control *child_c = p_child->cast_to<Control>();
+ Control *child_c = Object::cast_to<Control>(p_child);
if (!child_c)
return;
@@ -387,7 +398,7 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_ENTER_CANVAS: {
- data.parent = get_parent()->cast_to<Control>();
+ data.parent = Object::cast_to<Control>(get_parent());
if (is_set_as_toplevel()) {
data.SI = get_viewport()->_gui_add_subwindow_control(this);
@@ -410,13 +421,13 @@ void Control::_notification(int p_notification) {
if (!parent)
break;
- CanvasItem *ci = parent->cast_to<CanvasItem>();
+ CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
if (ci && ci->is_set_as_toplevel()) {
subwindow = true;
break;
}
- parent_control = parent->cast_to<Control>();
+ parent_control = Object::cast_to<Control>(parent);
if (parent_control) {
break;
@@ -613,7 +624,7 @@ Variant Control::get_drag_data(const Point2 &p_point) {
if (data.drag_owner) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
- Control *c = obj->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(obj);
return c->call("get_drag_data_fw", p_point, this);
}
}
@@ -635,7 +646,7 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const
if (data.drag_owner) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
- Control *c = obj->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(obj);
return c->call("can_drop_data_fw", p_point, p_data, this);
}
}
@@ -656,7 +667,7 @@ void Control::drop_data(const Point2 &p_point, const Variant &p_data) {
if (data.drag_owner) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
- Control *c = obj->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(obj);
c->call("drop_data_fw", p_point, p_data, this);
return;
}
@@ -738,7 +749,7 @@ Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_typ
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -774,7 +785,7 @@ Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_ty
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -810,7 +821,7 @@ Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName &
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -847,7 +858,7 @@ Ref<Font> Control::get_font(const StringName &p_name, const StringName &p_type)
if (theme_owner->data.theme->get_default_theme_font().is_valid())
return theme_owner->data.theme->get_default_theme_font();
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -881,7 +892,7 @@ Color Control::get_color(const StringName &p_name, const StringName &p_type) con
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -916,7 +927,7 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1004,7 +1015,7 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1038,7 +1049,7 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1071,7 +1082,7 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1104,7 +1115,7 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1138,7 +1149,7 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1172,7 +1183,7 @@ bool Control::has_constant(const StringName &p_name, const StringName &p_type) c
class_name = ClassDB::get_parent_class_nocheck(class_name);
}
- Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(theme_owner->get_parent());
if (parent)
theme_owner = parent->data.theme_owner;
@@ -1212,21 +1223,7 @@ void Control::_size_changed() {
for (int i = 0; i < 4; i++) {
float area = parent_size[i & 1];
- switch (data.anchor[i]) {
-
- case ANCHOR_BEGIN: {
-
- margin_pos[i] = data.margin[i];
- } break;
- case ANCHOR_END: {
-
- margin_pos[i] = area - data.margin[i];
- } break;
- case ANCHOR_CENTER: {
-
- margin_pos[i] = (area / 2) - data.margin[i];
- } break;
- }
+ margin_pos[i] = data.margin[i] + (data.anchor[i] * area);
}
Point2 new_pos_cache = Point2(margin_pos[0], margin_pos[1]);
@@ -1299,61 +1296,40 @@ float Control::_get_range(int p_idx) const {
return to - from;
}
-float Control::_s2a(float p_val, AnchorType p_anchor, float p_range) const {
-
- switch (p_anchor) {
-
- case ANCHOR_BEGIN: {
- return p_val;
- } break;
- case ANCHOR_END: {
- return p_range - p_val;
- } break;
- case ANCHOR_CENTER: {
- return (p_range / 2) - p_val;
- } break;
- }
-
- return 0;
+float Control::_s2a(float p_val, float p_anchor, float p_range) const {
+ return p_val - (p_anchor * p_range);
}
-float Control::_a2s(float p_val, AnchorType p_anchor, float p_range) const {
-
- switch (p_anchor) {
-
- case ANCHOR_BEGIN: {
- return Math::floor(p_val);
- } break;
- case ANCHOR_END: {
- return Math::floor(p_range - p_val);
- } break;
- case ANCHOR_CENTER: {
- return Math::floor((p_range / 2) - p_val);
- } break;
- }
- return 0;
+float Control::_a2s(float p_val, float p_anchor, float p_range) const {
+ return Math::floor(p_val + (p_anchor * p_range));
}
-void Control::set_anchor(Margin p_margin, AnchorType p_anchor, bool p_keep_margin) {
+void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bool p_push_opposite_anchor) {
+ bool pushed = false;
+ data.anchor[p_margin] = CLAMP(p_anchor, 0.0, 1.0);
- if (!is_inside_tree()) {
+ if (((p_margin == MARGIN_LEFT || p_margin == MARGIN_TOP) && data.anchor[p_margin] > data.anchor[(p_margin + 2) % 4]) ||
+ ((p_margin == MARGIN_RIGHT || p_margin == MARGIN_BOTTOM) && data.anchor[p_margin] < data.anchor[(p_margin + 2) % 4])) {
+ if (p_push_opposite_anchor) {
+ data.anchor[(p_margin + 2) % 4] = data.anchor[p_margin];
+ pushed = true;
+ } else {
+ data.anchor[p_margin] = data.anchor[(p_margin + 2) % 4];
+ }
+ }
- data.anchor[p_margin] = p_anchor;
- } else if (!p_keep_margin) {
- float pr = _get_parent_range(p_margin);
- float s = _a2s(data.margin[p_margin], data.anchor[p_margin], pr);
- data.anchor[p_margin] = p_anchor;
- data.margin[p_margin] = _s2a(s, p_anchor, pr);
- } else {
- data.anchor[p_margin] = p_anchor;
- _size_changed();
+ if (is_inside_tree()) {
+ if (p_keep_margin) {
+ _size_changed();
+ }
}
+ update();
_change_notify();
}
-void Control::_set_anchor(Margin p_margin, AnchorType p_anchor) {
+void Control::_set_anchor(Margin p_margin, float p_anchor) {
#ifdef TOOLS_ENABLED
- if (is_inside_tree() && get_tree()->is_editor_hint()) {
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
set_anchor(p_margin, p_anchor, EDITOR_DEF("editors/2d/keep_margins_when_changing_anchors", false));
} else {
set_anchor(p_margin, p_anchor, false);
@@ -1363,13 +1339,127 @@ void Control::_set_anchor(Margin p_margin, AnchorType p_anchor) {
#endif
}
-void Control::set_anchor_and_margin(Margin p_margin, AnchorType p_anchor, float p_pos) {
+void Control::set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor) {
- set_anchor(p_margin, p_anchor);
+ set_anchor(p_margin, p_anchor, false, p_push_opposite_anchor);
set_margin(p_margin, p_pos);
}
-Control::AnchorType Control::get_anchor(Margin p_margin) const {
+void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margin) {
+ //Left
+ switch (p_preset) {
+ case PRESET_TOP_LEFT:
+ case PRESET_BOTTOM_LEFT:
+ case PRESET_CENTER_LEFT:
+ case PRESET_TOP_WIDE:
+ case PRESET_BOTTOM_WIDE:
+ case PRESET_LEFT_WIDE:
+ case PRESET_HCENTER_WIDE:
+ case PRESET_WIDE:
+ set_anchor(MARGIN_LEFT, ANCHOR_BEGIN, p_keep_margin);
+ break;
+
+ case PRESET_CENTER_TOP:
+ case PRESET_CENTER_BOTTOM:
+ case PRESET_CENTER:
+ case PRESET_VCENTER_WIDE:
+ set_anchor(MARGIN_LEFT, 0.5, p_keep_margin);
+ break;
+
+ case PRESET_TOP_RIGHT:
+ case PRESET_BOTTOM_RIGHT:
+ case PRESET_CENTER_RIGHT:
+ case PRESET_RIGHT_WIDE:
+ set_anchor(MARGIN_LEFT, ANCHOR_END, p_keep_margin);
+ break;
+ }
+
+ // Top
+ switch (p_preset) {
+ case PRESET_TOP_LEFT:
+ case PRESET_TOP_RIGHT:
+ case PRESET_CENTER_TOP:
+ case PRESET_LEFT_WIDE:
+ case PRESET_RIGHT_WIDE:
+ case PRESET_TOP_WIDE:
+ case PRESET_VCENTER_WIDE:
+ case PRESET_WIDE:
+ set_anchor(MARGIN_TOP, ANCHOR_BEGIN, p_keep_margin);
+ break;
+
+ case PRESET_CENTER_LEFT:
+ case PRESET_CENTER_RIGHT:
+ case PRESET_CENTER:
+ case PRESET_HCENTER_WIDE:
+ set_anchor(MARGIN_TOP, 0.5, p_keep_margin);
+ break;
+
+ case PRESET_BOTTOM_LEFT:
+ case PRESET_BOTTOM_RIGHT:
+ case PRESET_CENTER_BOTTOM:
+ case PRESET_BOTTOM_WIDE:
+ set_anchor(MARGIN_TOP, ANCHOR_END, p_keep_margin);
+ break;
+ }
+
+ // Right
+ switch (p_preset) {
+ case PRESET_TOP_LEFT:
+ case PRESET_BOTTOM_LEFT:
+ case PRESET_CENTER_LEFT:
+ case PRESET_LEFT_WIDE:
+ set_anchor(MARGIN_RIGHT, ANCHOR_BEGIN, p_keep_margin);
+ break;
+
+ case PRESET_CENTER_TOP:
+ case PRESET_CENTER_BOTTOM:
+ case PRESET_CENTER:
+ case PRESET_VCENTER_WIDE:
+ set_anchor(MARGIN_RIGHT, 0.5, p_keep_margin);
+ break;
+
+ case PRESET_TOP_RIGHT:
+ case PRESET_BOTTOM_RIGHT:
+ case PRESET_CENTER_RIGHT:
+ case PRESET_TOP_WIDE:
+ case PRESET_RIGHT_WIDE:
+ case PRESET_BOTTOM_WIDE:
+ case PRESET_HCENTER_WIDE:
+ case PRESET_WIDE:
+ set_anchor(MARGIN_RIGHT, ANCHOR_END, p_keep_margin);
+ break;
+ }
+
+ // Bottom
+ switch (p_preset) {
+ case PRESET_TOP_LEFT:
+ case PRESET_TOP_RIGHT:
+ case PRESET_CENTER_TOP:
+ case PRESET_TOP_WIDE:
+ set_anchor(MARGIN_BOTTOM, ANCHOR_BEGIN, p_keep_margin);
+ break;
+
+ case PRESET_CENTER_LEFT:
+ case PRESET_CENTER_RIGHT:
+ case PRESET_CENTER:
+ case PRESET_HCENTER_WIDE:
+ set_anchor(MARGIN_BOTTOM, 0.5, p_keep_margin);
+ break;
+
+ case PRESET_BOTTOM_LEFT:
+ case PRESET_BOTTOM_RIGHT:
+ case PRESET_CENTER_BOTTOM:
+ case PRESET_LEFT_WIDE:
+ case PRESET_RIGHT_WIDE:
+ case PRESET_BOTTOM_WIDE:
+ case PRESET_VCENTER_WIDE:
+ case PRESET_WIDE:
+ set_anchor(MARGIN_BOTTOM, ANCHOR_END, p_keep_margin);
+ break;
+ }
+}
+
+float Control::get_anchor(Margin p_margin) const {
return data.anchor[p_margin];
}
@@ -1523,11 +1613,13 @@ Rect2 Control::get_item_rect() const {
void Control::set_area_as_parent_rect(int p_margin) {
data.anchor[MARGIN_LEFT] = ANCHOR_BEGIN;
+ data.margin[MARGIN_LEFT] = p_margin;
data.anchor[MARGIN_TOP] = ANCHOR_BEGIN;
+ data.margin[MARGIN_TOP] = p_margin;
data.anchor[MARGIN_RIGHT] = ANCHOR_END;
+ data.margin[MARGIN_RIGHT] = -p_margin;
data.anchor[MARGIN_BOTTOM] = ANCHOR_END;
- for (int i = 0; i < 4; i++)
- data.margin[i] = p_margin;
+ data.margin[MARGIN_BOTTOM] = -p_margin;
_size_changed();
}
@@ -1595,7 +1687,7 @@ static Control *_next_control(Control *p_from) {
if (p_from->is_set_as_toplevel())
return NULL; // can't go above
- Control *parent = p_from->get_parent() ? p_from->get_parent()->cast_to<Control>() : NULL;
+ Control *parent = Object::cast_to<Control>(p_from->get_parent());
if (!parent) {
@@ -1606,7 +1698,7 @@ static Control *_next_control(Control *p_from) {
ERR_FAIL_INDEX_V(next, parent->get_child_count(), NULL);
for (int i = (next + 1); i < parent->get_child_count(); i++) {
- Control *c = parent->get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(parent->get_child(i));
if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
@@ -1629,7 +1721,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>();
+ Control *c = Object::cast_to<Control>(from->get_child(i));
if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1647,10 +1739,8 @@ Control *Control::find_next_valid_focus() const {
if (!next_child) { //nothing else.. go up and find either window or subwindow
next_child = const_cast<Control *>(this);
while (next_child && !next_child->is_set_as_toplevel()) {
- if (next_child->get_parent()) {
- next_child = next_child->get_parent()->cast_to<Control>();
- } else
- next_child = NULL;
+
+ next_child = cast_to<Control>(next_child->get_parent());
}
if (!next_child) {
@@ -1684,7 +1774,7 @@ static Control *_prev_control(Control *p_from) {
Control *child = NULL;
for (int i = p_from->get_child_count() - 1; i >= 0; i--) {
- Control *c = p_from->get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(p_from->get_child(i));
if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
@@ -1708,7 +1798,7 @@ Control *Control::find_prev_valid_focus() const {
Control *prev_child = NULL;
- if (from->is_set_as_toplevel() || !from->get_parent() || !from->get_parent()->cast_to<Control>()) {
+ if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) {
//find last of the childs
@@ -1718,7 +1808,7 @@ Control *Control::find_prev_valid_focus() const {
for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) {
- Control *c = from->get_parent()->get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i));
if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
@@ -1730,7 +1820,7 @@ Control *Control::find_prev_valid_focus() const {
if (!prev_child) {
- prev_child = from->get_parent()->cast_to<Control>();
+ prev_child = Object::cast_to<Control>(from->get_parent());
} else {
prev_child = _prev_control(prev_child);
@@ -1747,8 +1837,6 @@ Control *Control::find_prev_valid_focus() const {
}
return NULL;
-
- return NULL;
}
Control::FocusMode Control::get_focus_mode() const {
@@ -1822,14 +1910,14 @@ void Control::_modal_stack_remove() {
void Control::_propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign) {
- Control *c = p_at->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(p_at);
if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
return;
for (int i = 0; i < p_at->get_child_count(); i++) {
- CanvasItem *child = p_at->get_child(i)->cast_to<CanvasItem>();
+ CanvasItem *child = Object::cast_to<CanvasItem>(p_at->get_child(i));
if (child) {
_propagate_theme_changed(child, p_owner, p_assign);
}
@@ -1865,7 +1953,7 @@ void Control::set_theme(const Ref<Theme> &p_theme) {
_propagate_theme_changed(this, this);
} else {
- Control *parent = get_parent() ? get_parent()->cast_to<Control>() : NULL;
+ Control *parent = cast_to<Control>(get_parent());
if (parent && parent->data.theme_owner) {
_propagate_theme_changed(this, parent->data.theme_owner);
} else {
@@ -1948,7 +2036,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
Control *c = NULL;
Node *n = get_node(data.focus_neighbour[p_margin]);
if (n) {
- c = n->cast_to<Control>();
+ c = Object::cast_to<Control>(n);
if (!c) {
@@ -2005,7 +2093,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
while (base) {
- Control *c = base->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(base);
if (c) {
if (c->data.SI)
break;
@@ -2025,10 +2113,10 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest) {
- if (p_at->cast_to<Viewport>())
+ if (Object::cast_to<Viewport>(p_at))
return; //bye
- Control *c = p_at->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(p_at);
if (c && c != this && c->get_focus_mode() == FOCUS_ALL && c->is_visible_in_tree()) {
@@ -2078,7 +2166,7 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
for (int i = 0; i < p_at->get_child_count(); i++) {
Node *child = p_at->get_child(i);
- Control *childc = child->cast_to<Control>();
+ Control *childc = Object::cast_to<Control>(child);
if (childc && childc->data.SI)
continue; //subwindow, ignore
_window_find_focus_neighbour(p_dir, p_at->get_child(i), p_points, p_min, r_closest_dist, r_closest);
@@ -2273,7 +2361,7 @@ Control *Control::get_root_parent_control() const {
while (ci) {
- const Control *c = ci->cast_to<Control>();
+ const Control *c = Object::cast_to<Control>(ci);
if (c) {
root = c;
@@ -2371,11 +2459,12 @@ void Control::_bind_methods() {
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("set_anchor", "margin", "anchor", "keep_margin", "push_opposite_anchor"), &Control::set_anchor, DEFVAL(false), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("_set_anchor", "margin", "anchor"), &Control::_set_anchor);
+ ClassDB::bind_method(D_METHOD("set_anchors_preset", "preset", "keep_margin"), &Control::set_anchors_preset, DEFVAL(false));
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_anchor_and_margin", "margin", "anchor", "offset", "push_opposite_anchor"), &Control::set_anchor_and_margin, DEFVAL(false));
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_position", "pos"), &Control::set_position);
@@ -2497,10 +2586,10 @@ 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"), "_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_PROPERTYI(PropertyInfo(Variant::REAL, "anchor_left", PROPERTY_HINT_RANGE, "0,1,0.01"), "_set_anchor", "get_anchor", MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anchor_top", PROPERTY_HINT_RANGE, "0,1,0.01"), "_set_anchor", "get_anchor", MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anchor_right", PROPERTY_HINT_RANGE, "0,1,0.01"), "_set_anchor", "get_anchor", MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anchor_bottom", PROPERTY_HINT_RANGE, "0,1,0.01"), "_set_anchor", "get_anchor", MARGIN_BOTTOM);
ADD_GROUP("Margin", "margin_");
ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_LEFT);
@@ -2541,12 +2630,9 @@ void Control::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme");
ADD_GROUP("", "");
- BIND_CONSTANT(ANCHOR_BEGIN);
- BIND_CONSTANT(ANCHOR_END);
- BIND_CONSTANT(ANCHOR_CENTER);
- BIND_CONSTANT(FOCUS_NONE);
- BIND_CONSTANT(FOCUS_CLICK);
- BIND_CONSTANT(FOCUS_ALL);
+ BIND_ENUM_CONSTANT(FOCUS_NONE);
+ BIND_ENUM_CONSTANT(FOCUS_CLICK);
+ BIND_ENUM_CONSTANT(FOCUS_ALL);
BIND_CONSTANT(NOTIFICATION_RESIZED);
BIND_CONSTANT(NOTIFICATION_MOUSE_ENTER);
@@ -2556,36 +2642,56 @@ void Control::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_THEME_CHANGED);
BIND_CONSTANT(NOTIFICATION_MODAL_CLOSE);
- BIND_CONSTANT(CURSOR_ARROW);
- BIND_CONSTANT(CURSOR_IBEAM);
- BIND_CONSTANT(CURSOR_POINTING_HAND);
- BIND_CONSTANT(CURSOR_CROSS);
- BIND_CONSTANT(CURSOR_WAIT);
- BIND_CONSTANT(CURSOR_BUSY);
- BIND_CONSTANT(CURSOR_DRAG);
- BIND_CONSTANT(CURSOR_CAN_DROP);
- BIND_CONSTANT(CURSOR_FORBIDDEN);
- BIND_CONSTANT(CURSOR_VSIZE);
- BIND_CONSTANT(CURSOR_HSIZE);
- BIND_CONSTANT(CURSOR_BDIAGSIZE);
- BIND_CONSTANT(CURSOR_FDIAGSIZE);
- BIND_CONSTANT(CURSOR_MOVE);
- BIND_CONSTANT(CURSOR_VSPLIT);
- BIND_CONSTANT(CURSOR_HSPLIT);
- BIND_CONSTANT(CURSOR_HELP);
-
- BIND_CONSTANT(SIZE_EXPAND);
- BIND_CONSTANT(SIZE_FILL);
- BIND_CONSTANT(SIZE_EXPAND_FILL);
- BIND_CONSTANT(SIZE_SHRINK_CENTER);
- BIND_CONSTANT(SIZE_SHRINK_END);
-
- BIND_CONSTANT(MOUSE_FILTER_STOP);
- BIND_CONSTANT(MOUSE_FILTER_PASS);
- BIND_CONSTANT(MOUSE_FILTER_IGNORE);
-
- BIND_CONSTANT(GROW_DIRECTION_BEGIN);
- BIND_CONSTANT(GROW_DIRECTION_END);
+ BIND_ENUM_CONSTANT(CURSOR_ARROW);
+ BIND_ENUM_CONSTANT(CURSOR_IBEAM);
+ BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
+ BIND_ENUM_CONSTANT(CURSOR_CROSS);
+ BIND_ENUM_CONSTANT(CURSOR_WAIT);
+ BIND_ENUM_CONSTANT(CURSOR_BUSY);
+ BIND_ENUM_CONSTANT(CURSOR_DRAG);
+ BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
+ BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
+ BIND_ENUM_CONSTANT(CURSOR_VSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_HSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_MOVE);
+ BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HELP);
+
+ BIND_ENUM_CONSTANT(PRESET_TOP_LEFT);
+ BIND_ENUM_CONSTANT(PRESET_TOP_RIGHT);
+ BIND_ENUM_CONSTANT(PRESET_BOTTOM_LEFT);
+ BIND_ENUM_CONSTANT(PRESET_BOTTOM_RIGHT);
+ BIND_ENUM_CONSTANT(PRESET_CENTER_LEFT);
+ BIND_ENUM_CONSTANT(PRESET_CENTER_TOP);
+ BIND_ENUM_CONSTANT(PRESET_CENTER_RIGHT);
+ BIND_ENUM_CONSTANT(PRESET_CENTER_BOTTOM);
+ BIND_ENUM_CONSTANT(PRESET_CENTER);
+ BIND_ENUM_CONSTANT(PRESET_LEFT_WIDE);
+ BIND_ENUM_CONSTANT(PRESET_TOP_WIDE);
+ BIND_ENUM_CONSTANT(PRESET_RIGHT_WIDE);
+ BIND_ENUM_CONSTANT(PRESET_BOTTOM_WIDE);
+ BIND_ENUM_CONSTANT(PRESET_VCENTER_WIDE);
+ BIND_ENUM_CONSTANT(PRESET_HCENTER_WIDE);
+ BIND_ENUM_CONSTANT(PRESET_WIDE);
+
+ BIND_ENUM_CONSTANT(SIZE_EXPAND);
+ BIND_ENUM_CONSTANT(SIZE_FILL);
+ BIND_ENUM_CONSTANT(SIZE_EXPAND_FILL);
+ BIND_ENUM_CONSTANT(SIZE_SHRINK_CENTER);
+ BIND_ENUM_CONSTANT(SIZE_SHRINK_END);
+
+ BIND_ENUM_CONSTANT(MOUSE_FILTER_STOP);
+ BIND_ENUM_CONSTANT(MOUSE_FILTER_PASS);
+ BIND_ENUM_CONSTANT(MOUSE_FILTER_IGNORE);
+
+ BIND_ENUM_CONSTANT(GROW_DIRECTION_BEGIN);
+ BIND_ENUM_CONSTANT(GROW_DIRECTION_END);
+
+ BIND_ENUM_CONSTANT(ANCHOR_BEGIN);
+ BIND_ENUM_CONSTANT(ANCHOR_END);
ADD_SIGNAL(MethodInfo("resized"));
ADD_SIGNAL(MethodInfo("gui_input", PropertyInfo(Variant::OBJECT, "ev", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
@@ -2597,7 +2703,7 @@ void Control::_bind_methods() {
ADD_SIGNAL(MethodInfo("minimum_size_changed"));
ADD_SIGNAL(MethodInfo("modal_closed"));
- BIND_VMETHOD(MethodInfo("has_point:bool", PropertyInfo(Variant::VECTOR2, "point")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_point", PropertyInfo(Variant::VECTOR2, "point")));
}
Control::Control() {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 86cf8f6dbd..da5c4d0908 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -33,7 +33,7 @@
#include "math_2d.h"
#include "rid.h"
#include "scene/2d/canvas_item.h"
-#include "scene/gui/input_action.h"
+#include "scene/gui/shortcut.h"
#include "scene/main/node.h"
#include "scene/main/timer.h"
#include "scene/resources/theme.h"
@@ -51,10 +51,10 @@ class Control : public CanvasItem {
OBJ_CATEGORY("GUI Nodes");
public:
- enum AnchorType {
- ANCHOR_BEGIN,
- ANCHOR_END,
- ANCHOR_CENTER,
+ enum Anchor {
+
+ ANCHOR_BEGIN = 0,
+ ANCHOR_END = 1
};
enum GrowDirection {
@@ -105,6 +105,25 @@ public:
CURSOR_MAX
};
+ enum LayoutPreset {
+ PRESET_TOP_LEFT,
+ PRESET_TOP_RIGHT,
+ PRESET_BOTTOM_LEFT,
+ PRESET_BOTTOM_RIGHT,
+ PRESET_CENTER_LEFT,
+ PRESET_CENTER_TOP,
+ PRESET_CENTER_RIGHT,
+ PRESET_CENTER_BOTTOM,
+ PRESET_CENTER,
+ PRESET_LEFT_WIDE,
+ PRESET_TOP_WIDE,
+ PRESET_RIGHT_WIDE,
+ PRESET_BOTTOM_WIDE,
+ PRESET_VCENTER_WIDE,
+ PRESET_HCENTER_WIDE,
+ PRESET_WIDE
+ };
+
private:
struct CComparator {
@@ -122,7 +141,7 @@ private:
Size2 size_cache;
float margin[4];
- AnchorType anchor[4];
+ float anchor[4];
FocusMode focus_mode;
GrowDirection h_grow;
GrowDirection v_grow;
@@ -182,12 +201,12 @@ private:
void _window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest);
Control *_get_focus_neighbour(Margin p_margin, int p_count = 0);
- void _set_anchor(Margin p_margin, AnchorType p_anchor);
+ void _set_anchor(Margin p_margin, float p_anchor);
float _get_parent_range(int p_idx) const;
float _get_range(int p_idx) const;
- float _s2a(float p_val, AnchorType p_anchor, float p_range) const;
- float _a2s(float p_val, AnchorType p_anchor, float p_range) const;
+ float _s2a(float p_val, float p_anchor, float p_range) const;
+ float _a2s(float p_val, float p_anchor, float p_range) const;
void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign = true);
void _theme_changed();
@@ -275,10 +294,11 @@ public:
/* POSITIONING */
- void set_anchor(Margin p_margin, AnchorType p_anchor, bool p_keep_margin = false);
- void set_anchor_and_margin(Margin p_margin, AnchorType p_anchor, float p_pos);
+ void set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin = false, bool p_push_opposite_anchor = true);
+ void set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor = true);
+ void set_anchors_preset(LayoutPreset p_preset, bool p_keep_margin = false);
- AnchorType get_anchor(Margin p_margin) const;
+ float get_anchor(Margin p_margin) const;
void set_margin(Margin p_margin, float p_value);
@@ -425,11 +445,12 @@ public:
~Control();
};
-VARIANT_ENUM_CAST(Control::AnchorType);
VARIANT_ENUM_CAST(Control::FocusMode);
VARIANT_ENUM_CAST(Control::SizeFlags);
VARIANT_ENUM_CAST(Control::CursorShape);
+VARIANT_ENUM_CAST(Control::LayoutPreset);
VARIANT_ENUM_CAST(Control::MouseFilter);
VARIANT_ENUM_CAST(Control::GrowDirection);
+VARIANT_ENUM_CAST(Control::Anchor);
#endif
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index dedf44d407..140d002387 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -60,17 +60,17 @@ void WindowDialog::_fix_size() {
float right = 0;
// Check validity, because the theme could contain a different type of StyleBox
if (panel->get_class() == "StyleBoxTexture") {
- Ref<StyleBoxTexture> panel_texture = panel->cast_to<StyleBoxTexture>();
+ Ref<StyleBoxTexture> panel_texture = Object::cast_to<StyleBoxTexture>(*panel);
top = panel_texture->get_expand_margin_size(MARGIN_TOP);
left = panel_texture->get_expand_margin_size(MARGIN_LEFT);
bottom = panel_texture->get_expand_margin_size(MARGIN_BOTTOM);
right = panel_texture->get_expand_margin_size(MARGIN_RIGHT);
} else if (panel->get_class() == "StyleBoxFlat") {
- Ref<StyleBoxFlat> panel_flat = panel->cast_to<StyleBoxFlat>();
- top = panel_flat->_get_additional_border_size(MARGIN_TOP);
- left = panel_flat->_get_additional_border_size(MARGIN_LEFT);
- bottom = panel_flat->_get_additional_border_size(MARGIN_BOTTOM);
- right = panel_flat->_get_additional_border_size(MARGIN_RIGHT);
+ Ref<StyleBoxFlat> panel_flat = Object::cast_to<StyleBoxFlat>(*panel);
+ top = panel_flat->get_expand_margin_size(MARGIN_TOP);
+ left = panel_flat->get_expand_margin_size(MARGIN_LEFT);
+ bottom = panel_flat->get_expand_margin_size(MARGIN_BOTTOM);
+ right = panel_flat->get_expand_margin_size(MARGIN_RIGHT);
}
pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right));
@@ -215,7 +215,7 @@ void WindowDialog::_notification(int p_what) {
close_button->set_pressed_texture(get_icon("close", "WindowDialog"));
close_button->set_hover_texture(get_icon("close_highlight", "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")));
+ close_button->set_begin(Point2(-get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog")));
} break;
case NOTIFICATION_MOUSE_EXIT: {
@@ -227,11 +227,11 @@ void WindowDialog::_notification(int p_what) {
} break;
#ifdef TOOLS_ENABLED
case NOTIFICATION_POST_POPUP: {
- if (get_tree() && get_tree()->is_editor_hint() && EditorNode::get_singleton())
+ if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
EditorNode::get_singleton()->dim_editor(true);
} break;
case NOTIFICATION_POPUP_HIDE: {
- if (get_tree() && get_tree()->is_editor_hint() && EditorNode::get_singleton())
+ if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
EditorNode::get_singleton()->dim_editor(false);
} break;
#endif
@@ -271,7 +271,7 @@ int WindowDialog::_drag_hit_test(const Point2 &pos) const {
void WindowDialog::set_title(const String &p_title) {
- title = XL_MESSAGE(p_title);
+ title = tr(p_title);
update();
}
String WindowDialog::get_title() const {
@@ -424,7 +424,7 @@ void AcceptDialog::_update_child_rects() {
Vector2 csize(size.x - margin * 2, size.y - margin * 3 - hminsize.y - label_size.height);
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
@@ -448,7 +448,7 @@ Size2 AcceptDialog::get_minimum_size() const {
Size2 minsize = label->get_combined_minimum_size();
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
@@ -546,7 +546,7 @@ AcceptDialog::AcceptDialog() {
label->set_anchor(MARGIN_RIGHT, ANCHOR_END);
label->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
label->set_begin(Point2(margin, margin));
- label->set_end(Point2(margin, button_margin + 10));
+ label->set_end(Point2(-margin, -button_margin - 10));
//label->set_autowrap(true);
add_child(label);
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index 9d8f113caa..54cc290b05 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 74255b38bf..990c0f3d96 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -464,7 +464,7 @@ void FileDialog::update_filters() {
String flt = filters[i].get_slice(";", 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
if (desc.length())
- filter->add_item(String(XL_MESSAGE(desc)) + " ( " + flt + " )");
+ filter->add_item(String(tr(desc)) + " ( " + flt + " )");
else
filter->add_item("( " + flt + " )");
}
@@ -718,16 +718,15 @@ void FileDialog::_bind_methods() {
ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::POOL_STRING_ARRAY, "paths")));
ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
- BIND_CONSTANT(MODE_OPEN_FILE);
- BIND_CONSTANT(MODE_OPEN_FILES);
- BIND_CONSTANT(MODE_OPEN_DIR);
- BIND_CONSTANT(MODE_OPEN_ANY);
+ BIND_ENUM_CONSTANT(MODE_OPEN_FILE);
+ BIND_ENUM_CONSTANT(MODE_OPEN_FILES);
+ BIND_ENUM_CONSTANT(MODE_OPEN_DIR);
+ BIND_ENUM_CONSTANT(MODE_OPEN_ANY);
+ BIND_ENUM_CONSTANT(MODE_SAVE_FILE);
- BIND_CONSTANT(MODE_SAVE_FILE);
-
- BIND_CONSTANT(ACCESS_RESOURCES);
- BIND_CONSTANT(ACCESS_USERDATA);
- BIND_CONSTANT(ACCESS_FILESYSTEM);
+ BIND_ENUM_CONSTANT(ACCESS_RESOURCES);
+ BIND_ENUM_CONSTANT(ACCESS_USERDATA);
+ BIND_ENUM_CONSTANT(ACCESS_FILESYSTEM);
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");
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 9873a677b2..34cecfe4d0 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 22de28ea7f..c9ce5e2143 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h
index 6c4ae6fd15..026e4f783b 100644
--- a/scene/gui/gradient_edit.h
+++ b/scene/gui/gradient_edit.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index e85ef73f4e..5b00aab2ef 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "graph_edit.h"
+
#include "os/input.h"
#include "os/keyboard.h"
#include "scene/gui/box_container.h"
@@ -134,7 +135,7 @@ void GraphEdit::_update_scroll_offset() {
for (int i = 0; i < get_child_count(); i++) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -163,7 +164,7 @@ void GraphEdit::_update_scroll() {
Rect2 screen;
for (int i = 0; i < get_child_count(); i++) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -205,7 +206,7 @@ void GraphEdit::_update_scroll() {
void GraphEdit::_graph_node_raised(Node *p_gn) {
- GraphNode *gn = p_gn->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
ERR_FAIL_COND(!gn);
if (gn->is_comment()) {
move_child(gn, 0);
@@ -214,7 +215,7 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
}
int first_not_comment = 0;
for (int i = 0; i < get_child_count(); i++) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (gn && !gn->is_comment()) {
first_not_comment = i;
break;
@@ -228,7 +229,7 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
void GraphEdit::_graph_node_moved(Node *p_gn) {
- GraphNode *gn = p_gn->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
ERR_FAIL_COND(!gn);
top_layer->update();
update();
@@ -240,7 +241,7 @@ void GraphEdit::add_child_notify(Node *p_child) {
Control::add_child_notify(p_child);
top_layer->call_deferred("raise"); //top layer always on top!
- GraphNode *gn = p_child->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(p_child);
if (gn) {
gn->set_scale(Vector2(zoom, zoom));
gn->connect("offset_changed", this, "_graph_node_moved", varray(gn));
@@ -256,7 +257,7 @@ void GraphEdit::remove_child_notify(Node *p_child) {
Control::remove_child_notify(p_child);
top_layer->call_deferred("raise"); //top layer always on top!
- GraphNode *gn = p_child->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(p_child);
if (gn) {
gn->disconnect("offset_changed", this, "_graph_node_moved");
gn->disconnect("raise_request", this, "_graph_node_raised");
@@ -269,14 +270,14 @@ void GraphEdit::_notification(int p_what) {
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
- v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, vmin.width);
+ v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width);
v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
- h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, hmin.height);
+ h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height);
h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
zoom_minus->set_icon(get_icon("minus"));
@@ -345,7 +346,7 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
float grab_r = port->get_width() * 0.5 * grab_r_extend;
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -379,7 +380,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
float grab_r = port->get_width() * 0.5 * grab_r_extend;
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -395,20 +396,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
if (E->get().from == gn->get_name() && E->get().from_port == j) {
Node *to = get_node(String(E->get().to));
- if (to && to->cast_to<GraphNode>()) {
+ if (Object::cast_to<GraphNode>(to)) {
connecting_from = E->get().to;
connecting_index = E->get().to_port;
connecting_out = false;
- connecting_type = to->cast_to<GraphNode>()->get_connection_input_type(E->get().to_port);
- connecting_color = to->cast_to<GraphNode>()->get_connection_input_color(E->get().to_port);
+ connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E->get().to_port);
+ connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port);
connecting_target = false;
connecting_to = pos;
just_disconected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
to = get_node(String(connecting_from)); //maybe it was erased
- if (to && to->cast_to<GraphNode>()) {
+ if (Object::cast_to<GraphNode>(to)) {
connecting = true;
}
return;
@@ -443,20 +444,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
if (E->get().to == gn->get_name() && E->get().to_port == j) {
Node *fr = get_node(String(E->get().from));
- if (fr && fr->cast_to<GraphNode>()) {
+ if (Object::cast_to<GraphNode>(fr)) {
connecting_from = E->get().from;
connecting_index = E->get().from_port;
connecting_out = true;
- connecting_type = fr->cast_to<GraphNode>()->get_connection_output_type(E->get().from_port);
- connecting_color = fr->cast_to<GraphNode>()->get_connection_output_color(E->get().from_port);
+ connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E->get().from_port);
+ connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port);
connecting_target = false;
connecting_to = pos;
just_disconected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
fr = get_node(String(connecting_from)); //maybe it was erased
- if (fr && fr->cast_to<GraphNode>()) {
+ if (Object::cast_to<GraphNode>(fr)) {
connecting = true;
}
return;
@@ -493,7 +494,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
float grab_r = port->get_width() * 0.5 * grab_r_extend;
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -593,8 +594,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors,
void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color) {
-#if 1
-
//cubic bezier code
float diff = p_to.x - p_from.x;
float cp_offset;
@@ -621,84 +620,53 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
colors.push_back(p_to_color);
p_where->draw_polyline_colors(points, colors, 2, true);
-
-#else
-
- static const int steps = 20;
-
- //old cosine code
- Rect2 r;
- r.pos = p_from;
- r.expand_to(p_to);
- Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1);
- bool flip = sign.x * sign.y < 0;
-
- Vector2 prev;
- for (int i = 0; i <= steps; i++) {
-
- float d = i / float(steps);
- float c = -Math::cos(d * Math_PI) * 0.5 + 0.5;
- if (flip)
- c = 1.0 - c;
- Vector2 p = r.pos + Vector2(d * r.size.width, c * r.size.height);
-
- if (i > 0) {
-
- p_where->draw_line(prev, p, p_color.linear_interpolate(p_to_color, d), 2);
- }
-
- prev = p;
- }
-#endif
}
void GraphEdit::_connections_layer_draw() {
- {
- //draw connections
- List<List<Connection>::Element *> to_erase;
- for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- NodePath fromnp(E->get().from);
+ //draw connections
+ List<List<Connection>::Element *> to_erase;
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
- Node *from = get_node(fromnp);
- if (!from) {
- to_erase.push_back(E);
- continue;
- }
+ NodePath fromnp(E->get().from);
- GraphNode *gfrom = from->cast_to<GraphNode>();
+ Node *from = get_node(fromnp);
+ if (!from) {
+ to_erase.push_back(E);
+ continue;
+ }
- if (!gfrom) {
- to_erase.push_back(E);
- continue;
- }
+ GraphNode *gfrom = Object::cast_to<GraphNode>(from);
- NodePath tonp(E->get().to);
- Node *to = get_node(tonp);
- if (!to) {
- to_erase.push_back(E);
- continue;
- }
+ if (!gfrom) {
+ to_erase.push_back(E);
+ continue;
+ }
- GraphNode *gto = to->cast_to<GraphNode>();
+ NodePath tonp(E->get().to);
+ Node *to = get_node(tonp);
+ if (!to) {
+ to_erase.push_back(E);
+ continue;
+ }
- if (!gto) {
- to_erase.push_back(E);
- continue;
- }
+ GraphNode *gto = Object::cast_to<GraphNode>(to);
- Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom;
- Color color = gfrom->get_connection_output_color(E->get().from_port);
- Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom;
- Color tocolor = gto->get_connection_input_color(E->get().to_port);
- _draw_cos_line(connections_layer, frompos, topos, color, tocolor);
+ if (!gto) {
+ to_erase.push_back(E);
+ continue;
}
- while (to_erase.size()) {
- connections.erase(to_erase.front()->get());
- to_erase.pop_front();
- }
+ Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom;
+ Color color = gfrom->get_connection_output_color(E->get().from_port);
+ Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom;
+ Color tocolor = gto->get_connection_input_color(E->get().to_port);
+ _draw_cos_line(connections_layer, frompos, topos, color, tocolor);
+ }
+
+ while (to_erase.size()) {
+ connections.erase(to_erase.front()->get());
+ to_erase.pop_front();
}
}
@@ -710,7 +678,7 @@ void GraphEdit::_top_layer_draw() {
Node *fromn = get_node(connecting_from);
ERR_FAIL_COND(!fromn);
- GraphNode *from = fromn->cast_to<GraphNode>();
+ GraphNode *from = Object::cast_to<GraphNode>(fromn);
ERR_FAIL_COND(!from);
Vector2 pos;
if (connecting_out)
@@ -744,7 +712,7 @@ void GraphEdit::set_selected(Node *p_child) {
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -767,7 +735,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
//drag_accum+=Vector2(mm->get_relative().x,mm->get_relative().y);
drag_accum = get_local_mouse_pos() - drag_origin;
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (gn && gn->is_selected()) {
Vector2 pos = (gn->get_drag_from() * zoom + drag_accum) / zoom;
@@ -791,7 +759,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -816,7 +784,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
box_selecting = false;
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
@@ -837,7 +805,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (!just_selected && drag_accum == Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
//deselect current node
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (gn) {
Rect2 r = gn->get_rect();
@@ -853,7 +821,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
emit_signal("_begin_node_move");
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (gn && gn->is_selected())
gn->set_drag(false);
}
@@ -874,7 +842,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn_selected = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn_selected = Object::cast_to<GraphNode>(get_child(i));
if (gn_selected) {
if (gn_selected->is_resizing())
@@ -898,7 +866,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
just_selected = !gn->is_selected();
if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
- GraphNode *o_gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i));
if (o_gn)
o_gn->set_selected(o_gn == gn);
}
@@ -906,7 +874,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
gn->set_selected(true);
for (int i = 0; i < get_child_count(); i++) {
- GraphNode *o_gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i));
if (!o_gn)
continue;
if (o_gn->is_selected())
@@ -926,7 +894,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn || !gn->is_selected())
continue;
@@ -937,7 +905,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn || !gn->is_selected())
continue;
@@ -948,7 +916,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index e908829d5f..4656b50133 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index b9062295b5..8730be0c06 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -96,7 +96,7 @@ void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || c->is_set_as_toplevel())
continue;
@@ -122,7 +122,7 @@ void GraphNode::_resort() {
Size2 minsize;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -144,7 +144,7 @@ void GraphNode::_resort() {
cache_y.clear();
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -375,7 +375,7 @@ Size2 GraphNode::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -462,7 +462,7 @@ void GraphNode::_connpos_update() {
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -710,9 +710,9 @@ void GraphNode::_bind_methods() {
ADD_SIGNAL(MethodInfo("close_request"));
ADD_SIGNAL(MethodInfo("resize_request", PropertyInfo(Variant::VECTOR2, "new_minsize")));
- BIND_CONSTANT(OVERLAY_DISABLED);
- BIND_CONSTANT(OVERLAY_BREAKPOINT);
- BIND_CONSTANT(OVERLAY_POSITION);
+ BIND_ENUM_CONSTANT(OVERLAY_DISABLED);
+ BIND_ENUM_CONSTANT(OVERLAY_BREAKPOINT);
+ BIND_ENUM_CONSTANT(OVERLAY_POSITION);
}
GraphNode::GraphNode() {
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index a7d9e8ddb0..416d711aab 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 06a58d69b2..5dd5667f46 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -51,7 +51,7 @@ void GridContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
@@ -109,7 +109,7 @@ void GridContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
@@ -184,7 +184,7 @@ Size2 GridContainer::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index aaa6a295ff..45e26ed48e 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 484051f546..9bad871ef9 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -339,7 +339,7 @@ void ItemList::set_same_column_width(bool p_enable) {
update();
shape_changed = true;
}
-int ItemList::is_same_column_width() const {
+bool ItemList::is_same_column_width() const {
return same_column_width;
}
@@ -736,10 +736,10 @@ void ItemList::_notification(int p_what) {
Ref<StyleBox> bg = get_stylebox("bg");
int mw = scroll_bar->get_minimum_size().x;
- scroll_bar->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, mw + bg->get_margin(MARGIN_RIGHT));
- scroll_bar->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, bg->get_margin(MARGIN_RIGHT));
+ scroll_bar->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -mw + bg->get_margin(MARGIN_RIGHT));
+ scroll_bar->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -bg->get_margin(MARGIN_RIGHT));
scroll_bar->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, bg->get_margin(MARGIN_TOP));
- scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, bg->get_margin(MARGIN_BOTTOM));
+ scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -bg->get_margin(MARGIN_BOTTOM));
Size2 size = get_size();
@@ -1374,10 +1374,11 @@ void ItemList::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "icon_mode", PROPERTY_HINT_ENUM, "Top,Left"), "set_icon_mode", "get_icon_mode");
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "icon_scale"), "set_icon_scale", "get_icon_scale");
- BIND_CONSTANT(ICON_MODE_TOP);
- BIND_CONSTANT(ICON_MODE_LEFT);
- BIND_CONSTANT(SELECT_SINGLE);
- BIND_CONSTANT(SELECT_MULTI);
+ BIND_ENUM_CONSTANT(ICON_MODE_TOP);
+ BIND_ENUM_CONSTANT(ICON_MODE_LEFT);
+
+ BIND_ENUM_CONSTANT(SELECT_SINGLE);
+ BIND_ENUM_CONSTANT(SELECT_MULTI);
ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "index")));
ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::VECTOR2, "atpos")));
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 137eff8885..8166975408 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -169,9 +169,9 @@ public:
int get_fixed_column_width() const;
void set_same_column_width(bool p_enable);
- int is_same_column_width() const;
+ bool is_same_column_width() const;
- void set_max_text_lines(int p_amount);
+ void set_max_text_lines(int p_lines);
int get_max_text_lines() const;
void set_max_columns(int p_amount);
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 874156821e..5fe3dd0129 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -63,7 +63,7 @@ void Label::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- String new_text = XL_MESSAGE(text);
+ String new_text = tr(text);
if (new_text == xl_text)
return; //nothing new
xl_text = new_text;
@@ -493,7 +493,10 @@ void Label::regenerate_word_cache() {
minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1));
}
- minimum_size_changed();
+ if (!autowrap || !clip) {
+ //helps speed up some labels that may change a lot, as no resizing is requested. Do not change.
+ minimum_size_changed();
+ }
word_cache_dirty = false;
}
@@ -526,7 +529,7 @@ void Label::set_text(const String &p_string) {
if (text == p_string)
return;
text = p_string;
- xl_text = XL_MESSAGE(p_string);
+ xl_text = tr(p_string);
word_cache_dirty = true;
if (percent_visible < 1)
visible_chars = get_total_character_count() * percent_visible;
@@ -641,15 +644,15 @@ void Label::_bind_methods() {
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);
- BIND_CONSTANT(ALIGN_RIGHT);
- BIND_CONSTANT(ALIGN_FILL);
+ BIND_ENUM_CONSTANT(ALIGN_LEFT);
+ BIND_ENUM_CONSTANT(ALIGN_CENTER);
+ BIND_ENUM_CONSTANT(ALIGN_RIGHT);
+ BIND_ENUM_CONSTANT(ALIGN_FILL);
- BIND_CONSTANT(VALIGN_TOP);
- BIND_CONSTANT(VALIGN_CENTER);
- BIND_CONSTANT(VALIGN_BOTTOM);
- BIND_CONSTANT(VALIGN_FILL);
+ BIND_ENUM_CONSTANT(VALIGN_TOP);
+ BIND_ENUM_CONSTANT(VALIGN_CENTER);
+ BIND_ENUM_CONSTANT(VALIGN_BOTTOM);
+ BIND_ENUM_CONSTANT(VALIGN_FILL);
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");
diff --git a/scene/gui/label.h b/scene/gui/label.h
index dce68f4422..7c1905af7d 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index c1784fb7ba..66b4e6cec1 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -534,7 +534,7 @@ void LineEdit::_notification(int p_what) {
switch (p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
- if (get_tree()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
cursor_set_blink_enabled(EDITOR_DEF("text_editor/cursor/caret_blink", false));
cursor_set_blink_speed(EDITOR_DEF("text_editor/cursor/caret_blink_speed", 0.65));
@@ -991,7 +991,7 @@ String LineEdit::get_text() const {
void LineEdit::set_placeholder(String p_text) {
- placeholder = XL_MESSAGE(p_text);
+ placeholder = tr(p_text);
update();
}
@@ -1352,18 +1352,18 @@ void LineEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text")));
ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text")));
- BIND_CONSTANT(ALIGN_LEFT);
- BIND_CONSTANT(ALIGN_CENTER);
- BIND_CONSTANT(ALIGN_RIGHT);
- BIND_CONSTANT(ALIGN_FILL);
-
- BIND_CONSTANT(MENU_CUT);
- BIND_CONSTANT(MENU_COPY);
- BIND_CONSTANT(MENU_PASTE);
- BIND_CONSTANT(MENU_CLEAR);
- BIND_CONSTANT(MENU_SELECT_ALL);
- BIND_CONSTANT(MENU_UNDO);
- BIND_CONSTANT(MENU_MAX);
+ BIND_ENUM_CONSTANT(ALIGN_LEFT);
+ BIND_ENUM_CONSTANT(ALIGN_CENTER);
+ BIND_ENUM_CONSTANT(ALIGN_RIGHT);
+ BIND_ENUM_CONSTANT(ALIGN_FILL);
+
+ BIND_ENUM_CONSTANT(MENU_CUT);
+ BIND_ENUM_CONSTANT(MENU_COPY);
+ BIND_ENUM_CONSTANT(MENU_PASTE);
+ BIND_ENUM_CONSTANT(MENU_CLEAR);
+ BIND_ENUM_CONSTANT(MENU_SELECT_ALL);
+ BIND_ENUM_CONSTANT(MENU_UNDO);
+ BIND_ENUM_CONSTANT(MENU_MAX);
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");
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index 73c5a46937..52a4a29a33 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -177,7 +177,7 @@ public:
virtual Size2 get_minimum_size() const;
- void set_expand_to_text_length(bool p_len);
+ void set_expand_to_text_length(bool p_enabled);
bool get_expand_to_text_length() const;
virtual bool is_text_field() const;
@@ -186,5 +186,6 @@ public:
};
VARIANT_ENUM_CAST(LineEdit::Align);
+VARIANT_ENUM_CAST(LineEdit::MenuItems);
#endif
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 9cb67b75e2..9fe94fc464 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -130,9 +130,9 @@ void LinkButton::_bind_methods() {
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);
+ BIND_ENUM_CONSTANT(UNDERLINE_MODE_ALWAYS);
+ BIND_ENUM_CONSTANT(UNDERLINE_MODE_ON_HOVER);
+ BIND_ENUM_CONSTANT(UNDERLINE_MODE_NEVER);
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/link_button.h b/scene/gui/link_button.h
index 98a3dc66f6..386eb452ae 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 2bc9db529b..14991f5d44 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -40,7 +40,7 @@ Size2 MarginContainer::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -74,7 +74,7 @@ void MarginContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h
index 1cdb3a36cc..9703d9ebe0 100644
--- a/scene/gui/margin_container.h
+++ b/scene/gui/margin_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 93284f2b6c..ac450616d6 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -33,7 +33,7 @@
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
- if (p_event->is_pressed() && !p_event->is_echo() && (p_event->cast_to<InputEventKey>() || p_event->cast_to<InputEventJoypadButton>() || p_event->cast_to<InputEventAction>())) {
+ if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
if (!get_parent() || !is_visible_in_tree() || is_disabled())
return;
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 6bb23452dd..c7f1d976ff 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 25ac8d5259..b4d0799945 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -185,21 +185,21 @@ void OptionButton::clear() {
current = -1;
}
-void OptionButton::_select(int p_idx, bool p_emit) {
+void OptionButton::_select(int p_which, bool p_emit) {
- if (p_idx < 0)
+ if (p_which < 0)
return;
- if (p_idx == current)
+ if (p_which == current)
return;
- ERR_FAIL_INDEX(p_idx, popup->get_item_count());
+ ERR_FAIL_INDEX(p_which, popup->get_item_count());
for (int i = 0; i < popup->get_item_count(); i++) {
- popup->set_item_checked(i, i == p_idx);
+ popup->set_item_checked(i, i == p_which);
}
- current = p_idx;
+ current = p_which;
set_text(popup->get_item_text(current));
set_icon(popup->get_item_icon(current));
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index db921b8b97..a06c540678 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index f3c6142f9e..536b655f75 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index eac8f2d4e8..cc7ca47319 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index 86874f7cfd..a0c75d1330 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -41,7 +41,7 @@ Size2 PanelContainer::get_minimum_size() const {
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
@@ -90,7 +90,7 @@ void PanelContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h
index f8f1fb6494..5d8f1ee64b 100644
--- a/scene/gui/panel_container.h
+++ b/scene/gui/panel_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp
index 249090830d..6b2deeb209 100644
--- a/scene/gui/patch_9_rect.cpp
+++ b/scene/gui/patch_9_rect.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -82,9 +82,9 @@ void NinePatchRect::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "axis_stretch_horizontal", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_h_axis_stretch_mode", "get_h_axis_stretch_mode");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "axis_stretch_vertical", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_v_axis_stretch_mode", "get_v_axis_stretch_mode");
- BIND_CONSTANT(AXIS_STRETCH_MODE_STRETCH);
- BIND_CONSTANT(AXIS_STRETCH_MODE_TILE);
- BIND_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT);
+ BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_STRETCH);
+ BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE);
+ BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT);
}
void NinePatchRect::set_texture(const Ref<Texture> &p_tex) {
diff --git a/scene/gui/patch_9_rect.h b/scene/gui/patch_9_rect.h
index 602a6d22bf..4cf93e4c05 100644
--- a/scene/gui/patch_9_rect.h
+++ b/scene/gui/patch_9_rect.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -67,7 +67,7 @@ public:
void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
- void set_draw_center(bool p_enable);
+ void set_draw_center(bool p_draw);
bool get_draw_center() const;
void set_h_axis_stretch_mode(AxisStretchMode p_mode);
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 8979e0f111..5a2a552943 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "popup.h"
+
+#include "engine.h"
#include "os/keyboard.h"
void Popup::_gui_input(Ref<InputEvent> p_event) {
@@ -48,7 +50,7 @@ void Popup::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
//small helper to make editing of these easier in editor
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
set_as_toplevel(false);
}
#endif
@@ -57,17 +59,10 @@ void Popup::_notification(int p_what) {
void Popup::_fix_size() {
-#if 0
- Point2 pos = get_position();
- Size2 size = get_size();
- Point2 window_size = window==this ? get_parent_area_size() :window->get_size();
-#else
-
Point2 pos = get_global_position();
Size2 size = get_size();
Point2 window_size = get_viewport_rect().size;
-#endif
if (pos.x + size.width > window_size.width)
pos.x = window_size.width - size.width;
if (pos.x < 0)
@@ -77,14 +72,8 @@ void Popup::_fix_size() {
pos.y = window_size.height - size.height;
if (pos.y < 0)
pos.y = 0;
-#if 0
- if (pos!=get_pos())
- set_position(pos);
-#else
if (pos != get_position())
set_global_position(pos);
-
-#endif
}
void Popup::set_as_minsize() {
@@ -93,7 +82,7 @@ void Popup::set_as_minsize() {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (!c->is_visible())
@@ -108,13 +97,10 @@ void Popup::set_as_minsize() {
float margin_begin = c->get_margin(m_beg);
float margin_end = c->get_margin(m_end);
- AnchorType anchor_begin = c->get_anchor(m_beg);
- AnchorType anchor_end = c->get_anchor(m_end);
+ float anchor_begin = c->get_anchor(m_beg);
+ float anchor_end = c->get_anchor(m_end);
- if (anchor_begin == ANCHOR_BEGIN)
- minsize[j] += margin_begin;
- if (anchor_end == ANCHOR_END)
- minsize[j] += margin_end;
+ minsize[j] += margin_begin * (ANCHOR_END - anchor_begin) + margin_end * anchor_end;
}
total_minsize.width = MAX(total_minsize.width, minsize.width);
@@ -130,7 +116,7 @@ void Popup::popup_centered_minsize(const Size2 &p_minsize) {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (!c->is_visible())
@@ -145,13 +131,10 @@ void Popup::popup_centered_minsize(const Size2 &p_minsize) {
float margin_begin = c->get_margin(m_beg);
float margin_end = c->get_margin(m_end);
- AnchorType anchor_begin = c->get_anchor(m_beg);
- AnchorType anchor_end = c->get_anchor(m_end);
+ float anchor_begin = c->get_anchor(m_beg);
+ float anchor_end = c->get_anchor(m_end);
- if (anchor_begin == ANCHOR_BEGIN)
- minsize[j] += margin_begin;
- if (anchor_end == ANCHOR_END)
- minsize[j] += margin_end;
+ minsize[j] += margin_begin * (ANCHOR_END - anchor_begin) + margin_end * anchor_end;
}
total_minsize.width = MAX(total_minsize.width, minsize.width);
@@ -209,15 +192,15 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
popped_up = true;
}
-void Popup::popup(const Rect2 &bounds) {
+void Popup::popup(const Rect2 &p_bounds) {
emit_signal("about_to_show");
show_modal(exclusive);
// Fit the popup into the optionally provided bounds.
- if (!bounds.has_no_area()) {
- set_position(bounds.position);
- set_size(bounds.size);
+ if (!p_bounds.has_no_area()) {
+ set_position(p_bounds.position);
+ set_size(p_bounds.size);
}
_fix_size();
@@ -253,6 +236,7 @@ void Popup::_bind_methods() {
ADD_SIGNAL(MethodInfo("popup_hide"));
ADD_GROUP("Popup", "popup_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "popup_exclusive"), "set_exclusive", "is_exclusive");
+
BIND_CONSTANT(NOTIFICATION_POST_POPUP);
BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
}
@@ -282,9 +266,10 @@ void PopupPanel::set_child_rect(Control *p_child) {
Ref<StyleBox> p = get_stylebox("panel");
p_child->set_area_as_parent_rect();
- for (int i = 0; i < 4; i++) {
- p_child->set_margin(Margin(i), p->get_margin(Margin(i)));
- }
+ p_child->set_margin(MARGIN_LEFT, p->get_margin(MARGIN_LEFT));
+ p_child->set_margin(MARGIN_RIGHT, -p->get_margin(MARGIN_RIGHT));
+ p_child->set_margin(MARGIN_TOP, p->get_margin(MARGIN_TOP));
+ p_child->set_margin(MARGIN_BOTTOM, -p->get_margin(MARGIN_BOTTOM));
}
void PopupPanel::_notification(int p_what) {
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 0543ae1937..6739c580f2 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 46aa0e5054..f3711b86b6 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -168,7 +168,7 @@ void PopupMenu::_activate_submenu(int over) {
Node *n = get_node(items[over].submenu);
ERR_EXPLAIN("item subnode does not exist: " + items[over].submenu);
ERR_FAIL_COND(!n);
- Popup *pm = n->cast_to<Popup>();
+ Popup *pm = Object::cast_to<Popup>(n);
ERR_EXPLAIN("item subnode is not a Popup: " + items[over].submenu);
ERR_FAIL_COND(!pm);
if (pm->is_visible_in_tree())
@@ -187,7 +187,7 @@ void PopupMenu::_activate_submenu(int over) {
pm->set_position(pos);
pm->popup();
- PopupMenu *pum = pm->cast_to<PopupMenu>();
+ PopupMenu *pum = Object::cast_to<PopupMenu>(pm);
if (pum) {
pr.position -= pum->get_global_position();
@@ -395,7 +395,7 @@ void PopupMenu::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
for (int i = 0; i < items.size(); i++) {
- items[i].xl_text = XL_MESSAGE(items[i].text);
+ items[i].xl_text = tr(items[i].text);
}
minimum_size_changed();
@@ -513,7 +513,7 @@ void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label,
Item item;
item.icon = p_icon;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
items.push_back(item);
@@ -523,7 +523,7 @@ void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
items.push_back(item);
@@ -534,7 +534,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
Item item;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.ID = p_ID;
item.submenu = p_submenu;
items.push_back(item);
@@ -546,7 +546,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_
Item item;
item.icon = p_icon;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
item.checkable = true;
@@ -557,7 +557,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel
Item item;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
item.checkable = true;
@@ -628,7 +628,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) {
ERR_FAIL_INDEX(p_idx, items.size());
items[p_idx].text = p_text;
- items[p_idx].xl_text = XL_MESSAGE(p_text);
+ items[p_idx].xl_text = tr(p_text);
update();
}
@@ -869,7 +869,7 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo
if (!n)
continue;
- PopupMenu *pm = n->cast_to<PopupMenu>();
+ PopupMenu *pm = Object::cast_to<PopupMenu>(n);
if (!pm)
continue;
@@ -891,14 +891,14 @@ void PopupMenu::activate_item(int p_item) {
//hide all parent PopupMenue's
Node *next = get_parent();
- PopupMenu *pop = next->cast_to<PopupMenu>();
+ PopupMenu *pop = Object::cast_to<PopupMenu>(next);
while (pop) {
// We close all parents that are chained together,
// with hide_on_item_selection enabled
if ((items[p_item].checkable && hide_on_checkable_item_selection && pop->is_hide_on_checkable_item_selection()) || (!items[p_item].checkable && hide_on_item_selection && pop->is_hide_on_item_selection())) {
pop->hide();
next = next->get_parent();
- pop = next->cast_to<PopupMenu>();
+ pop = Object::cast_to<PopupMenu>(next);
} else {
// Break out of loop when the next parent has
// hide_on_item_selection disabled
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index cbfe7873e6..c9e9c8e311 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -140,7 +140,7 @@ public:
uint32_t get_item_accelerator(int p_idx) const;
Variant get_item_metadata(int p_idx) const;
bool is_item_disabled(int p_idx) const;
- String get_item_submenu(int p_ID) const;
+ String get_item_submenu(int p_idx) const;
bool is_item_separator(int p_idx) const;
bool is_item_checkable(int p_idx) const;
String get_item_tooltip(int p_idx) const;
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 13d368d253..6953d03384 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index 1121a78aab..c5a9252123 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 68afe8150a..1dbec6e5a1 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -170,7 +170,7 @@ double Range::get_as_ratio() const {
void Range::_share(Node *p_range) {
- Range *r = p_range->cast_to<Range>();
+ Range *r = Object::cast_to<Range>(p_range);
ERR_FAIL_COND(!r);
share(r);
}
diff --git a/scene/gui/range.h b/scene/gui/range.h
index fdcbbb09ee..daa8af824a 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp
index 400ff299a9..e2f4abe04a 100644
--- a/scene/gui/reference_rect.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,13 +29,15 @@
/*************************************************************************/
#include "reference_rect.h"
+#include "engine.h"
+
void ReferenceRect::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
draw_style_box(get_stylebox("border"), Rect2(Point2(), get_size()));
}
}
diff --git a/scene/gui/reference_rect.h b/scene/gui/reference_rect.h
index b118425eb6..9b826a1145 100644
--- a/scene/gui/reference_rect.h
+++ b/scene/gui/reference_rect.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 0e4004c27b..a3f116c883 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -594,7 +594,7 @@ void RichTextLabel::_update_scroll() {
main->first_invalid_line = 0;
scroll_w = vscroll->get_combined_minimum_size().width;
vscroll->show();
- vscroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, scroll_w);
+ vscroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -scroll_w);
_validate_line_caches(main);
} else {
@@ -1915,26 +1915,26 @@ void RichTextLabel::_bind_methods() {
ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta")));
- BIND_CONSTANT(ALIGN_LEFT);
- BIND_CONSTANT(ALIGN_CENTER);
- BIND_CONSTANT(ALIGN_RIGHT);
- BIND_CONSTANT(ALIGN_FILL);
-
- BIND_CONSTANT(LIST_NUMBERS);
- BIND_CONSTANT(LIST_LETTERS);
- BIND_CONSTANT(LIST_DOTS);
-
- BIND_CONSTANT(ITEM_FRAME);
- BIND_CONSTANT(ITEM_TEXT);
- BIND_CONSTANT(ITEM_IMAGE);
- BIND_CONSTANT(ITEM_NEWLINE);
- BIND_CONSTANT(ITEM_FONT);
- BIND_CONSTANT(ITEM_COLOR);
- BIND_CONSTANT(ITEM_UNDERLINE);
- BIND_CONSTANT(ITEM_ALIGN);
- BIND_CONSTANT(ITEM_INDENT);
- BIND_CONSTANT(ITEM_LIST);
- BIND_CONSTANT(ITEM_META);
+ BIND_ENUM_CONSTANT(ALIGN_LEFT);
+ BIND_ENUM_CONSTANT(ALIGN_CENTER);
+ BIND_ENUM_CONSTANT(ALIGN_RIGHT);
+ BIND_ENUM_CONSTANT(ALIGN_FILL);
+
+ BIND_ENUM_CONSTANT(LIST_NUMBERS);
+ BIND_ENUM_CONSTANT(LIST_LETTERS);
+ BIND_ENUM_CONSTANT(LIST_DOTS);
+
+ BIND_ENUM_CONSTANT(ITEM_FRAME);
+ BIND_ENUM_CONSTANT(ITEM_TEXT);
+ BIND_ENUM_CONSTANT(ITEM_IMAGE);
+ BIND_ENUM_CONSTANT(ITEM_NEWLINE);
+ BIND_ENUM_CONSTANT(ITEM_FONT);
+ BIND_ENUM_CONSTANT(ITEM_COLOR);
+ BIND_ENUM_CONSTANT(ITEM_UNDERLINE);
+ BIND_ENUM_CONSTANT(ITEM_ALIGN);
+ BIND_ENUM_CONSTANT(ITEM_INDENT);
+ BIND_ENUM_CONSTANT(ITEM_LIST);
+ BIND_ENUM_CONSTANT(ITEM_META);
}
void RichTextLabel::set_visible_characters(int p_visible) {
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 409a8f6b3f..74bf180b5d 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -296,7 +296,7 @@ public:
void push_align(Align p_align);
void push_indent(int p_level);
void push_list(ListType p_list);
- void push_meta(const Variant &p_data);
+ void push_meta(const Variant &p_meta);
void push_table(int p_columns);
void set_table_column_expand(int p_column, bool p_expand, int p_ratio = 1);
int get_current_table_column() const;
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index bd66cd2745..16d1b320b7 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,9 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scroll_bar.h"
+
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
+
bool ScrollBar::focus_by_default = false;
void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
@@ -40,6 +42,11 @@ void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
+ Ref<InputEventMouseMotion> m = p_event;
+ if (!m.is_valid() || drag.active) {
+ emit_signal("scrolling");
+ }
+
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
@@ -98,7 +105,18 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (ofs < grabber_ofs) {
- set_value(get_value() - get_page());
+ if (scrolling) {
+ target_scroll = target_scroll - get_page();
+ } else {
+ target_scroll = get_value() - get_page();
+ }
+
+ if (smooth_scroll_enabled) {
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ set_value(target_scroll);
+ }
return;
}
@@ -111,8 +129,18 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
drag.value_at_click = get_as_ratio();
update();
} else {
+ if (scrolling) {
+ target_scroll = target_scroll + get_page();
+ } else {
+ target_scroll = get_value() + get_page();
+ }
- set_value(get_value() + get_page());
+ if (smooth_scroll_enabled) {
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ set_value(target_scroll);
+ }
}
} else {
@@ -122,8 +150,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
}
}
- Ref<InputEventMouseMotion> m = p_event;
-
if (m.is_valid()) {
accept_event();
@@ -233,7 +259,14 @@ void ScrollBar::_notification(int p_what) {
Ref<Texture> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement");
Ref<Texture> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment");
Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll");
- Ref<StyleBox> grabber = (drag.active || highlight == HIGHLIGHT_RANGE) ? get_stylebox("grabber_highlight") : get_stylebox("grabber");
+
+ Ref<StyleBox> grabber;
+ if (drag.active)
+ grabber = get_stylebox("grabber_pressed");
+ else if (highlight == HIGHLIGHT_RANGE)
+ grabber = get_stylebox("grabber_highlight");
+ else
+ grabber = get_stylebox("grabber");
Point2 ofs;
@@ -284,7 +317,7 @@ void ScrollBar::_notification(int p_what) {
if (has_node(drag_slave_path)) {
Node *n = get_node(drag_slave_path);
- drag_slave = n->cast_to<Control>();
+ drag_slave = Object::cast_to<Control>(n);
}
if (drag_slave) {
@@ -304,7 +337,22 @@ void ScrollBar::_notification(int p_what) {
if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (drag_slave_touching) {
+ if (scrolling) {
+ if (get_value() != target_scroll) {
+ double target = target_scroll - get_value();
+ double dist = sqrt(target * target);
+ double vel = ((target / dist) * 500) * get_fixed_process_delta_time();
+
+ if (vel >= dist) {
+ set_value(target_scroll);
+ } else {
+ set_value(get_value() + vel);
+ }
+ } else {
+ scrolling = false;
+ set_fixed_process(false);
+ }
+ } else if (drag_slave_touching) {
if (drag_slave_touching_deaccel) {
@@ -617,7 +665,7 @@ void ScrollBar::set_drag_slave(const NodePath &p_path) {
if (has_node(p_path)) {
Node *n = get_node(p_path);
- drag_slave = n->cast_to<Control>();
+ drag_slave = Object::cast_to<Control>(n);
}
if (drag_slave) {
@@ -632,138 +680,14 @@ NodePath ScrollBar::get_drag_slave() const {
return drag_slave_path;
}
-#if 0
-
-void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) {
-
- // wheel!
-
- if (b->get_button_index()==BUTTON_WHEEL_UP && b->is_pressed()) {
-
- if (orientation==VERTICAL)
- set_val( get_val() - get_page() / 4.0 );
- else
- set_val( get_val() + get_page() / 4.0 );
-
- }
- if (b->get_button_index()==BUTTON_WHEEL_DOWN && b->is_pressed()) {
-
- if (orientation==HORIZONTAL)
- set_val( get_val() - get_page() / 4.0 );
- else
- set_val( get_val() + get_page() / 4.0 );
- }
-
- if (b->get_button_index()!=BUTTON_LEFT)
- return;
-
- if (b->is_pressed()) {
-
- int ofs = orientation==VERTICAL ? p_pos.y : p_pos.x ;
- int grabber_ofs = get_grabber_offset();
- int grabber_size = get_grabber_size();
-
- if ( ofs < grabber_ofs ) {
-
- set_val( get_val() - get_page() );
-
- } else if (ofs > grabber_ofs + grabber_size ) {
-
- set_val( get_val() + get_page() );
-
- } else {
-
-
- drag.active=true;
- drag.pos_at_click=get_click_pos(p_pos);
- drag.value_at_click=get_unit_value();
- }
-
-
- } else {
-
- drag.active=false;
- }
-
+void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
+ smooth_scroll_enabled = p_enable;
}
-void ScrollBar::mouse_motion(const Point2& p_pos, const Point2& p_rel, int b->get_button_index()_mask) {
-
- if (!drag.active)
- return;
-
- double value_ofs=drag.value_at_click+(get_click_pos(p_pos)-drag.pos_at_click);
-
-
- value_ofs=value_ofs*( get_max() - get_min() );
- if (value_ofs<get_min())
- value_ofs=get_min();
- if (value_ofs>(get_max()-get_page()))
- value_ofs=get_max()-get_page();
- if (get_val()==value_ofs)
- return; //don't bother if the value is the same
-
- set_val( value_ofs );
-
-}
-
-bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b->is_pressed(),bool p_repeat,int p_modifier_mask) {
-
- if (!b->is_pressed())
- return false;
-
- switch (p_scan_code) {
- case KEY_LEFT: {
-
- if (orientation!=HORIZONTAL)
- return false;
- set_val( get_val() - get_step() );
-
- } break;
- case KEY_RIGHT: {
-
- if (orientation!=HORIZONTAL)
- return false;
- set_val( get_val() + get_step() );
-
- } break;
- case KEY_UP: {
-
- if (orientation!=VERTICAL)
- return false;
-
- set_val( get_val() - get_step() );
-
-
- } break;
- case KEY_DOWN: {
-
- if (orientation!=VERTICAL)
- return false;
- set_val( get_val() + get_step() );
-
- } break;
- case KEY_HOME: {
-
- set_val( get_min() );
-
- } break;
- case KEY_END: {
-
- set_val( get_max() );
-
- } break;
-
- default:
- return false;
-
- }
-
- return true;
+bool ScrollBar::is_smooth_scroll_enabled() const {
+ return smooth_scroll_enabled;
}
-#endif
-
void ScrollBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input);
@@ -772,6 +696,8 @@ void ScrollBar::_bind_methods() {
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_SIGNAL(MethodInfo("scrolling"));
+
ADD_PROPERTY(PropertyInfo(Variant::REAL, "custom_step", PROPERTY_HINT_RANGE, "-1,4096"), "set_custom_step", "get_custom_step");
}
@@ -788,6 +714,10 @@ ScrollBar::ScrollBar(Orientation p_orientation) {
drag_slave_touching = false;
drag_slave_touching_deaccel = false;
+ scrolling = false;
+ target_scroll = 0;
+ smooth_scroll_enabled = false;
+
if (focus_by_default)
set_focus_mode(FOCUS_ALL);
set_step(0);
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index 8310e12590..373483a8a0 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -83,6 +83,10 @@ class ScrollBar : public Range {
bool drag_slave_touching_deaccel;
bool click_handled;
+ bool scrolling;
+ double target_scroll;
+ bool smooth_scroll_enabled;
+
void _drag_slave_exit();
void _drag_slave_input(const Ref<InputEvent> &p_input);
@@ -100,6 +104,9 @@ public:
void set_drag_slave(const NodePath &p_path);
NodePath get_drag_slave() const;
+ void set_smooth_scroll_enabled(bool p_enable);
+ bool is_smooth_scroll_enabled() const;
+
virtual Size2 get_minimum_size() const;
ScrollBar(Orientation p_orientation = VERTICAL);
~ScrollBar();
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index cc1a637d2b..e182e491d3 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -40,7 +40,7 @@ Size2 ScrollContainer::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -187,14 +187,14 @@ void ScrollContainer::_update_scrollbar_pos() {
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
- v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, vmin.width);
+ v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width);
v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
- h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, hmin.height);
+ h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height);
h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
h_scroll->raise();
@@ -220,7 +220,7 @@ void ScrollContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -423,7 +423,7 @@ String ScrollContainer::get_configuration_warning() const {
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c)
continue;
if (c->is_set_as_toplevel())
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index e5df3e5e1c..9076be0d72 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 3b00ab4605..3db234f7cc 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/separator.h b/scene/gui/separator.h
index 9a5fe2ac66..be2f1e8e77 100644
--- a/scene/gui/separator.h
+++ b/scene/gui/separator.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/input_action.cpp b/scene/gui/shortcut.cpp
index c08059a049..f37410e77b 100644
--- a/scene/gui/input_action.cpp
+++ b/scene/gui/shortcut.cpp
@@ -1,9 +1,9 @@
/*************************************************************************/
-/* input_action.cpp */
+/* shortcut.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,7 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "input_action.h"
+#include "shortcut.h"
+
#include "os/keyboard.h"
void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
@@ -52,61 +53,6 @@ String ShortCut::get_as_text() const {
return shortcut->as_text();
else
return "None";
-#if 0
- switch (shortcut.type) {
-
- case Ref<InputEvent>::NONE: {
-
- return "None";
- } break;
- case Ref<InputEvent>::KEY: {
-
- String str;
- if (shortcut->get_shift())
- str += RTR("Shift+");
- if (shortcut->get_alt())
- str += RTR("Alt+");
- if (shortcut->get_control())
- str += RTR("Ctrl+");
- if (shortcut->get_metakey())
- str += RTR("Meta+");
-
- str += keycode_get_string(shortcut->get_scancode()).capitalize();
-
- return str;
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
-
- String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Button") + " " + itos(shortcut.joy_button->get_button_index());
- str += ".";
-
- return str;
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
-
- String str = RTR("Device") + " " + itos(shortcut.device) + ", ";
- switch (shortcut->get_button_index()) {
- case BUTTON_LEFT: str += RTR("Left Button."); break;
- case BUTTON_RIGHT: str += RTR("Right Button."); break;
- case BUTTON_MIDDLE: str += RTR("Middle Button."); break;
- case BUTTON_WHEEL_UP: str += RTR("Wheel Up."); break;
- case BUTTON_WHEEL_DOWN: str += RTR("Wheel Down."); break;
- default: str += RTR("Button") + " " + itos(shortcut->get_button_index()) + ".";
- }
-
- return str;
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- int ax = shortcut.joy_motion.axis;
- String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Axis") + " " + itos(ax) + ".";
-
- return str;
- } break;
- }
-
- return "";
-#endif
}
bool ShortCut::is_valid() const {
diff --git a/scene/gui/input_action.h b/scene/gui/shortcut.h
index 6d13d8bd40..8d85bb920f 100644
--- a/scene/gui/input_action.h
+++ b/scene/gui/shortcut.h
@@ -1,9 +1,9 @@
/*************************************************************************/
-/* input_action.h */
+/* shortcut.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef INPUTACTION_H
-#define INPUTACTION_H
+#ifndef SHORTCUT_H
+#define SHORTCUT_H
#include "os/input_event.h"
#include "resource.h"
@@ -45,7 +45,7 @@ protected:
public:
void set_shortcut(const Ref<InputEvent> &p_shortcut);
Ref<InputEvent> get_shortcut() const;
- bool is_shortcut(const Ref<InputEvent> &p_Event) const;
+ bool is_shortcut(const Ref<InputEvent> &p_event) const;
bool is_valid() const;
String get_as_text() const;
@@ -53,4 +53,4 @@ public:
ShortCut();
};
-#endif // INPUTACTION_H
+#endif // SHORTCUT_H
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 9ba17ce34f..4661f54526 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index f3cf3c6f48..a2334a69fc 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index c5b9df15b9..f462989f53 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -192,7 +192,7 @@ void SpinBox::_notification(int p_what) {
int w = updown->get_width();
if (w != last_w) {
- line_edit->set_margin(MARGIN_RIGHT, w);
+ line_edit->set_margin(MARGIN_RIGHT, -w);
last_w = w;
}
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index 683ed0c344..0c562bd744 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index e3dad08809..4420a936d2 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -44,7 +44,7 @@ Control *SplitContainer::_getch(int p_idx) const {
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
@@ -410,9 +410,9 @@ void SplitContainer::_bind_methods() {
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);
- BIND_CONSTANT(DRAGGER_HIDDEN_COLLAPSED);
+ BIND_ENUM_CONSTANT(DRAGGER_VISIBLE);
+ BIND_ENUM_CONSTANT(DRAGGER_HIDDEN);
+ BIND_ENUM_CONSTANT(DRAGGER_HIDDEN_COLLAPSED);
}
SplitContainer::SplitContainer(bool p_vertical) {
diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h
index 87a210f24c..8ec21b5eaa 100644
--- a/scene/gui/split_container.h
+++ b/scene/gui/split_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 4b8b180b0e..461ae3444b 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -230,8 +230,8 @@ void TabContainer::_notification(int p_what) {
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());
+ Control *control = Object::cast_to<Control>(tabs[i + first_tab_cache]);
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT);
int top_margin = tab_style->get_margin(MARGIN_TOP);
@@ -293,13 +293,13 @@ void TabContainer::_notification(int p_what) {
}
int TabContainer::_get_tab_width(int p_index) const {
- Control *control = _get_tabs()[p_index]->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(_get_tabs()[p_index]);
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());
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int width = font->get_string_size(text).width;
// Add space for a tab icon.
@@ -332,7 +332,7 @@ 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>();
+ Control *control = Object::cast_to<Control>(get_child(i));
if (!control || control->is_toplevel_control())
continue;
@@ -350,7 +350,7 @@ void TabContainer::add_child_notify(Node *p_child) {
Control::add_child_notify(p_child);
- Control *c = p_child->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(p_child);
if (!c)
return;
if (c->is_set_as_toplevel())
@@ -371,8 +371,10 @@ void TabContainer::add_child_notify(Node *p_child) {
if (tabs_visible)
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)));
+ c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
+ c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
+ c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
+ c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM)));
update();
p_child->connect("renamed", this, "_child_renamed_callback");
@@ -402,8 +404,10 @@ void TabContainer::set_current_tab(int p_current) {
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(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
+ c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
+ c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
+ c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM)));
} else
c->hide();
@@ -544,11 +548,11 @@ Ref<Texture> TabContainer::get_tab_icon(int p_tab) const {
return Ref<Texture>();
}
-void TabContainer::set_tab_disabled(int p_tab, bool p_enabled) {
+void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) {
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
- child->set_meta("_tab_disabled", p_enabled);
+ child->set_meta("_tab_disabled", p_disabled);
update();
}
@@ -612,7 +616,7 @@ Size2 TabContainer::get_minimum_size() const {
void TabContainer::set_popup(Node *p_popup) {
ERR_FAIL_NULL(p_popup);
- popup = p_popup->cast_to<Popup>();
+ popup = Object::cast_to<Popup>(p_popup);
update();
}
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 1105c6b298..be59a16b3f 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -54,7 +54,7 @@ private:
bool tabs_visible;
bool buttons_visible_cache;
TabAlign align;
- Control *_get_tab(int idx) const;
+ Control *_get_tab(int p_idx) const;
int _get_top_margin() const;
Popup *popup;
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index acffbbc499..085f6de6b8 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -815,15 +815,15 @@ void Tabs::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "tab_close_display_policy", PROPERTY_HINT_ENUM, "Show Never,Show Active Only,Show Always"), "set_tab_close_display_policy", "get_tab_close_display_policy");
- BIND_CONSTANT(ALIGN_LEFT);
- BIND_CONSTANT(ALIGN_CENTER);
- BIND_CONSTANT(ALIGN_RIGHT);
- BIND_CONSTANT(ALIGN_MAX);
+ BIND_ENUM_CONSTANT(ALIGN_LEFT);
+ BIND_ENUM_CONSTANT(ALIGN_CENTER);
+ BIND_ENUM_CONSTANT(ALIGN_RIGHT);
+ BIND_ENUM_CONSTANT(ALIGN_MAX);
- BIND_CONSTANT(CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
- BIND_CONSTANT(CLOSE_BUTTON_SHOW_ALWAYS);
- BIND_CONSTANT(CLOSE_BUTTON_SHOW_NEVER);
- BIND_CONSTANT(CLOSE_BUTTON_MAX);
+ BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
+ BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_ALWAYS);
+ BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_NEVER);
+ BIND_ENUM_CONSTANT(CLOSE_BUTTON_MAX);
}
Tabs::Tabs() {
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 86ad128dcd..73fa40bbb8 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 7b0d14c1a9..7a9daea73e 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,13 +27,12 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "text_edit.h"
+
+#include "message_queue.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
-
-#include "message_queue.h"
#include "project_settings.h"
#include "scene/main/viewport.h"
@@ -215,8 +214,8 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) {
- Map<int, ColorRegionInfo> *cri = NULL;
- ERR_FAIL_INDEX_V(p_line, text.size(), *cri); //enjoy your crash
+ static Map<int, ColorRegionInfo> cri;
+ ERR_FAIL_INDEX_V(p_line, text.size(), cri);
if (text[p_line].width_cache == -1) {
_update_line_cache(p_line);
@@ -338,6 +337,11 @@ void TextEdit::_update_scrollbars() {
v_scroll->show();
v_scroll->set_max(total_rows);
v_scroll->set_page(visible_rows);
+ if (smooth_scroll_enabled) {
+ v_scroll->set_step(0.25);
+ } else {
+ v_scroll->set_step(1);
+ }
if (fabs(v_scroll->get_value() - (double)cursor.line_ofs) >= 1) {
v_scroll->set_value(cursor.line_ofs);
@@ -420,6 +424,24 @@ void TextEdit::_notification(int p_what) {
draw_caret = false;
update();
} break;
+ case NOTIFICATION_FIXED_PROCESS: {
+ if (scrolling && v_scroll->get_value() != target_v_scroll) {
+ double target_y = target_v_scroll - v_scroll->get_value();
+ double dist = sqrt(target_y * target_y);
+ double vel = ((target_y / dist) * v_scroll_speed) * get_fixed_process_delta_time();
+
+ if (vel >= dist) {
+ v_scroll->set_value(target_v_scroll);
+ scrolling = false;
+ set_fixed_process(false);
+ } else {
+ v_scroll->set_value(v_scroll->get_value() + vel);
+ }
+ } else {
+ scrolling = false;
+ set_fixed_process(false);
+ }
+ } break;
case NOTIFICATION_DRAW: {
if ((!has_focus() && !menu->has_focus()) || !window_has_focus) {
@@ -436,7 +458,7 @@ void TextEdit::_notification(int p_what) {
int line_number_char_count = 0;
{
- int lc = text.size() + 1;
+ int lc = text.size();
cache.line_number_w = 0;
while (lc) {
cache.line_number_w += 1;
@@ -454,6 +476,7 @@ void TextEdit::_notification(int p_what) {
_update_scrollbars();
RID ci = get_canvas_item();
+ VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width;
int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
//let's do it easy for now:
@@ -463,7 +486,7 @@ void TextEdit::_notification(int p_what) {
int ascent = cache.font->get_ascent();
- int visible_rows = get_visible_rows();
+ int visible_rows = get_visible_rows() + 1;
int tab_w = cache.font->get_char_size(' ').width * indent_size;
@@ -674,7 +697,11 @@ void TextEdit::_notification(int p_what) {
int char_margin = xmargin_beg - cursor.x_ofs;
int char_ofs = 0;
- int ofs_y = i * get_row_height() + cache.line_spacing / 2;
+ int ofs_y = (i * get_row_height() + cache.line_spacing / 2);
+ if (smooth_scroll_enabled) {
+ ofs_y -= (v_scroll->get_value() - cursor.line_ofs) * get_row_height();
+ }
+
bool prev_is_char = false;
bool prev_is_number = false;
bool in_keyword = false;
@@ -1028,6 +1055,8 @@ void TextEdit::_notification(int p_what) {
if (cursor.column == j && cursor.line == line && block_caret && draw_caret && !insert_mode) {
color = cache.caret_background_color;
+ } else if (!syntax_coloring && block_caret) {
+ color = cache.font_color;
}
if (str[j] >= 32) {
@@ -1498,7 +1527,7 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co
float rows = p_mouse.y;
rows -= cache.style_normal->get_margin(MARGIN_TOP);
rows /= get_row_height();
- int row = cursor.line_ofs + rows;
+ int row = cursor.line_ofs + (rows + (v_scroll->get_value() - cursor.line_ofs));
if (row < 0)
row = 0;
@@ -1564,10 +1593,43 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->is_pressed()) {
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
- v_scroll->set_value(v_scroll->get_value() - (3 * mb->get_factor()));
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll - (3 * mb->get_factor()));
+ } else {
+ target_v_scroll = (v_scroll->get_value() - (3 * mb->get_factor()));
+ }
+
+ if (smooth_scroll_enabled) {
+ if (target_v_scroll <= 0) {
+ target_v_scroll = 0;
+ }
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) {
- v_scroll->set_value(v_scroll->get_value() + (3 * mb->get_factor()));
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll + (3 * mb->get_factor()));
+ } else {
+ target_v_scroll = (v_scroll->get_value() + (3 * mb->get_factor()));
+ }
+
+ if (smooth_scroll_enabled) {
+ int max_v_scroll = get_line_count() - 1;
+ if (!scroll_past_end_of_file_enabled) {
+ max_v_scroll -= get_visible_rows() - 1;
+ }
+
+ if (target_v_scroll > max_v_scroll) {
+ target_v_scroll = max_v_scroll;
+ }
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_LEFT) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
@@ -2052,14 +2114,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
//keep indentation
int space_count = 0;
for (int i = 0; i < text[cursor.line].length(); i++) {
- if (text[cursor.line][i] == '\t') {
+ if (text[cursor.line][i] == '\t' && cursor.column > 0) {
if (indent_using_spaces) {
ins += space_indent;
} else {
ins += "\t";
}
space_count = 0;
- } else if (text[cursor.line][i] == ' ') {
+ } else if (text[cursor.line][i] == ' ' && cursor.column > 0) {
space_count++;
if (space_count == indent_size) {
@@ -2248,6 +2310,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#endif
bool prev_char = false;
int cc = cursor.column;
+
+ if (cc == 0 && cursor.line > 0) {
+ cursor_set_line(cursor.line - 1);
+ cursor_set_column(text[cursor.line].length());
+ break;
+ }
+
while (cc > 0) {
bool ischar = _is_text_char(text[cursor.line][cc - 1]);
@@ -2305,6 +2374,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#endif
bool prev_char = false;
int cc = cursor.column;
+
+ if (cc == text[cursor.line].length() && cursor.line < text.size() - 1) {
+ cursor_set_line(cursor.line + 1);
+ cursor_set_column(0);
+ break;
+ }
+
while (cc < text[cursor.line].length()) {
bool ischar = _is_text_char(text[cursor.line][cc]);
@@ -2659,6 +2735,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
else
undo();
} break;
+ case KEY_Y: {
+
+ if (!k->get_command()) {
+ scancode_handled = false;
+ break;
+ }
+
+ redo();
+ } break;
case KEY_V: {
if (readonly) {
break;
@@ -2803,6 +2888,8 @@ void TextEdit::_post_shift_selection() {
}
void TextEdit::_scroll_lines_up() {
+ scrolling = false;
+
// adjust the vertical scroll
if (get_v_scroll() > 0) {
set_v_scroll(get_v_scroll() - 1);
@@ -2815,6 +2902,8 @@ void TextEdit::_scroll_lines_up() {
}
void TextEdit::_scroll_lines_down() {
+ scrolling = false;
+
// calculate the maximum vertical scroll position
int max_v_scroll = get_line_count() - 1;
if (!scroll_past_end_of_file_enabled) {
@@ -2933,7 +3022,7 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li
}
}
-void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r_end_line, int *r_end_column) {
+void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r_end_line, int *r_end_char) {
if (!setting_text)
idle_detect->start();
@@ -2946,8 +3035,8 @@ void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r
_base_insert_text(p_line, p_char, p_text, retline, retchar);
if (r_end_line)
*r_end_line = retline;
- if (r_end_column)
- *r_end_column = retchar;
+ if (r_end_char)
+ *r_end_char = retchar;
if (!undo_enabled)
return;
@@ -3079,6 +3168,7 @@ int TextEdit::get_visible_rows() const {
return total;
}
void TextEdit::adjust_viewport_to_cursor() {
+ scrolling = false;
if (cursor.line_ofs > cursor.line)
cursor.line_ofs = cursor.line;
@@ -3095,10 +3185,15 @@ void TextEdit::adjust_viewport_to_cursor() {
visible_rows -= ((h_scroll->get_combined_minimum_size().height - 1) / get_row_height());
if (cursor.line >= (cursor.line_ofs + visible_rows))
- cursor.line_ofs = cursor.line - visible_rows + 1;
+ cursor.line_ofs = cursor.line - visible_rows;
if (cursor.line < cursor.line_ofs)
cursor.line_ofs = cursor.line;
+ if (cursor.line_ofs + visible_rows > text.size() && !scroll_past_end_of_file_enabled) {
+ cursor.line_ofs = text.size() - visible_rows;
+ v_scroll->set_value(text.size() - visible_rows);
+ }
+
int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]);
if (cursor_x > (cursor.x_ofs + visible_width))
@@ -3118,6 +3213,7 @@ void TextEdit::adjust_viewport_to_cursor() {
}
void TextEdit::center_viewport_to_cursor() {
+ scrolling = false;
if (cursor.line_ofs > cursor.line)
cursor.line_ofs = cursor.line;
@@ -3236,6 +3332,10 @@ bool TextEdit::cursor_is_block_mode() const {
return block_caret;
}
+void TextEdit::_v_scroll_input() {
+ scrolling = false;
+}
+
void TextEdit::_scroll_moved(double p_to_val) {
if (updating_scrolls)
@@ -3566,10 +3666,10 @@ void TextEdit::cut() {
String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
OS::get_singleton()->set_clipboard(clipboard);
- cursor_set_line(selection.from_line);
+ _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
+ cursor_set_line(selection.from_line); // set afterwards else it causes the view to be offset
cursor_set_column(selection.from_column);
- _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
selection.active = false;
selection.selecting_mode = Selection::MODE_NONE;
update();
@@ -3579,9 +3679,6 @@ void TextEdit::cut() {
void TextEdit::copy() {
- if (!selection.active)
- return;
-
if (!selection.active) {
String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
OS::get_singleton()->set_clipboard(clipboard);
@@ -3821,11 +3918,9 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
//search through the whole documment, but start by current line
- int line = -1;
+ int line = p_from_line;
int pos = -1;
- line = p_from_line;
-
for (int i = 0; i < text.size() + 1; i++) {
//backwards is broken...
//int idx=(p_search_flags&SEARCH_BACKWARDS)?(text.size()-i):i; //do backwards seearch
@@ -4178,6 +4273,23 @@ void TextEdit::set_h_scroll(int p_scroll) {
h_scroll->set_value(p_scroll);
}
+void TextEdit::set_smooth_scroll_enabled(bool p_enable) {
+ v_scroll->set_smooth_scroll_enabled(p_enable);
+ smooth_scroll_enabled = p_enable;
+}
+
+bool TextEdit::is_smooth_scroll_enabled() const {
+ return smooth_scroll_enabled;
+}
+
+void TextEdit::set_v_scroll_speed(float p_speed) {
+ v_scroll_speed = p_speed;
+}
+
+float TextEdit::get_v_scroll_speed() const {
+ return v_scroll_speed;
+}
+
void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) {
completion_prefixes.clear();
@@ -4220,6 +4332,7 @@ void TextEdit::_cancel_completion() {
return;
completion_active = false;
+ completion_forced = false;
update();
}
@@ -4287,13 +4400,19 @@ void TextEdit::_update_completion_candidates() {
}
}
- if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) {
+ if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_forced) {
cancel = true;
}
update();
- if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !completion_prefixes.has(String::chr(l[cofs - 1]))))) {
+ bool prev_is_prefix = false;
+ if (cofs > 0 && completion_prefixes.has(String::chr(l[cofs - 1])))
+ prev_is_prefix = true;
+ if (cofs > 1 && l[cofs - 1] == ' ' && completion_prefixes.has(String::chr(l[cofs - 2]))) //check with one space before prefix, to allow indent
+ prev_is_prefix = true;
+
+ if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !prev_is_prefix))) {
//none to complete, cancel
_cancel_completion();
return;
@@ -4351,18 +4470,6 @@ void TextEdit::_update_completion_candidates() {
// The top of the list is the best match
completion_current = completion_options[0];
-
-#if 0 // even there's only one option, user still get the chance to choose using it or not
- 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()));
- _cancel_completion();
- return;
-
- }
-#endif
-
completion_enabled = true;
}
@@ -4382,6 +4489,8 @@ void TextEdit::query_code_comple() {
if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1]))))
emit_signal("request_completion");
+ else if (ofs > 1 && l[ofs - 1] == ' ' && completion_prefixes.has(String::chr(l[ofs - 2]))) //make it work with a space too, it's good enough
+ emit_signal("request_completion");
}
void TextEdit::set_code_hint(const String &p_hint) {
@@ -4393,12 +4502,13 @@ void TextEdit::set_code_hint(const String &p_hint) {
update();
}
-void TextEdit::code_complete(const Vector<String> &p_strings) {
+void TextEdit::code_complete(const Vector<String> &p_strings, bool p_forced) {
VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
raised_from_completion = true;
completion_strings = p_strings;
completion_active = true;
+ completion_forced = p_forced;
completion_current = "";
completion_index = 0;
_update_completion_candidates();
@@ -4617,10 +4727,11 @@ void TextEdit::_bind_methods() {
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);
+ ClassDB::bind_method(D_METHOD("_v_scroll_input"), &TextEdit::_v_scroll_input);
- BIND_CONSTANT(SEARCH_MATCH_CASE);
- BIND_CONSTANT(SEARCH_WHOLE_WORDS);
- BIND_CONSTANT(SEARCH_BACKWARDS);
+ BIND_ENUM_CONSTANT(SEARCH_MATCH_CASE);
+ BIND_ENUM_CONSTANT(SEARCH_WHOLE_WORDS);
+ BIND_ENUM_CONSTANT(SEARCH_BACKWARDS);
/*
ClassDB::bind_method(D_METHOD("delete_char"),&TextEdit::delete_char);
@@ -4678,6 +4789,11 @@ void TextEdit::_bind_methods() {
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(D_METHOD("set_smooth_scroll_enable", "enable"), &TextEdit::set_smooth_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("set_v_scroll_speed", "speed"), &TextEdit::set_v_scroll_speed);
+ ClassDB::bind_method(D_METHOD("get_v_scroll_speed"), &TextEdit::get_v_scroll_speed);
+
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);
@@ -4687,6 +4803,8 @@ void TextEdit::_bind_methods() {
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_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed");
ADD_GROUP("Caret", "caret_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode");
@@ -4699,13 +4817,13 @@ void TextEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo(Variant::INT, "row")));
ADD_SIGNAL(MethodInfo("symbol_lookup", PropertyInfo(Variant::STRING, "symbol"), PropertyInfo(Variant::INT, "row"), PropertyInfo(Variant::INT, "column")));
- BIND_CONSTANT(MENU_CUT);
- BIND_CONSTANT(MENU_COPY);
- BIND_CONSTANT(MENU_PASTE);
- BIND_CONSTANT(MENU_CLEAR);
- BIND_CONSTANT(MENU_SELECT_ALL);
- BIND_CONSTANT(MENU_UNDO);
- BIND_CONSTANT(MENU_MAX);
+ BIND_ENUM_CONSTANT(MENU_CUT);
+ BIND_ENUM_CONSTANT(MENU_COPY);
+ BIND_ENUM_CONSTANT(MENU_PASTE);
+ BIND_ENUM_CONSTANT(MENU_CLEAR);
+ BIND_ENUM_CONSTANT(MENU_SELECT_ALL);
+ BIND_ENUM_CONSTANT(MENU_UNDO);
+ BIND_ENUM_CONSTANT(MENU_MAX);
GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3);
}
@@ -4747,6 +4865,8 @@ TextEdit::TextEdit() {
h_scroll->connect("value_changed", this, "_scroll_moved");
v_scroll->connect("value_changed", this, "_scroll_moved");
+ v_scroll->connect("scrolling", this, "_v_scroll_input");
+
cursor_changed_dirty = false;
text_changed_dirty = false;
@@ -4776,24 +4896,6 @@ TextEdit::TextEdit() {
click_select_held->set_wait_time(0.05);
click_select_held->connect("timeout", this, "_click_selection_held");
-#if 0
- syntax_coloring=true;
- keywords["void"]=Color(0.3,0.0,0.1);
- keywords["int"]=Color(0.3,0.0,0.1);
- keywords["function"]=Color(0.3,0.0,0.1);
- keywords["class"]=Color(0.3,0.0,0.1);
- keywords["extends"]=Color(0.3,0.0,0.1);
- keywords["constructor"]=Color(0.3,0.0,0.1);
- symbol_color=Color(0.1,0.0,0.3,1.0);
-
- color_regions.push_back(ColorRegion("/*","*/",Color(0.4,0.6,0,4)));
- color_regions.push_back(ColorRegion("//","",Color(0.6,0.6,0.4)));
- color_regions.push_back(ColorRegion("\"","\"",Color(0.4,0.7,0.7)));
- color_regions.push_back(ColorRegion("'","'",Color(0.4,0.8,0.8)));
- color_regions.push_back(ColorRegion("#","",Color(0.2,1.0,0.2)));
-
-#endif
-
current_op.type = TextOperation::TYPE_NONE;
undo_enabled = true;
undo_stack_pos = NULL;
@@ -4823,6 +4925,10 @@ TextEdit::TextEdit() {
insert_mode = false;
window_has_focus = true;
select_identifiers_enabled = false;
+ smooth_scroll_enabled = false;
+ scrolling = false;
+ target_v_scroll = 0;
+ v_scroll_speed = 80;
raised_from_completion = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index afb4b1c547..68ef559f46 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -152,7 +152,7 @@ class TextEdit : public Control {
int get_line_width(int p_line) const;
int get_max_width() const;
const Map<int, ColorRegionInfo> &get_color_region_info(int p_line);
- void set(int p_line, const String &p_string);
+ void set(int p_line, const String &p_text);
void set_marked(int p_line, bool p_marked) { text[p_line].marked = p_marked; }
bool is_marked(int p_line) const { return text[p_line].marked; }
void set_breakpoint(int p_line, bool p_breakpoint) { text[p_line].breakpoint = p_breakpoint; }
@@ -205,6 +205,7 @@ class TextEdit : public Control {
Vector<String> completion_strings;
Vector<String> completion_options;
bool completion_active;
+ bool completion_forced;
String completion_current;
String completion_base;
int completion_index;
@@ -256,6 +257,11 @@ class TextEdit : public Control {
bool insert_mode;
bool select_identifiers_enabled;
+ bool smooth_scroll_enabled;
+ bool scrolling;
+ float target_v_scroll;
+ float v_scroll_speed;
+
bool raised_from_completion;
String highlighted_word;
@@ -288,12 +294,13 @@ class TextEdit : public Control {
int get_char_count();
- int get_char_pos_for(int p_px, String p_pos) const;
- int get_column_x_offset(int p_column, String p_pos);
+ int get_char_pos_for(int p_px, String p_str) const;
+ int get_column_x_offset(int p_char, String p_str);
void adjust_viewport_to_cursor();
void _scroll_moved(double);
void _update_scrollbars();
+ void _v_scroll_input();
void _click_selection_held();
void _pre_shift_selection();
@@ -320,7 +327,7 @@ class TextEdit : public Control {
/* super internal api, undo/redo builds on it */
- void _base_insert_text(int p_line, int p_column, const String &p_text, int &r_end_line, int &r_end_column);
+ void _base_insert_text(int p_line, int p_char, const String &p_text, int &r_end_line, int &r_end_column);
String _base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const;
void _base_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
@@ -339,10 +346,10 @@ class TextEdit : public Control {
protected:
virtual String get_tooltip(const Point2 &p_pos) const;
- void _insert_text(int p_line, int p_column, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL);
+ void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL);
void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
void _insert_text_at_cursor(const String &p_text);
- void _gui_input(const Ref<InputEvent> &p_input);
+ void _gui_input(const Ref<InputEvent> &p_gui_input);
void _notification(int p_what);
void _consume_pair_symbol(CharType ch);
@@ -487,6 +494,12 @@ public:
int get_h_scroll() const;
void set_h_scroll(int p_scroll);
+ void set_smooth_scroll_enabled(bool p_enable);
+ bool is_smooth_scroll_enabled() const;
+
+ void set_v_scroll_speed(float p_speed);
+ float get_v_scroll_speed() const;
+
uint32_t get_version() const;
uint32_t get_saved_version() const;
void tag_saved_version();
@@ -510,7 +523,7 @@ public:
void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
void set_completion(bool p_enabled, const Vector<String> &p_prefixes);
- void code_complete(const Vector<String> &p_strings);
+ void code_complete(const Vector<String> &p_strings, bool p_forced = false);
void set_code_hint(const String &p_hint);
void query_code_comple();
@@ -528,4 +541,7 @@ public:
~TextEdit();
};
+VARIANT_ENUM_CAST(TextEdit::MenuItems);
+VARIANT_ENUM_CAST(TextEdit::SearchFlags);
+
#endif // TEXT_EDIT_H
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 00849c4e5a..77bc876201 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -208,13 +208,13 @@ void TextureButton::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "expand", PROPERTY_HINT_RESOURCE_TYPE, "bool"), "set_expand", "get_expand");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode");
- BIND_CONSTANT(STRETCH_SCALE);
- BIND_CONSTANT(STRETCH_TILE);
- 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);
+ BIND_ENUM_CONSTANT(STRETCH_SCALE);
+ BIND_ENUM_CONSTANT(STRETCH_TILE);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_CENTERED);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT_CENTERED);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT_COVERED);
}
void TextureButton::set_normal_texture(const Ref<Texture> &p_normal) {
@@ -286,8 +286,8 @@ void TextureButton::set_expand(bool p_expand) {
update();
}
-void TextureButton::set_stretch_mode(StretchMode p_mode) {
- stretch_mode = p_mode;
+void TextureButton::set_stretch_mode(StretchMode p_stretch_mode) {
+ stretch_mode = p_stretch_mode;
update();
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 9c31912a32..94f372decf 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -69,7 +69,7 @@ public:
void set_hover_texture(const Ref<Texture> &p_hover);
void set_disabled_texture(const Ref<Texture> &p_disabled);
void set_focused_texture(const Ref<Texture> &p_focused);
- void set_click_mask(const Ref<BitMap> &p_image);
+ void set_click_mask(const Ref<BitMap> &p_click_mask);
Ref<Texture> get_normal_texture() const;
Ref<Texture> get_pressed_texture() const;
@@ -81,7 +81,7 @@ public:
bool get_expand() const;
void set_expand(bool p_expand);
- void set_stretch_mode(StretchMode stretch_mode);
+ void set_stretch_mode(StretchMode p_stretch_mode);
StretchMode get_stretch_mode() const;
TextureButton();
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 081c7ddb73..aad7c6b96b 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "texture_progress.h"
+#include "engine.h"
+
void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) {
under = p_texture;
@@ -55,9 +57,33 @@ Ref<Texture> TextureProgress::get_over_texture() const {
return over;
}
+void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) {
+ ERR_FAIL_INDEX(p_margin, 4);
+ stretch_margin[p_margin] = p_size;
+ update();
+ minimum_size_changed();
+}
+
+int TextureProgress::get_stretch_margin(Margin p_margin) const {
+ ERR_FAIL_INDEX_V(p_margin, 4, 0);
+ return stretch_margin[p_margin];
+}
+
+void TextureProgress::set_nine_patch_stretch(bool p_stretch) {
+ nine_patch_stretch = p_stretch;
+ update();
+ minimum_size_changed();
+}
+
+bool TextureProgress::get_nine_patch_stretch() const {
+ return nine_patch_stretch;
+}
+
Size2 TextureProgress::get_minimum_size() const {
- if (under.is_valid())
+ if (nine_patch_stretch)
+ return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]);
+ else if (under.is_valid())
return under->get_size();
else if (over.is_valid())
return over->get_size();
@@ -120,80 +146,165 @@ Point2 TextureProgress::get_relative_center() {
return p;
}
+void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio) {
+ Vector2 texture_size = p_texture->get_size();
+ Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]);
+ Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]);
+
+ Rect2 src_rect = Rect2(Point2(), texture_size);
+ Rect2 dst_rect = Rect2(Point2(), get_size());
+
+ if (p_ratio < 1.0) {
+ // Drawing a partially-filled 9-patch is a little tricky -
+ // texture is divided by 3 sections toward fill direction,
+ // then middle section is streching while the other two aren't.
+
+ double width_total = 0.0;
+ double width_texture = 0.0;
+ double first_section_size = 0.0;
+ double last_section_size = 0.0;
+ switch (mode) {
+ case FILL_LEFT_TO_RIGHT:
+ case FILL_RIGHT_TO_LEFT: {
+ width_total = dst_rect.size.x;
+ width_texture = texture_size.x;
+ first_section_size = topleft.x;
+ last_section_size = bottomright.x;
+ } break;
+ case FILL_TOP_TO_BOTTOM:
+ case FILL_BOTTOM_TO_TOP: {
+ width_total = dst_rect.size.y;
+ width_texture = texture_size.y;
+ first_section_size = topleft.y;
+ last_section_size = bottomright.y;
+ } break;
+ }
+
+ double width_filled = width_total * p_ratio;
+ double middle_section_size = MAX(0.0, width_texture - first_section_size - last_section_size);
+
+ middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size)));
+ last_section_size = MAX(0.0, last_section_size - (width_total - width_filled));
+ width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
+
+ switch (mode) {
+ case FILL_LEFT_TO_RIGHT: {
+ src_rect.size.x = width_texture;
+ dst_rect.size.x = width_filled;
+ bottomright.x = last_section_size;
+ } break;
+ case FILL_RIGHT_TO_LEFT: {
+ src_rect.position.x += src_rect.size.x - width_texture;
+ src_rect.size.x = width_texture;
+ dst_rect.position.x += width_total - width_filled;
+ dst_rect.size.x = width_filled;
+ topleft.x = last_section_size;
+ } break;
+ case FILL_TOP_TO_BOTTOM: {
+ src_rect.size.y = width_texture;
+ dst_rect.size.y = width_filled;
+ bottomright.y = last_section_size;
+ } break;
+ case FILL_BOTTOM_TO_TOP: {
+ src_rect.position.y += src_rect.size.y - width_texture;
+ src_rect.size.y = width_texture;
+ dst_rect.position.y += width_total - width_filled;
+ dst_rect.size.y = width_filled;
+ topleft.y = last_section_size;
+ } break;
+ }
+ }
+
+ RID ci = get_canvas_item();
+ VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright);
+}
+
void TextureProgress::_notification(int p_what) {
const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
switch (p_what) {
case NOTIFICATION_DRAW: {
- if (under.is_valid())
- draw_texture(under, Point2());
- if (progress.is_valid()) {
- Size2 s = progress->get_size();
- switch (mode) {
- case FILL_LEFT_TO_RIGHT: {
- 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_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_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_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_as_ratio() * rad_max_degrees / 360;
- if (val == 1) {
- Rect2 region = Rect2(Point2(), s);
+ if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP)) {
+ if (under.is_valid()) {
+ draw_nine_patch_stretched(under, FILL_LEFT_TO_RIGHT, 1.0);
+ }
+ if (progress.is_valid()) {
+ draw_nine_patch_stretched(progress, mode, get_as_ratio());
+ }
+ if (over.is_valid()) {
+ draw_nine_patch_stretched(over, FILL_LEFT_TO_RIGHT, 1.0);
+ }
+ } else {
+ if (under.is_valid())
+ draw_texture(under, Point2());
+ if (progress.is_valid()) {
+ Size2 s = progress->get_size();
+ switch (mode) {
+ case FILL_LEFT_TO_RIGHT: {
+ 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_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y));
draw_texture_rect_region(progress, region, region);
- } else if (val != 0) {
- Array pts;
- float direction = mode == FILL_CLOCKWISE ? 1 : -1;
- float start = rad_init_angle / 360;
- float end = start + direction * val;
- pts.append(start);
- pts.append(end);
- float from = MIN(start, end);
- float to = MAX(start, end);
- for (int i = 0; i < 12; i++)
- if (corners[i] > from && corners[i] < to)
- pts.append(corners[i]);
- pts.sort();
- Vector<Point2> uvs;
- Vector<Point2> points;
- uvs.push_back(get_relative_center());
- points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
- for (int i = 0; i < pts.size(); i++) {
- Point2 uv = unit_val_to_uv(pts[i]);
- if (uvs.find(uv) >= 0)
- continue;
- uvs.push_back(uv);
- points.push_back(Point2(uv.x * s.x, uv.y * s.y));
+ } break;
+ case FILL_TOP_TO_BOTTOM: {
+ 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_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_as_ratio() * rad_max_degrees / 360;
+ if (val == 1) {
+ Rect2 region = Rect2(Point2(), s);
+ draw_texture_rect_region(progress, region, region);
+ } else if (val != 0) {
+ Array pts;
+ float direction = mode == FILL_CLOCKWISE ? 1 : -1;
+ float start = rad_init_angle / 360;
+ float end = start + direction * val;
+ pts.append(start);
+ pts.append(end);
+ float from = MIN(start, end);
+ float to = MAX(start, end);
+ for (int i = 0; i < 12; i++)
+ if (corners[i] > from && corners[i] < to)
+ pts.append(corners[i]);
+ pts.sort();
+ Vector<Point2> uvs;
+ Vector<Point2> points;
+ uvs.push_back(get_relative_center());
+ points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
+ for (int i = 0; i < pts.size(); i++) {
+ Point2 uv = unit_val_to_uv(pts[i]);
+ if (uvs.find(uv) >= 0)
+ continue;
+ uvs.push_back(uv);
+ points.push_back(Point2(uv.x * s.x, uv.y * s.y));
+ }
+ draw_polygon(points, Vector<Color>(), uvs, progress);
}
- draw_polygon(points, Vector<Color>(), uvs, progress);
- }
- if (get_tree()->is_editor_hint()) {
- Point2 p = progress->get_size();
- p.x *= get_relative_center().x;
- p.y *= get_relative_center().y;
- p = p.floor();
- draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
- draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
- }
- } break;
- default:
- 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)));
+ if (Engine::get_singleton()->is_editor_hint()) {
+ Point2 p = progress->get_size();
+ p.x *= get_relative_center().x;
+ p.y *= get_relative_center().y;
+ p = p.floor();
+ draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
+ draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
+ }
+ } break;
+ default:
+ 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)));
+ }
}
+ if (over.is_valid())
+ draw_texture(over, Point2());
}
- if (over.is_valid())
- draw_texture(over, Point2());
} break;
}
@@ -263,6 +374,12 @@ void TextureProgress::_bind_methods() {
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);
+ ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgress::set_stretch_margin);
+ ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgress::get_stretch_margin);
+
+ ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgress::set_nine_patch_stretch);
+ ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch);
+
ADD_GROUP("Textures", "texture_");
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");
@@ -272,13 +389,19 @@ void TextureProgress::_bind_methods() {
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);
- BIND_CONSTANT(FILL_TOP_TO_BOTTOM);
- BIND_CONSTANT(FILL_BOTTOM_TO_TOP);
- BIND_CONSTANT(FILL_CLOCKWISE);
- BIND_CONSTANT(FILL_COUNTER_CLOCKWISE);
+ ADD_GROUP("Stretch", "stretch_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "nine_patch_stretch"), "set_nine_patch_stretch", "get_nine_patch_stretch");
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_LEFT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_RIGHT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_BOTTOM);
+
+ BIND_ENUM_CONSTANT(FILL_LEFT_TO_RIGHT);
+ BIND_ENUM_CONSTANT(FILL_RIGHT_TO_LEFT);
+ BIND_ENUM_CONSTANT(FILL_TOP_TO_BOTTOM);
+ BIND_ENUM_CONSTANT(FILL_BOTTOM_TO_TOP);
+ BIND_ENUM_CONSTANT(FILL_CLOCKWISE);
+ BIND_ENUM_CONSTANT(FILL_COUNTER_CLOCKWISE);
}
TextureProgress::TextureProgress() {
@@ -287,4 +410,10 @@ TextureProgress::TextureProgress() {
rad_center_off = Point2();
rad_max_degrees = 360;
set_mouse_filter(MOUSE_FILTER_PASS);
+
+ nine_patch_stretch = false;
+ stretch_margin[MARGIN_LEFT] = 0;
+ stretch_margin[MARGIN_RIGHT] = 0;
+ stretch_margin[MARGIN_BOTTOM] = 0;
+ stretch_margin[MARGIN_TOP] = 0;
}
diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h
index c0c2779cf9..04096d35e3 100644
--- a/scene/gui/texture_progress.h
+++ b/scene/gui/texture_progress.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -75,6 +75,12 @@ public:
void set_over_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_over_texture() const;
+ void set_stretch_margin(Margin p_margin, int p_size);
+ int get_stretch_margin(Margin p_margin) const;
+
+ void set_nine_patch_stretch(bool p_stretch);
+ bool get_nine_patch_stretch() const;
+
Size2 get_minimum_size() const;
TextureProgress();
@@ -84,9 +90,14 @@ private:
float rad_init_angle;
float rad_max_degrees;
Point2 rad_center_off;
+ bool nine_patch_stretch;
+ int stretch_margin[4];
Point2 unit_val_to_uv(float val);
Point2 get_relative_center();
+ void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio);
};
+VARIANT_ENUM_CAST(TextureProgress::FillMode);
+
#endif // TEXTURE_PROGRESS_H
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index 92a3db6a74..38f90fe7b5 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -112,14 +112,14 @@ void TextureRect::_bind_methods() {
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);
- 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);
+ BIND_ENUM_CONSTANT(STRETCH_SCALE_ON_EXPAND);
+ BIND_ENUM_CONSTANT(STRETCH_SCALE);
+ BIND_ENUM_CONSTANT(STRETCH_TILE);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_CENTERED);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT_CENTERED);
+ BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT_COVERED);
}
void TextureRect::set_texture(const Ref<Texture> &p_tex) {
diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h
index dcc6c3f9bd..8a2b715488 100644
--- a/scene/gui/texture_rect.h
+++ b/scene/gui/texture_rect.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp
index 5fc4b6ecf8..4dfa3d8f37 100644
--- a/scene/gui/tool_button.cpp
+++ b/scene/gui/tool_button.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h
index d243b5559f..4c5ea685de 100644
--- a/scene/gui/tool_button.h
+++ b/scene/gui/tool_button.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index fa499ff277..5e15bceb7d 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tree.h"
+
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
@@ -752,12 +753,12 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_disable_folding", "disable"), &TreeItem::set_disable_folding);
ClassDB::bind_method(D_METHOD("is_folding_disabled"), &TreeItem::is_folding_disabled);
- BIND_CONSTANT(CELL_MODE_STRING);
- BIND_CONSTANT(CELL_MODE_CHECK);
- BIND_CONSTANT(CELL_MODE_RANGE);
- BIND_CONSTANT(CELL_MODE_RANGE_EXPRESSION);
- BIND_CONSTANT(CELL_MODE_ICON);
- BIND_CONSTANT(CELL_MODE_CUSTOM);
+ BIND_ENUM_CONSTANT(CELL_MODE_STRING);
+ BIND_ENUM_CONSTANT(CELL_MODE_CHECK);
+ BIND_ENUM_CONSTANT(CELL_MODE_RANGE);
+ BIND_ENUM_CONSTANT(CELL_MODE_RANGE_EXPRESSION);
+ BIND_ENUM_CONSTANT(CELL_MODE_ICON);
+ BIND_ENUM_CONSTANT(CELL_MODE_CUSTOM);
}
void TreeItem::clear_children() {
@@ -990,41 +991,10 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co
rect.size.x -= bmsize.x + cache.hseparation;
}
- /*
- if (p_tool)
- rect.size.x-=Math::floor(rect.size.y/2);
- */
-
rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent();
font->draw(ci, rect.position, text, p_color, rect.size.x);
}
-#if 0
-void Tree::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) {
-
- RID ci = get_canvas_item();
- if (!p_icon.is_null()) {
- Size2i bmsize = p_icon->get_size();
- if (p_icon_max_w>0 && bmsize.width > p_icon_max_w) {
- bmsize.height = bmsize.height * p_icon_max_w / bmsize.width;
- bmsize.width=p_icon_max_w;
- }
-
- draw_texture_rect(p_icon,Rect2(p_rect.pos + Size2i(0,Math::floor((p_rect.size.y-bmsize.y)/2)),bmsize));
- p_rect.pos.x+=bmsize.x+cache.hseparation;
- p_rect.size.x-=bmsize.x+cache.hseparation;
-
- }
-
- if (p_tool)
- p_rect.size.x-=Math::floor(p_rect.size.y/2);
-
- Ref<Font> font = cache.font;
-
- p_rect.pos.y+=Math::floor((p_rect.size.y-font->get_height())/2.0) +font->get_ascent();
- font->draw(ci,p_rect.pos,p_text,p_color,p_rect.size.x);
-}
-#endif
int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) {
if (p_pos.y - cache.offset.y > (p_draw_size.height))
@@ -1455,11 +1425,10 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (select_mode == SELECT_ROW) {
- if (p_selected == p_current && !c.selected) {
+ if (p_selected == p_current && (!c.selected || allow_reselect)) {
c.selected = true;
selected_item = p_selected;
selected_col = 0;
- selected_item = p_selected;
if (!emitted_row) {
emit_signal("item_selected");
emitted_row = true;
@@ -1478,7 +1447,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (!r_in_range && &selected_cell == &c) {
- if (!selected_cell.selected || force_select_on_already_selected) {
+ if (!selected_cell.selected || allow_reselect) {
selected_cell.selected = true;
@@ -1743,7 +1712,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
/* editing */
- bool bring_up_editor = force_select_on_already_selected ? (c.selected && already_selected) : c.selected;
+ bool bring_up_editor = allow_reselect ? (c.selected && already_selected) : c.selected;
String editor_text = c.text;
switch (c.mode) {
@@ -2474,22 +2443,24 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Point2 pos = b->get_position() - bg->get_offset();
cache.click_type = Cache::CLICK_NONE;
- if (show_column_titles && b->get_button_index() == BUTTON_LEFT) {
+ if (show_column_titles) {
pos.y -= _get_title_button_height();
if (pos.y < 0) {
- pos.x += cache.offset.x;
- int len = 0;
- for (int i = 0; i < columns.size(); i++) {
-
- len += get_column_width(i);
- if (pos.x < len) {
-
- cache.click_type = Cache::CLICK_TITLE;
- cache.click_index = i;
- //cache.click_id=;
- update();
- break;
+ if (b->get_button_index() == BUTTON_LEFT) {
+ pos.x += cache.offset.x;
+ int len = 0;
+ for (int i = 0; i < columns.size(); i++) {
+
+ len += get_column_width(i);
+ if (pos.x < len) {
+
+ cache.click_type = Cache::CLICK_TITLE;
+ cache.click_index = i;
+ //cache.click_id=;
+ update();
+ break;
+ }
}
}
break;
@@ -2869,8 +2840,8 @@ TreeItem *Tree::create_item(TreeItem *p_parent) {
TreeItem *ti = memnew(TreeItem(this));
- ti->cells.resize(columns.size());
ERR_FAIL_COND_V(!ti, NULL);
+ ti->cells.resize(columns.size());
if (p_parent) {
@@ -3557,16 +3528,6 @@ int Tree::get_drop_mode_flags() const {
return drop_mode_flags;
}
-void Tree::set_single_select_cell_editing_only_when_already_selected(bool p_enable) {
-
- force_select_on_already_selected = p_enable;
-}
-
-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;
@@ -3587,6 +3548,15 @@ bool Tree::get_allow_rmb_select() const {
return allow_rmb_select;
}
+void Tree::set_allow_reselect(bool p_allow) {
+ allow_reselect = p_allow;
+}
+
+bool Tree::get_allow_reselect() const {
+
+ return allow_reselect;
+}
+
void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &Tree::_range_click_timeout);
@@ -3640,8 +3610,8 @@ void Tree::_bind_methods() {
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(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);
+ ClassDB::bind_method(D_METHOD("set_allow_reselect", "allow"), &Tree::set_allow_reselect);
+ ClassDB::bind_method(D_METHOD("get_allow_reselect"), &Tree::get_allow_reselect);
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
@@ -3659,13 +3629,13 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_activated"));
ADD_SIGNAL(MethodInfo("column_title_pressed", PropertyInfo(Variant::INT, "column")));
- BIND_CONSTANT(SELECT_SINGLE);
- BIND_CONSTANT(SELECT_ROW);
- BIND_CONSTANT(SELECT_MULTI);
+ BIND_ENUM_CONSTANT(SELECT_SINGLE);
+ BIND_ENUM_CONSTANT(SELECT_ROW);
+ BIND_ENUM_CONSTANT(SELECT_MULTI);
- BIND_CONSTANT(DROP_MODE_DISABLED);
- BIND_CONSTANT(DROP_MODE_ON_ITEM);
- BIND_CONSTANT(DROP_MODE_INBETWEEN);
+ BIND_ENUM_CONSTANT(DROP_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(DROP_MODE_ON_ITEM);
+ BIND_ENUM_CONSTANT(DROP_MODE_INBETWEEN);
}
Tree::Tree() {
@@ -3751,7 +3721,6 @@ Tree::Tree() {
drop_mode_over = NULL;
drop_mode_section = 0;
single_select_defer = NULL;
- force_select_on_already_selected = false;
allow_rmb_select = false;
force_edit_checkbox_only_on_checkbox = false;
@@ -3760,6 +3729,8 @@ Tree::Tree() {
cache.hover_item = NULL;
cache.hover_cell = -1;
+
+ allow_reselect = false;
}
Tree::~Tree() {
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index d3715c3c43..1fb1eb2792 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -172,7 +172,9 @@ protected:
return d;
}
- void _remove_child(Object *p_child) { remove_child(p_child->cast_to<TreeItem>()); }
+ void _remove_child(Object *p_child) {
+ remove_child(Object::cast_to<TreeItem>(p_child));
+ }
public:
/* cell mode */
@@ -471,7 +473,7 @@ private:
TreeItem *_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards = false);
- TreeItem *_find_item_at_pos(TreeItem *p_current, const Point2 &p_pos, int &r_column, int &h, int &section) const;
+ TreeItem *_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int &section) const;
/* float drag_speed;
float drag_accum;
@@ -490,7 +492,8 @@ private:
bool allow_rmb_select;
bool scrolling;
- bool force_select_on_already_selected;
+ bool allow_reselect;
+
bool force_edit_checkbox_only_on_checkbox;
bool hide_folding;
@@ -503,9 +506,17 @@ protected:
static void _bind_methods();
//bind helpers
- Object *_create_item(Object *p_parent) { return create_item(p_parent->cast_to<TreeItem>()); }
- TreeItem *_get_next_selected(Object *p_item) { return get_next_selected(p_item->cast_to<TreeItem>()); }
- Rect2 _get_item_rect(Object *p_item, int p_column) const { return get_item_rect(p_item->cast_to<TreeItem>(), p_column); }
+ Object *_create_item(Object *p_parent) {
+ return create_item(Object::cast_to<TreeItem>(p_parent));
+ }
+
+ TreeItem *_get_next_selected(Object *p_item) {
+ return get_next_selected(Object::cast_to<TreeItem>(p_item));
+ }
+
+ Rect2 _get_item_rect(Object *p_item, int p_column) const {
+ return get_item_rect(Object::cast_to<TreeItem>(p_item), p_column);
+ }
public:
virtual String get_tooltip(const Point2 &p_pos) const;
@@ -524,7 +535,7 @@ public:
void set_column_expand(int p_column, bool p_expand);
int get_column_width(int p_column) const;
- void set_hide_root(bool p_eanbled);
+ void set_hide_root(bool p_enabled);
TreeItem *get_next_selected(TreeItem *p_item);
TreeItem *get_selected() const;
int get_selected_column() const;
@@ -566,15 +577,15 @@ public:
void set_drop_mode_flags(int p_flags);
int get_drop_mode_flags() const;
- 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;
+ void set_allow_reselect(bool p_allow);
+ bool get_allow_reselect() const;
+
void set_value_evaluator(ValueEvaluator *p_evaluator);
Tree();
@@ -582,4 +593,5 @@ public:
};
VARIANT_ENUM_CAST(Tree::SelectMode);
+VARIANT_ENUM_CAST(Tree::DropModeFlags);
#endif
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 9c018a4e7c..a92155cc4f 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,27 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "video_player.h"
+
#include "os/os.h"
#include "servers/audio_server.h"
-/*
-
-int VideoPlayer::InternalStream::get_channel_count() const {
-
- return player->sp_get_channel_count();
-}
-void VideoPlayer::InternalStream::set_mix_rate(int p_rate){
-
- return player->sp_set_mix_rate(p_rate);
-}
-bool VideoPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
-
- return player->sp_mix(p_buffer,p_frames);
-}
-void VideoPlayer::InternalStream::update(){
-
- player->sp_update();
-}
-*/
int VideoPlayer::sp_get_channel_count() const {
@@ -69,31 +51,6 @@ bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) {
return false;
}
-void VideoPlayer::sp_update() {
-#if 0
- _THREAD_SAFE_METHOD_
- //update is unused
- if (!paused && 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);
- }
-#endif
-}
-
int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) {
VideoPlayer *vp = (VideoPlayer *)p_udata;
@@ -116,7 +73,7 @@ void VideoPlayer::_notification(int p_notification) {
case NOTIFICATION_ENTER_TREE: {
- if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) {
+ if (stream.is_valid() && autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
}
} break;
@@ -399,7 +356,6 @@ VideoPlayer::VideoPlayer() {
paused = false;
autoplay = false;
expand = true;
- loops = false;
audio_track = 0;
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 1d70718a6a..b78f3aabe7 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,23 +38,12 @@ class VideoPlayer : public Control {
GDCLASS(VideoPlayer, Control);
- /* 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;
Ref<VideoStreamPlayback> playback;
Ref<VideoStream> 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();
RID stream_rid;
@@ -105,7 +94,7 @@ public:
String get_stream_name() const;
float get_stream_pos() const;
- void set_autoplay(bool p_vol);
+ void set_autoplay(bool p_enable);
bool has_autoplay() const;
void set_audio_track(int p_track);
@@ -118,4 +107,4 @@ public:
~VideoPlayer();
};
-#endif
+#endif // VIDEO_PLAYER_H
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp
index dbc2699867..c321b873fd 100644
--- a/scene/gui/viewport_container.cpp
+++ b/scene/gui/viewport_container.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,7 +38,7 @@ Size2 ViewportContainer::get_minimum_size() const {
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = get_child(i)->cast_to<Viewport>();
+ Viewport *c = Object::cast_to<Viewport>(get_child(i));
if (!c)
continue;
@@ -71,7 +71,7 @@ void ViewportContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = get_child(i)->cast_to<Viewport>();
+ Viewport *c = Object::cast_to<Viewport>(get_child(i));
if (!c)
continue;
@@ -83,7 +83,7 @@ void ViewportContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = get_child(i)->cast_to<Viewport>();
+ Viewport *c = Object::cast_to<Viewport>(get_child(i));
if (!c)
continue;
@@ -98,7 +98,7 @@ void ViewportContainer::_notification(int p_what) {
for (int i = 0; i < get_child_count(); i++) {
- Viewport *c = get_child(i)->cast_to<Viewport>();
+ Viewport *c = Object::cast_to<Viewport>(get_child(i));
if (!c)
continue;
diff --git a/scene/gui/viewport_container.h b/scene/gui/viewport_container.h
index 27eb6ec81b..630523b5fb 100644
--- a/scene/gui/viewport_container.h
+++ b/scene/gui/viewport_container.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/io/SCsub b/scene/io/SCsub
deleted file mode 100644
index bf9125be7f..0000000000
--- a/scene/io/SCsub
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-
-env.add_source_files(env.scene_sources, "*.cpp")
-
-Export('env')
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp
deleted file mode 100644
index 04b6177c3c..0000000000
--- a/scene/io/resource_format_image.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*************************************************************************/
-/* resource_format_image.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "resource_format_image.h"
-
-#if 0
-#include "io/image_loader.h"
-#include "os/os.h"
-#include "project_settings.h"
-#include "scene/resources/texture.h"
-RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) {
-
- if (r_error)
- *r_error=ERR_CANT_OPEN;
-
- if (p_path.get_extension()=="cube") {
- // open as cubemap txture
-
- CubeMap* ptr = memnew(CubeMap);
- Ref<CubeMap> cubemap( ptr );
-
- Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
- if (err) {
-
- ERR_FAIL_COND_V( err, RES() );
- }
-
- String base_path=p_path.substr( 0, p_path.find_last("/")+1 );
-
- for(int i=0;i<6;i++) {
-
- String file = f->get_line().strip_edges();
- Image image;
-
- Error err = ImageLoader::load_image(base_path+file,&image);
-
-
- if (err) {
-
- memdelete(f);
- ERR_FAIL_COND_V( err, RES() );
- }
-
- if (i==0) {
-
- //cubemap->create(image.get_width(),image.get_height(),image.get_format(),Texture::FLAGS_DEFAULT|Texture::FLAG_CUBEMAP);
- }
-
- static const CubeMap::Side cube_side[6]= {
- CubeMap::SIDE_LEFT,
- CubeMap::SIDE_RIGHT,
- CubeMap::SIDE_BOTTOM,
- CubeMap::SIDE_TOP,
- CubeMap::SIDE_FRONT,
- CubeMap::SIDE_BACK
- };
-
- cubemap->set_side(cube_side[i],image);
- }
-
- memdelete(f);
-
- cubemap->set_name(p_path.get_file());
- if (r_error)
- *r_error=OK;
-
- return cubemap;
-
- } else {
- // simple image
-
- ImageTexture* ptr = memnew(ImageTexture);
- Ref<ImageTexture> texture( ptr );
-
- uint64_t begtime;
- double total;
-
- Image image;
-
- if (debug_load_times)
- begtime=OS::get_singleton()->get_ticks_usec();
-
-
- Error err = ImageLoader::load_image(p_path,&image);
-
- if (!err && debug_load_times) {
- double total=USEC_TO_SEC((OS::get_singleton()->get_ticks_usec()-begtime));
- print_line("IMAGE: "+itos(image.get_width())+"x"+itos(image.get_height()));
- print_line(" -load: "+rtos(total));
- }
-
-
- ERR_EXPLAIN("Failed loading image: "+p_path);
- ERR_FAIL_COND_V(err, RES());
- if (r_error)
- *r_error=ERR_FILE_CORRUPT;
-
-#ifdef DEBUG_ENABLED
-#ifdef TOOLS_ENABLED
-
- if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) {
-
-
- if (bool(ProjectSettings::get_singleton()->get("debug/image_loader/max_texture_size_alert"))) {
- OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!");
- }
-
- ERR_EXPLAIN("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".");
- ERR_FAIL_V(RES());
- }
-#endif
-#endif
-
-
- uint32_t flags=load_image_flags(p_path);
-
- if (debug_load_times)
- begtime=OS::get_singleton()->get_ticks_usec();
-
- //print_line("img: "+p_path+" flags: "+itos(flags));
- texture->create_from_image( image,flags );
- texture->set_name(p_path.get_file());
-
-
- if (debug_load_times) {
- total=USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()-begtime);
- print_line(" -make texture: "+rtos(total));
- }
-
- if (r_error)
- *r_error=OK;
-
- return RES( texture );
- }
-
-
-}
-
-uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) {
-
-
- FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ);
- Map<String,bool> flags_found;
- if (f2) {
-
- while(!f2->eof_reached()) {
- String l2 = f2->get_line();
- int eqpos = l2.find("=");
- if (eqpos!=-1) {
- String flag=l2.substr(0,eqpos).strip_edges();
- String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower();
- flags_found[flag]=(val=="true" || val=="1")?true:false;
- }
- }
- memdelete(f2);
- }
-
-
- uint32_t flags=0;
-
- if (flags_found.has("filter")) {
- if (flags_found["filter"])
- flags|=Texture::FLAG_FILTER;
- } else if (bool(GLOBAL_DEF("rendering/image_loader/filter",true))) {
- flags|=Texture::FLAG_FILTER;
- }
-
-
- if (flags_found.has("gen_mipmaps")) {
- if (flags_found["gen_mipmaps"])
- flags|=Texture::FLAG_MIPMAPS;
- } else if (bool(GLOBAL_DEF("rendering/image_loader/gen_mipmaps",true))) {
- flags|=Texture::FLAG_MIPMAPS;
- }
-
- if (flags_found.has("repeat")) {
- if (flags_found["repeat"])
- flags|=Texture::FLAG_REPEAT;
- } else if (bool(GLOBAL_DEF("rendering/image_loader/repeat",true))) {
- flags|=Texture::FLAG_REPEAT;
- }
-
- if (flags_found.has("anisotropic")) {
- if (flags_found["anisotropic"])
- flags|=Texture::FLAG_ANISOTROPIC_FILTER;
- }
-
- if (flags_found.has("tolinear")) {
- if (flags_found["tolinear"])
- flags|=Texture::FLAG_CONVERT_TO_LINEAR;
- }
-
- if (flags_found.has("mirroredrepeat")) {
- if (flags_found["mirroredrepeat"])
- flags|=Texture::FLAG_MIRRORED_REPEAT;
- }
-
- return flags;
-}
-
-bool ResourceFormatLoaderImage::handles_type(const String& p_type) const {
-
- return ClassDB::is_parent_class(p_type,"Texture") || ClassDB::is_parent_class(p_type,"CubeMap");
-}
-
-void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extensions) const {
-
- ImageLoader::get_recognized_extensions(p_extensions);
- p_extensions->push_back("cube");
-}
-
-String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const {
-
- String ext=p_path.get_extension().to_lower();
- if (ext=="cube")
- return "CubeMap";
-
- List<String> extensions;
- ImageLoader::get_recognized_extensions(&extensions);
-
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get()==ext)
- return "ImageTexture";
- }
- return "";
-}
-
-
-ResourceFormatLoaderImage::ResourceFormatLoaderImage() {
-
- max_texture_size = GLOBAL_DEF("debug/image_loader/max_texture_size",0);
- GLOBAL_DEF("debug/image_loader/max_texture_size_alert",false);
- debug_load_times=GLOBAL_DEF("debug/image_loader/image_load_times",false);
- GLOBAL_DEF("rendering/image_loader/filter",true);
- GLOBAL_DEF("rendering/image_loader/gen_mipmaps",true);
- GLOBAL_DEF("rendering/image_loader/repeat",false);
-
-}
-#endif
diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h
deleted file mode 100644
index 2cf6315f17..0000000000
--- a/scene/io/resource_format_image.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*************************************************************************/
-/* resource_format_image.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef RESOURCE_FORMAT_IMAGE_H
-#define RESOURCE_FORMAT_IMAGE_H
-
-#if 0
-
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class ResourceFormatLoaderImage : public ResourceFormatLoader {
-
- bool debug_load_times;
- int max_texture_size;
-public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
- static uint32_t load_image_flags(const String &p_path);
- 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;
-
- ResourceFormatLoaderImage();
-};
-
-#endif
-#endif
diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp
deleted file mode 100644
index dabbb79de3..0000000000
--- a/scene/io/resource_format_wav.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/*************************************************************************/
-/* resource_format_wav.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#if 0
-#include "resource_format_wav.h"
-#include "os/file_access.h"
-#include "scene/resources/sample.h"
-
-
-RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original_path, Error *r_error) {
- if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
-
- Error err;
- FileAccess *file=FileAccess::open(p_path, FileAccess::READ,&err);
-
- ERR_FAIL_COND_V( err!=OK, RES() );
-
- if (r_error)
- *r_error=ERR_FILE_CORRUPT;
-
- /* 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( RES() );
- }
-
-
- /* 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( RES() );
- }
-
- bool format_found=false;
- bool data_found=false;
- int format_bits=0;
- int format_channels=0;
- int format_freq=0;
- Sample::LoopFormat loop=Sample::LOOP_NONE;
- int loop_begin=0;
- int loop_end=0;
-
-
- Ref<Sample> sample( memnew( Sample ) );
-
-
- 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_position(); //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;
- }
-
- /* Don't 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;
-
- }
-
- int 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));
-*/
- sample->create(
- (format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16,
- (format_channels==2)?true:false,
- frames );
- sample->set_mix_rate( format_freq );
-
- int len=frames;
- if (format_channels==2)
- len*=2;
- if (format_bits>8)
- len*=2;
-
- PoolVector<uint8_t> data;
- data.resize(len);
- PoolVector<uint8_t>::Write dataw = data.write();
- void * data_ptr = dataw.ptr();
-
- 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;
-
- int8_t *data_ptr8=&((int8_t*)data_ptr)[i*format_channels+c];
-
- *data_ptr8=*sp;
-
- } else {
- //16+ bits samples are SIGNED
- // if sample is > 16 bits, just read extra bytes
-
- uint32_t data=0;
- for (int b=0;b<(format_bits>>3);b++) {
-
- data|=((uint32_t)file->get_8())<<(b*8);
- }
- data<<=(32-format_bits);
-
-
- int32_t s=data;
-
- int16_t *data_ptr16=&((int16_t*)data_ptr)[i*format_channels+c];
-
- *data_ptr16=s>>16;
- }
- }
-
- }
-
- dataw=PoolVector<uint8_t>::Write();
-
- sample->set_data(data);
-
-
- if (file->eof_reached()) {
- file->close();
- memdelete(file);
- ERR_EXPLAIN("Premature end of file.");
- ERR_FAIL_V(RES());
- }
- }
-
- 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()?Sample::LOOP_PING_PONG:Sample::LOOP_FORWARD;
- loop_begin=file->get_32();
- loop_end=file->get_32();
-
- }
- file->seek( file_pos+chunksize );
- }
-
- sample->set_loop_format(loop);
- sample->set_loop_begin(loop_begin);
- sample->set_loop_end(loop_end);
-
- file->close();
- memdelete(file);
-
- if (r_error)
- *r_error=OK;
-
-
- return sample;
-
-}
-void ResourceFormatLoaderWAV::get_recognized_extensions(List<String> *p_extensions) const {
-
- p_extensions->push_back("wav");
-}
-bool ResourceFormatLoaderWAV::handles_type(const String& p_type) const {
-
- return (p_type=="Sample");
-}
-
-String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const {
-
- 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
deleted file mode 100644
index 9105689670..0000000000
--- a/scene/io/resource_format_wav.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*************************************************************************/
-/* resource_format_wav.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef RESOURCE_FORMAT_WAV_H
-#define RESOURCE_FORMAT_WAV_H
-
-#if 0
-#include "io/resource_loader.h"
-
-class ResourceFormatLoaderWAV : 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;
-
-};
-
-#endif
-#endif // RESOURCE_FORMAT_WAV_H
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 77407fdde7..ce8714e574 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -201,7 +201,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
viewport = RID();
}
- custom_viewport = p_viewport->cast_to<Viewport>();
+ custom_viewport = Object::cast_to<Viewport>(p_viewport);
if (custom_viewport) {
custom_viewport_id = custom_viewport->get_instance_id();
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index 1be6f8be24..fbee87f487 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -55,7 +55,7 @@ class CanvasLayer : public Node {
int sort_index;
// Deprecated, should be removed in a future version.
- void _set_rotationd(real_t p_rotation);
+ void _set_rotationd(real_t p_degrees);
real_t _get_rotationd() const;
void _update_xform();
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index a9b2dba186..1e1e4f2d5f 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -547,19 +547,19 @@ void HTTPRequest::_bind_methods() {
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")));
- BIND_CONSTANT(RESULT_SUCCESS);
- //BIND_CONSTANT( RESULT_NO_BODY );
- BIND_CONSTANT(RESULT_CHUNKED_BODY_SIZE_MISMATCH);
- BIND_CONSTANT(RESULT_CANT_CONNECT);
- BIND_CONSTANT(RESULT_CANT_RESOLVE);
- BIND_CONSTANT(RESULT_CONNECTION_ERROR);
- BIND_CONSTANT(RESULT_SSL_HANDSHAKE_ERROR);
- BIND_CONSTANT(RESULT_NO_RESPONSE);
- BIND_CONSTANT(RESULT_BODY_SIZE_LIMIT_EXCEEDED);
- BIND_CONSTANT(RESULT_REQUEST_FAILED);
- BIND_CONSTANT(RESULT_DOWNLOAD_FILE_CANT_OPEN);
- BIND_CONSTANT(RESULT_DOWNLOAD_FILE_WRITE_ERROR);
- BIND_CONSTANT(RESULT_REDIRECT_LIMIT_REACHED);
+ BIND_ENUM_CONSTANT(RESULT_SUCCESS);
+ //BIND_ENUM_CONSTANT( RESULT_NO_BODY );
+ BIND_ENUM_CONSTANT(RESULT_CHUNKED_BODY_SIZE_MISMATCH);
+ BIND_ENUM_CONSTANT(RESULT_CANT_CONNECT);
+ BIND_ENUM_CONSTANT(RESULT_CANT_RESOLVE);
+ BIND_ENUM_CONSTANT(RESULT_CONNECTION_ERROR);
+ BIND_ENUM_CONSTANT(RESULT_SSL_HANDSHAKE_ERROR);
+ BIND_ENUM_CONSTANT(RESULT_NO_RESPONSE);
+ BIND_ENUM_CONSTANT(RESULT_BODY_SIZE_LIMIT_EXCEEDED);
+ BIND_ENUM_CONSTANT(RESULT_REQUEST_FAILED);
+ BIND_ENUM_CONSTANT(RESULT_DOWNLOAD_FILE_CANT_OPEN);
+ BIND_ENUM_CONSTANT(RESULT_DOWNLOAD_FILE_WRITE_ERROR);
+ BIND_ENUM_CONSTANT(RESULT_REDIRECT_LIMIT_REACHED);
}
HTTPRequest::HTTPRequest() {
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 6099d4e9bf..790ff5f7ef 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -137,4 +137,6 @@ public:
~HTTPRequest();
};
+VARIANT_ENUM_CAST(HTTPRequest::Result);
+
#endif // HTTPREQUEST_H
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 5580ef486e..cbe30e05dd 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h
index ec4520e1c8..375c87a035 100644
--- a/scene/main/instance_placeholder.h
+++ b/scene/main/instance_placeholder.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 0d872d906e..c3d9d97c5a 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "node.h"
+
#include "instance_placeholder.h"
#include "io/resource_loader.h"
#include "message_queue.h"
@@ -194,7 +195,7 @@ void Node::_propagate_enter_tree() {
data.depth = 1;
}
- data.viewport = cast_to<Viewport>();
+ data.viewport = Object::cast_to<Viewport>(this);
if (!data.viewport)
data.viewport = data.parent->data.viewport;
@@ -360,18 +361,6 @@ void Node::add_child_notify(Node *p_child) {
// to be used when not wanted
}
-/*
-void Node::remove_and_delete_child(Node *p_child) {
-
- ERR_FAIL_NULL( p_child );
- ERR_FAIL_COND( p_child->get_parent()!=this );
-
- remove_child(p_child);
- memdelete(p_child);
-
-}
-*/
-
void Node::remove_child_notify(Node *p_child) {
// to be used when not wanted
@@ -675,31 +664,6 @@ Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Va
return Variant();
}
-#if 0
-Variant Node::_rpc_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
-
- if (p_argcount<1) {
- r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
- r_error.argument=1;
- return Variant();
- }
-
- if (p_args[0]->get_type()!=Variant::STRING) {
- r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument=0;
- r_error.expected=Variant::STRING;
- return Variant();
- }
-
- StringName method = *p_args[0];
-
- rpcp(method,&p_args[1],p_argcount-1);
-
- r_error.error=Variant::CallError::CALL_OK;
- return Variant();
-}
-
-#endif
void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
ERR_FAIL_COND(!is_inside_tree());
@@ -1301,8 +1265,9 @@ String Node::_generate_serial_child_name(Node *p_child) {
}
}
+ int num_places = nums.length();
for (;;) {
- String attempt = (name + (num > 0 || explicit_zero ? nnsep + itos(num) : "")).strip_edges();
+ String attempt = (name + (num > 0 || explicit_zero ? nnsep + itos(num).pad_zeros(num_places) : "")).strip_edges();
bool found = false;
for (int i = 0; i < data.children.size(); i++) {
if (data.children[i] == p_child)
@@ -1352,20 +1317,24 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
void Node::add_child(Node *p_child, bool p_legible_unique_name) {
ERR_FAIL_NULL(p_child);
- /* Fail if node has a parent */
+
if (p_child == this) {
- ERR_EXPLAIN("Can't add child " + p_child->get_name() + " to itself.")
+ ERR_EXPLAIN("Can't add child '" + p_child->get_name() + "' to itself.")
ERR_FAIL_COND(p_child == this); // adding to itself!
}
- ERR_EXPLAIN("Can't add child, already has a parent");
- ERR_FAIL_COND(p_child->data.parent);
+
+ /* Fail if node has a parent */
+ if (p_child->data.parent) {
+ ERR_EXPLAIN("Can't add child '" + p_child->get_name() + "' to '" + get_name() + "', already has a parent '" + p_child->data.parent->get_name() + "'.");
+ ERR_FAIL_COND(p_child->data.parent);
+ }
if (data.blocked > 0) {
- ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\",child) instead.");
+ ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\", child) instead.");
ERR_FAIL_COND(data.blocked > 0);
}
- ERR_EXPLAIN("Can't add child while a notification is happening");
+ ERR_EXPLAIN("Can't add child while a notification is happening.");
ERR_FAIL_COND(data.blocked > 0);
/* Validate name */
@@ -1380,7 +1349,7 @@ void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_uniq
if (is_a_parent_of(p_node)) {
move_child(p_child, p_node->get_position_in_parent() + 1);
} else {
- WARN_PRINTS("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent")
+ WARN_PRINTS("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent.")
}
}
@@ -1953,6 +1922,23 @@ void Node::propagate_notification(int p_notification) {
data.blocked--;
}
+void Node::propagate_call(const StringName &p_method, const Array &p_args, const bool p_parent_first) {
+
+ data.blocked++;
+
+ if (p_parent_first && has_method(p_method))
+ callv(p_method, p_args);
+
+ for (int i = 0; i < data.children.size(); i++) {
+ data.children[i]->propagate_call(p_method, p_args, p_parent_first);
+ }
+
+ if (!p_parent_first && has_method(p_method))
+ callv(p_method, p_args);
+
+ data.blocked--;
+}
+
void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
if (get_owner() == p_owner)
set_owner(p_by_owner);
@@ -2048,59 +2034,6 @@ HashMap<NodePath, int> Node::get_editable_instances() const {
return data.editable_instances;
}
-#if 0
-
-void Node::generate_instance_state() {
-
- List<PropertyInfo> properties;
- get_property_list(&properties);
-
- data.instance_state.clear();
-
- for( List<PropertyInfo>::Element *E=properties.front();E;E=E->next() ) {
-
- PropertyInfo &pi=E->get();
- if ((pi.usage&PROPERTY_USAGE_NO_INSTANCE_STATE) || !(pi.usage&PROPERTY_USAGE_EDITOR) || !(pi.usage&PROPERTY_USAGE_STORAGE))
- continue;
-
- data.instance_state[pi.name]=get(pi.name);
- }
-
- List<GroupInfo> groups;
- get_groups(&groups);
- for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) {
-
- if (!E->get().persistent)
- continue;
- data.instance_groups.push_back(E->get().name);
- }
-
- List<MethodInfo> signal_list;
-
- get_signal_list(&signal_list);
-
- for(List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) {
-
- StringName name = E->get().name;
- List<Connection> connections;
- get_signal_connection_list(name,&connections);
-
- for(List<Connection>::Element *F=connections.front();F;F=F->next()) {
-
- if (F->get().flags&CONNECT_PERSIST)
- data.instance_connections.push_back(F->get());
- }
-
- }
-}
-
-Dictionary Node::get_instance_state() const {
-
- return data.instance_state;
-}
-
-#endif
-
void Node::set_scene_instance_state(const Ref<SceneState> &p_state) {
data.instance_state = p_state;
@@ -2142,9 +2075,9 @@ Node *Node::_duplicate(int p_flags) const {
bool instanced = false;
- if (cast_to<InstancePlaceholder>()) {
+ if (Object::cast_to<InstancePlaceholder>(this)) {
- const InstancePlaceholder *ip = cast_to<const InstancePlaceholder>();
+ const InstancePlaceholder *ip = Object::cast_to<const InstancePlaceholder>(this);
InstancePlaceholder *nip = memnew(InstancePlaceholder);
nip->set_instance_path(ip->get_instance_path());
node = nip;
@@ -2162,7 +2095,7 @@ Node *Node::_duplicate(int p_flags) const {
Object *obj = ClassDB::instance(get_class());
ERR_FAIL_COND_V(!obj, NULL);
- node = obj->cast_to<Node>();
+ node = Object::cast_to<Node>(obj);
if (!node)
memdelete(obj);
ERR_FAIL_COND_V(!node, NULL);
@@ -2252,7 +2185,7 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
print_line("could not duplicate: " + String(get_class()));
}
ERR_FAIL_COND(!obj);
- node = obj->cast_to<Node>();
+ node = Object::cast_to<Node>(obj);
if (!node)
memdelete(obj);
}
@@ -2308,7 +2241,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
NodePath p = p_original->get_path_to(this);
Node *copy = p_copy->get_node(p);
- Node *target = E->get().target->cast_to<Node>();
+ Node *target = Object::cast_to<Node>(E->get().target);
if (!target) {
continue;
}
@@ -2337,7 +2270,7 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
print_line("could not duplicate: " + String(get_class()));
}
ERR_FAIL_COND_V(!obj, NULL);
- node = obj->cast_to<Node>();
+ node = Object::cast_to<Node>(obj);
if (!node)
memdelete(obj);
ERR_FAIL_COND_V(!node, NULL);
@@ -2592,7 +2525,7 @@ void Node::_set_tree(SceneTree *p_tree) {
static void _Node_debug_sn(Object *p_obj) {
- Node *n = p_obj->cast_to<Node>();
+ Node *n = Object::cast_to<Node>(p_obj);
if (!n)
return;
@@ -2730,7 +2663,6 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name);
ClassDB::bind_method(D_METHOD("add_child", "node", "legible_unique_name"), &Node::add_child, DEFVAL(false));
ClassDB::bind_method(D_METHOD("remove_child", "node"), &Node::remove_child);
- //ClassDB::bind_method(D_METHOD("remove_and_delete_child","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", "idx"), &Node::get_child);
@@ -2760,6 +2692,7 @@ void Node::_bind_methods() {
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("propagate_call", "method", "args", "parent_first"), &Node::propagate_call, DEFVAL(Array()), DEFVAL(false));
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);
@@ -2841,7 +2774,6 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_ENTER_TREE);
BIND_CONSTANT(NOTIFICATION_EXIT_TREE);
BIND_CONSTANT(NOTIFICATION_MOVED_IN_PARENT);
- //BIND_CONSTANT( NOTIFICATION_PARENT_DECONFIGURED );
BIND_CONSTANT(NOTIFICATION_READY);
BIND_CONSTANT(NOTIFICATION_FIXED_PROCESS);
BIND_CONSTANT(NOTIFICATION_PROCESS);
@@ -2857,20 +2789,20 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS);
BIND_CONSTANT(NOTIFICATION_INTERNAL_FIXED_PROCESS);
- BIND_CONSTANT(RPC_MODE_DISABLED);
- BIND_CONSTANT(RPC_MODE_REMOTE);
- BIND_CONSTANT(RPC_MODE_SYNC);
- BIND_CONSTANT(RPC_MODE_MASTER);
- BIND_CONSTANT(RPC_MODE_SLAVE);
+ BIND_ENUM_CONSTANT(RPC_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(RPC_MODE_REMOTE);
+ BIND_ENUM_CONSTANT(RPC_MODE_SYNC);
+ BIND_ENUM_CONSTANT(RPC_MODE_MASTER);
+ BIND_ENUM_CONSTANT(RPC_MODE_SLAVE);
- BIND_CONSTANT(PAUSE_MODE_INHERIT);
- BIND_CONSTANT(PAUSE_MODE_STOP);
- BIND_CONSTANT(PAUSE_MODE_PROCESS);
+ BIND_ENUM_CONSTANT(PAUSE_MODE_INHERIT);
+ BIND_ENUM_CONSTANT(PAUSE_MODE_STOP);
+ BIND_ENUM_CONSTANT(PAUSE_MODE_PROCESS);
- BIND_CONSTANT(DUPLICATE_SIGNALS);
- BIND_CONSTANT(DUPLICATE_GROUPS);
- BIND_CONSTANT(DUPLICATE_SCRIPTS);
- BIND_CONSTANT(DUPLICATE_USE_INSTANCING);
+ BIND_ENUM_CONSTANT(DUPLICATE_SIGNALS);
+ BIND_ENUM_CONSTANT(DUPLICATE_GROUPS);
+ BIND_ENUM_CONSTANT(DUPLICATE_SCRIPTS);
+ BIND_ENUM_CONSTANT(DUPLICATE_USE_INSTANCING);
ADD_SIGNAL(MethodInfo("renamed"));
ADD_SIGNAL(MethodInfo("tree_entered"));
diff --git a/scene/main/node.h b/scene/main/node.h
index 0447deccc1..12d6310062 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -32,8 +32,8 @@
#include "class_db.h"
#include "map.h"
-#include "object.h"
#include "node_path.h"
+#include "object.h"
#include "project_settings.h"
#include "scene/main/scene_tree.h"
#include "script_language.h"
@@ -192,7 +192,6 @@ protected:
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
virtual void move_child_notify(Node *p_child);
- //void remove_and_delete_child(Node *p_child);
void _propagate_replace_owner(Node *p_owner, Node *p_by_owner);
@@ -212,7 +211,6 @@ public:
NOTIFICATION_EXIT_TREE = 11,
NOTIFICATION_MOVED_IN_PARENT = 12,
NOTIFICATION_READY = 13,
- //NOTIFICATION_PARENT_DECONFIGURED =15, - it's confusing, it's going away
NOTIFICATION_PAUSED = 14,
NOTIFICATION_UNPAUSED = 15,
NOTIFICATION_FIXED_PROCESS = 16,
@@ -298,19 +296,21 @@ public:
void propagate_notification(int p_notification);
+ void propagate_call(const StringName &p_method, const Array &p_args = Array(), const bool p_parent_first = false);
+
/* PROCESSING */
void set_fixed_process(bool p_process);
float get_fixed_process_delta_time() const;
bool is_fixed_processing() const;
- void set_process(bool p_process);
+ void set_process(bool p_idle_process);
float get_process_delta_time() const;
bool is_processing() const;
- void set_fixed_process_internal(bool p_process);
+ void set_fixed_process_internal(bool p_process_internal);
bool is_fixed_processing_internal() const;
- void set_process_internal(bool p_process);
+ void set_process_internal(bool p_idle_process_internal);
bool is_processing_internal() const;
void set_process_input(bool p_enable);
@@ -412,6 +412,8 @@ public:
~Node();
};
+VARIANT_ENUM_CAST(Node::DuplicateFlags);
+
typedef Set<Node *, Node::Comparator> NodeSet;
#endif
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index ae323ba021..35bb6ef7e8 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h
index a54781dc81..40e900a492 100644
--- a/scene/main/resource_preloader.h
+++ b/scene/main/resource_preloader.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 067bcbff3e..65aeb23609 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,17 +29,15 @@
/*************************************************************************/
#include "scene_tree.h"
+#include "editor/editor_node.h"
+#include "io/marshalls.h"
+#include "io/resource_loader.h"
#include "message_queue.h"
#include "node.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
#include "project_settings.h"
-#include <stdio.h>
-//#include "servers/spatial_sound_2d_server.h"
-
-#include "io/marshalls.h"
-#include "io/resource_loader.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/packed_scene.h"
@@ -48,6 +46,8 @@
#include "servers/physics_server.h"
#include "viewport.h"
+#include <stdio.h>
+
void SceneTreeTimer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_time_left", "time"), &SceneTreeTimer::set_time_left);
@@ -382,7 +382,7 @@ bool SceneTree::is_input_handled() {
void SceneTree::input_event(const Ref<InputEvent> &p_event) {
- if (is_editor_hint() && (p_event->cast_to<InputEventJoypadButton>() || p_event->cast_to<InputEventJoypadMotion>()))
+ if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_event)))
return; //avoid joy input on editor
root_lock++;
@@ -392,86 +392,11 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
Ref<InputEvent> ev = p_event;
ev->set_id(++last_id); //this should work better
-#if 0
- switch(ev.type) {
-
- case InputEvent::MOUSE_BUTTON: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
- Vector2 l = ai.xform(Vector2(ev->get_pos().x,ev->get_pos().y));
- ev->get_pos().x=l.x;
- ev->get_pos().y=l.y;
- ev.mouse_button.global_x=g.x;
- ev.mouse_button.global_y=g.y;
-
- } break;
- case InputEvent::MOUSE_MOTION: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
- Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
- Vector2 r = ai.xform(Vector2(ev->get_relative().x,ev->get_relative().y));
- ev.mouse_motion.x=l.x;
- ev.mouse_motion.y=l.y;
- ev.mouse_motion.global_x=g.x;
- ev.mouse_motion.global_y=g.y;
- ev->get_relative().x=r.x;
- ev->get_relative().y=r.y;
-
- } break;
- case InputEvent::SCREEN_TOUCH: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
- ev.screen_touch.x=t.x;
- ev.screen_touch.y=t.y;
-
- } break;
- case InputEvent::SCREEN_DRAG: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
- Vector2 r = ai.xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
- Vector2 s = ai.xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
- ev.screen_drag.x=t.x;
- ev.screen_drag.y=t.y;
- ev.screen_drag.relative_x=r.x;
- ev.screen_drag.relative_y=r.y;
- ev.screen_drag.speed_x=s.x;
- ev.screen_drag.speed_y=s.y;
- } break;
- }
-
-#endif
MainLoop::input_event(ev);
-#if 0
- _call_input_pause("input","_input",ev);
-
- call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"_gui_input","_gui_input",p_event); //special one for GUI, as controls use their own process check
-
- //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev);
-
- /*
- if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_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->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F11) {
-
- Memory::dump_static_mem_to_file("memdump.txt");
- }
- */
-
- //transform for the rest
-#else
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()) {
//quit from game window using F8
Ref<InputEventKey> k = ev;
@@ -482,28 +407,16 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
_flush_ugc();
root_lock--;
- MessageQueue::get_singleton()->flush(); //small little hack
+ //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness
root_lock++;
if (!input_handled) {
-
-#if 0
- _call_input_pause("unhandled_input","_unhandled_input",ev);
- //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev);
- if (!input_handled && ev.type==InputEvent::KEY) {
- _call_input_pause("unhandled_key_input","_unhandled_key_input",ev);
- //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev);
- }
-#else
-
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;
_flush_ugc();
root_lock--;
- MessageQueue::get_singleton()->flush(); //small little hack
+ //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness
} else {
input_handled = true;
root_lock--;
@@ -616,7 +529,7 @@ bool SceneTree::idle(float p_time) {
#ifdef TOOLS_ENABLED
- if (is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
//simple hack to reload fallback environment if it changed from editor
String env_path = ProjectSettings::get_singleton()->get("rendering/environment/default_environment");
env_path = env_path.strip_edges(); //user may have added a space or two
@@ -691,7 +604,7 @@ void SceneTree::_notification(int p_notification) {
get_root()->propagate_notification(p_notification);
} break;
case NOTIFICATION_TRANSLATION_CHANGED: {
- if (!is_editor_hint()) {
+ if (!Engine::get_singleton()->is_editor_hint()) {
get_root()->propagate_notification(Node::NOTIFICATION_TRANSLATION_CHANGED);
}
} break;
@@ -701,6 +614,19 @@ void SceneTree::_notification(int p_notification) {
} break;
+ case NOTIFICATION_WM_ABOUT: {
+
+#ifdef TOOLS_ENABLED
+ if (EditorNode::get_singleton()) {
+ EditorNode::get_singleton()->show_about();
+ } else {
+#endif
+ get_root()->propagate_notification(p_notification);
+#ifdef TOOLS_ENABLED
+ }
+#endif
+ } break;
+
default:
break;
};
@@ -717,19 +643,10 @@ void SceneTree::set_quit_on_go_back(bool p_enable) {
}
#ifdef TOOLS_ENABLED
-void SceneTree::set_editor_hint(bool p_enabled) {
-
- editor_hint = p_enabled;
-}
bool SceneTree::is_node_being_edited(const Node *p_node) const {
- return editor_hint && edited_scene_root && edited_scene_root->is_a_parent_of(p_node);
-}
-
-bool SceneTree::is_editor_hint() const {
-
- return editor_hint;
+ return Engine::get_singleton()->is_editor_hint() && edited_scene_root && edited_scene_root->is_a_parent_of(p_node);
}
#endif
@@ -801,11 +718,11 @@ Ref<Material> SceneTree::get_debug_navigation_material() {
return navigation_material;
Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- /* line_material->set_flag(Material::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,get_debug_navigation_color());*/
+ line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_albedo(get_debug_navigation_color());
navigation_material = line_material;
@@ -818,11 +735,11 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material() {
return navigation_disabled_material;
Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- /* line_material->set_flag(Material::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());*/
+ line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_albedo(get_debug_navigation_disabled_color());
navigation_disabled_material = line_material;
@@ -834,11 +751,11 @@ Ref<Material> SceneTree::get_debug_collision_material() {
return collision_material;
Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- /*line_material->set_flag(Material::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,get_debug_collisions_color());*/
+ line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_albedo(get_debug_collisions_color());
collision_material = line_material;
@@ -852,11 +769,12 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
debug_contact_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
- Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
- /*mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true);
- mat->set_parameter(SpatialMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());*/
+ Ref<SpatialMaterial> mat = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_albedo(get_debug_collision_contact_color());
Vector3 diamond[6] = {
Vector3(-1, 0, 0),
@@ -1469,12 +1387,12 @@ void SceneTree::_live_edit_create_node_func(const NodePath &p_parent, const Stri
continue;
Node *n2 = n->get_node(p_parent);
- Object *o = ClassDB::instance(p_type);
- if (!o)
+ Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
+ if (!no) {
continue;
- Node *no = o->cast_to<Node>();
- no->set_name(p_name);
+ }
+ no->set_name(p_name);
n2->add_child(no);
}
}
@@ -1777,6 +1695,11 @@ Vector<int> SceneTree::get_network_connected_peers() const {
return ret;
}
+
+int SceneTree::get_rpc_sender_id() const {
+ return rpc_sender_id;
+}
+
void SceneTree::set_refuse_new_network_connections(bool p_refuse) {
ERR_FAIL_COND(!network_peer.is_valid());
network_peer->set_refuse_new_connections(p_refuse);
@@ -2171,7 +2094,9 @@ void SceneTree::_network_poll() {
ERR_PRINT("Error getting packet!");
}
+ rpc_sender_id = sender;
_network_process_packet(sender, packet, len);
+ rpc_sender_id = 0;
if (!network_peer.is_valid()) {
break; //it's also possible that a packet or RPC caused a disconnection, so also check here
@@ -2188,8 +2113,6 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_auto_accept_quit", "enabled"), &SceneTree::set_auto_accept_quit);
- 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);
@@ -2253,6 +2176,7 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_network_peer"), &SceneTree::has_network_peer);
ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &SceneTree::get_network_connected_peers);
ClassDB::bind_method(D_METHOD("get_network_unique_id"), &SceneTree::get_network_unique_id);
+ ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &SceneTree::get_rpc_sender_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);
@@ -2276,18 +2200,19 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL(MethodInfo("connection_failed"));
ADD_SIGNAL(MethodInfo("server_disconnected"));
- BIND_CONSTANT(GROUP_CALL_DEFAULT);
- BIND_CONSTANT(GROUP_CALL_REVERSE);
- BIND_CONSTANT(GROUP_CALL_REALTIME);
- BIND_CONSTANT(GROUP_CALL_UNIQUE);
+ BIND_ENUM_CONSTANT(GROUP_CALL_DEFAULT);
+ BIND_ENUM_CONSTANT(GROUP_CALL_REVERSE);
+ BIND_ENUM_CONSTANT(GROUP_CALL_REALTIME);
+ BIND_ENUM_CONSTANT(GROUP_CALL_UNIQUE);
- BIND_CONSTANT(STRETCH_MODE_DISABLED);
- BIND_CONSTANT(STRETCH_MODE_2D);
- BIND_CONSTANT(STRETCH_MODE_VIEWPORT);
- BIND_CONSTANT(STRETCH_ASPECT_IGNORE);
- BIND_CONSTANT(STRETCH_ASPECT_KEEP);
- BIND_CONSTANT(STRETCH_ASPECT_KEEP_WIDTH);
- BIND_CONSTANT(STRETCH_ASPECT_KEEP_HEIGHT);
+ BIND_ENUM_CONSTANT(STRETCH_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(STRETCH_MODE_2D);
+ BIND_ENUM_CONSTANT(STRETCH_MODE_VIEWPORT);
+
+ BIND_ENUM_CONSTANT(STRETCH_ASPECT_IGNORE);
+ BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP);
+ BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_WIDTH);
+ BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_HEIGHT);
}
SceneTree *SceneTree::singleton = NULL;
@@ -2314,9 +2239,6 @@ SceneTree::SceneTree() {
accept_quit = true;
quit_on_go_back = true;
initialized = false;
-#ifdef TOOLS_ENABLED
- editor_hint = false;
-#endif
#ifdef DEBUG_ENABLED
debug_collisions_hint = false;
debug_navigation_hint = false;
@@ -2339,6 +2261,7 @@ SceneTree::SceneTree() {
call_lock = 0;
root_lock = 0;
node_count = 0;
+ rpc_sender_id = 0;
//create with mainloop
@@ -2386,7 +2309,7 @@ SceneTree::SceneTree() {
if (env.is_valid()) {
root->get_world()->set_fallback_environment(env);
} else {
- if (is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
//file was erased, clear the field.
ProjectSettings::get_singleton()->set("rendering/environment/default_environment", "");
} else {
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 3543ebee90..594b806cef 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -111,9 +111,6 @@ private:
bool quit_on_go_back;
uint32_t last_id;
-#ifdef TOOLS_ENABLED
- bool editor_hint;
-#endif
#ifdef DEBUG_ENABLED
bool debug_collisions_hint;
bool debug_navigation_hint;
@@ -202,6 +199,8 @@ private:
void _connection_failed();
void _server_disconnected();
+ int rpc_sender_id;
+
//path sent caches
struct PathSentCache {
Map<int, bool> confirmed_peers;
@@ -363,14 +362,8 @@ public:
_FORCE_INLINE_ float get_idle_process_time() const { return idle_process_time; }
#ifdef TOOLS_ENABLED
- void set_editor_hint(bool p_enabled);
-
- bool is_editor_hint() const;
bool is_node_being_edited(const Node *p_node) const;
#else
- void set_editor_hint(bool p_enabled) {}
-
- bool is_editor_hint() const { return false; }
bool is_node_being_edited(const Node *p_node) const { return false; }
#endif
@@ -454,6 +447,7 @@ public:
bool has_network_peer() const;
int get_network_unique_id() const;
Vector<int> get_network_connected_peers() const;
+ int get_rpc_sender_id() const;
void set_refuse_new_network_connections(bool p_refuse);
bool is_refusing_new_network_connections() const;
@@ -465,5 +459,6 @@ public:
VARIANT_ENUM_CAST(SceneTree::StretchMode);
VARIANT_ENUM_CAST(SceneTree::StretchAspect);
+VARIANT_ENUM_CAST(SceneTree::CallGroupFlags);
#endif
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index a61d1100e6..df7d609ac0 100755
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "timer.h"
+#include "engine.h"
+
void Timer::_notification(int p_what) {
switch (p_what) {
@@ -37,7 +39,7 @@ void Timer::_notification(int p_what) {
if (autostart) {
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
break;
#endif
start();
@@ -202,8 +204,8 @@ void Timer::_bind_methods() {
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);
+ BIND_ENUM_CONSTANT(TIMER_PROCESS_FIXED);
+ BIND_ENUM_CONSTANT(TIMER_PROCESS_IDLE);
}
Timer::Timer() {
diff --git a/scene/main/timer.h b/scene/main/timer.h
index dd4711ec37..0cd92f12de 100755
--- a/scene/main/timer.h
+++ b/scene/main/timer.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 717e76c5fd..02da926e50 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,28 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "viewport.h"
+
#include "os/input.h"
#include "os/os.h"
-#include "scene/3d/spatial.h"
-#include "servers/physics_2d_server.h"
-//#include "scene/3d/camera.h"
-
+#include "project_settings.h"
+#include "scene/2d/collision_object_2d.h"
#include "scene/3d/camera.h"
#include "scene/3d/collision_object.h"
#include "scene/3d/listener.h"
-#include "scene/3d/spatial_indexer.h"
+#include "scene/3d/scenario_fx.h"
+#include "scene/3d/spatial.h"
#include "scene/gui/control.h"
-#include "scene/resources/mesh.h"
-
-#include "scene/2d/collision_object_2d.h"
-
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
#include "scene/main/timer.h"
+#include "scene/resources/mesh.h"
#include "scene/scene_string_names.h"
-
-#include "project_settings.h"
-#include "scene/3d/scenario_fx.h"
+#include "servers/physics_2d_server.h"
void ViewportTexture::setup_local_to_scene() {
@@ -68,7 +63,7 @@ void ViewportTexture::setup_local_to_scene() {
ERR_EXPLAIN("ViewportTexture: Path to node is invalid");
ERR_FAIL_COND(!vpn);
- vp = vpn->cast_to<Viewport>();
+ vp = Object::cast_to<Viewport>(vpn);
ERR_EXPLAIN("ViewportTexture: Path to node does not point to a viewport");
ERR_FAIL_COND(!vp);
@@ -337,22 +332,18 @@ void Viewport::_test_new_mouseover(ObjectID new_collider) {
if (new_collider != physics_object_over) {
if (physics_object_over) {
- Object *obj = ObjectDB::get_instance(physics_object_over);
- if (obj) {
- CollisionObject *co = obj->cast_to<CollisionObject>();
- if (co) {
- co->_mouse_exit();
- }
+
+ CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_over));
+ if (co) {
+ co->_mouse_exit();
}
}
if (new_collider) {
- Object *obj = ObjectDB::get_instance(new_collider);
- if (obj) {
- CollisionObject *co = obj->cast_to<CollisionObject>();
- if (co) {
- co->_mouse_enter();
- }
+
+ CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(new_collider));
+ if (co) {
+ co->_mouse_enter();
}
}
@@ -399,7 +390,7 @@ void Viewport::_notification(int p_what) {
contact_3d_debug_instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario());
- VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
+ //VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
}
VS::get_singleton()->viewport_set_active(viewport, true);
@@ -552,7 +543,7 @@ void Viewport::_notification(int p_what) {
for (int i = 0; i < rc; i++) {
if (res[i].collider_id && res[i].collider) {
- CollisionObject2D *co = res[i].collider->cast_to<CollisionObject2D>();
+ CollisionObject2D *co = Object::cast_to<CollisionObject2D>(res[i].collider);
if (co) {
Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.find(res[i].collider_id);
@@ -575,7 +566,7 @@ void Viewport::_notification(int p_what) {
Object *o = ObjectDB::get_instance(E->key());
if (o) {
- CollisionObject2D *co = o->cast_to<CollisionObject2D>();
+ CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o);
if (co) {
co->_mouse_exit();
}
@@ -595,19 +586,14 @@ void Viewport::_notification(int p_what) {
if (physics_object_capture != 0) {
- Object *obj = ObjectDB::get_instance(physics_object_capture);
- if (obj) {
- CollisionObject *co = obj->cast_to<CollisionObject>();
- if (co) {
- co->_input_event(camera, ev, Vector3(), Vector3(), 0);
- captured = true;
- if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) {
- physics_object_capture = 0;
- }
-
- } else {
+ CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_capture));
+ if (co) {
+ co->_input_event(camera, ev, Vector3(), Vector3(), 0);
+ captured = true;
+ if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) {
physics_object_capture = 0;
}
+
} else {
physics_object_capture = 0;
}
@@ -640,18 +626,15 @@ void Viewport::_notification(int p_what) {
ObjectID new_collider = 0;
if (col) {
- if (result.collider) {
-
- CollisionObject *co = result.collider->cast_to<CollisionObject>();
- if (co) {
+ CollisionObject *co = Object::cast_to<CollisionObject>(result.collider);
+ if (co) {
- co->_input_event(camera, ev, result.position, result.normal, result.shape);
- last_object = co;
- last_id = result.collider_id;
- new_collider = last_id;
- if (co->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
- physics_object_capture = last_id;
- }
+ co->_input_event(camera, ev, result.position, result.normal, result.shape);
+ last_object = co;
+ last_id = result.collider_id;
+ new_collider = last_id;
+ if (co->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
+ physics_object_capture = last_id;
}
}
}
@@ -678,11 +661,9 @@ void Viewport::_notification(int p_what) {
bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, 0xFFFFFFFF, true);
ObjectID new_collider = 0;
if (col) {
- if (result.collider) {
- CollisionObject *co = result.collider->cast_to<CollisionObject>();
- if (co) {
- new_collider = result.collider_id;
- }
+ CollisionObject *co = Object::cast_to<CollisionObject>(result.collider);
+ if (co) {
+ new_collider = result.collider_id;
}
}
@@ -750,7 +731,7 @@ 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_in_tree()))) {
+ if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (Object::cast_to<Control>(get_parent()) && Object::cast_to<Control>(get_parent())->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());
@@ -761,7 +742,7 @@ void Viewport::_update_listener() {
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_in_tree())))
+ if (is_inside_tree() && audio_listener && (!get_parent() || (Object::cast_to<Control>(get_parent()) && Object::cast_to<Control>(get_parent())->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());
@@ -1029,11 +1010,11 @@ void Viewport::_propagate_enter_world(Node *p_node) {
if (!p_node->is_inside_tree()) //may not have entered scene yet
return;
- if (p_node->cast_to<Spatial>() || p_node->cast_to<WorldEnvironment>()) {
+ if (Object::cast_to<Spatial>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
p_node->notification(Spatial::NOTIFICATION_ENTER_WORLD);
} else {
- Viewport *v = p_node->cast_to<Viewport>();
+ Viewport *v = Object::cast_to<Viewport>(p_node);
if (v) {
if (v->world.is_valid())
@@ -1053,7 +1034,7 @@ void Viewport::_propagate_viewport_notification(Node *p_node, int p_what) {
p_node->notification(p_what);
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (c->cast_to<Viewport>())
+ if (Object::cast_to<Viewport>(c))
continue;
_propagate_viewport_notification(c, p_what);
}
@@ -1066,11 +1047,11 @@ void Viewport::_propagate_exit_world(Node *p_node) {
if (!p_node->is_inside_tree()) //may have exited scene already
return;
- if (p_node->cast_to<Spatial>() || p_node->cast_to<WorldEnvironment>()) {
+ if (Object::cast_to<Spatial>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
p_node->notification(Spatial::NOTIFICATION_EXIT_WORLD);
} else {
- Viewport *v = p_node->cast_to<Viewport>();
+ Viewport *v = Object::cast_to<Viewport>(p_node);
if (v) {
if (v->world.is_valid())
@@ -1194,44 +1175,7 @@ bool Viewport::is_size_override_stretch_enabled() const {
return size_override_stretch;
}
-#if 0
-void Viewport::set_as_render_target(bool p_enable){
-
-/* if (render_target==p_enable)
- return;
-
- render_target=p_enable;
-
- VS::get_singleton()->viewport_set_as_render_target(viewport,p_enable);
- if (is_inside_tree()) {
-
- if (p_enable)
- _vp_exit_tree();
- else
- _vp_enter_tree();
- }
-
- if (p_enable) {
-
- texture_rid = VS::get_singleton()->viewport_get_texture(viewport);
- } else {
-
- texture_rid=RID();
- }
-
- texture->set_flags(texture->flags);
- texture->emit_changed();
-
- update_configuration_warning();
- */
-}
-
-bool Viewport::is_set_as_render_target() const{
-
- return render_target;
-}
-#endif
void Viewport::set_update_mode(UpdateMode p_mode) {
update_mode = p_mode;
@@ -1241,7 +1185,6 @@ Viewport::UpdateMode Viewport::get_update_mode() const {
return update_mode;
}
-//RID get_texture() const;
Ref<ViewportTexture> Viewport::get_texture() const {
@@ -1354,7 +1297,7 @@ void Viewport::_vp_input(const Ref<InputEvent> &p_ev) {
return;
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
}
#endif
@@ -1374,7 +1317,7 @@ void Viewport::_vp_unhandled_input(const Ref<InputEvent> &p_ev) {
if (disable_input)
return;
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
}
#endif
@@ -1456,6 +1399,10 @@ void Viewport::_gui_show_tooltip() {
gui.tooltip_popup = NULL;
}
+ if (!gui.tooltip) {
+ return;
+ }
+
Control *rp = gui.tooltip->get_root_parent_control();
if (!rp)
return;
@@ -1473,8 +1420,8 @@ void Viewport::_gui_show_tooltip() {
gui.tooltip_label->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, ttp->get_margin(MARGIN_LEFT));
gui.tooltip_label->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, ttp->get_margin(MARGIN_TOP));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, ttp->get_margin(MARGIN_RIGHT));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, ttp->get_margin(MARGIN_BOTTOM));
+ gui.tooltip_label->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -ttp->get_margin(MARGIN_RIGHT));
+ gui.tooltip_label->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -ttp->get_margin(MARGIN_BOTTOM));
gui.tooltip_label->set_text(tooltip);
Rect2 r(gui.tooltip_pos + Point2(10, 10), gui.tooltip_label->get_combined_minimum_size() + ttp->get_minimum_size());
Rect2 vr = gui.tooltip_label->get_viewport_rect();
@@ -1510,12 +1457,12 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
mb->get_button_index() == BUTTON_WHEEL_LEFT ||
mb->get_button_index() == BUTTON_WHEEL_RIGHT));
- bool ismouse = ev.is_valid() || p_input->cast_to<InputEventMouseMotion>() != NULL;
+ bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != NULL;
CanvasItem *ci = p_control;
while (ci) {
- Control *control = ci->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(ci);
if (control) {
control->call_multilevel(SceneStringNames::get_singleton()->_gui_input, ev);
if (gui.key_event_accepted)
@@ -1588,10 +1535,10 @@ Control *Viewport::_gui_find_control(const Point2 &p_global) {
Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform) {
- if (p_node->cast_to<Viewport>())
+ if (Object::cast_to<Viewport>(p_node))
return NULL;
- Control *c = p_node->cast_to<Control>();
+ Control *c = Object::cast_to<Control>(p_node);
if (c) {
//print_line("at "+String(c->get_path())+" POS "+c->get_position()+" bt "+p_xform);
@@ -1616,7 +1563,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
if (p_node == gui.tooltip_popup)
continue;
- CanvasItem *ci = p_node->get_child(i)->cast_to<CanvasItem>();
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i));
if (!ci || ci->is_set_as_toplevel())
continue;
@@ -1645,7 +1592,7 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
CanvasItem *ci = p_at_control;
while (ci) {
- Control *control = ci->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(ci);
if (control) {
if (control->can_drop_data(p_at_pos, gui.drag_data)) {
@@ -1770,7 +1717,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
CanvasItem *ci = gui.mouse_focus;
while (ci) {
- Control *control = ci->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(ci);
if (control) {
if (control->get_focus_mode() != Control::FOCUS_NONE) {
if (control != gui.key_focus) {
@@ -1891,7 +1838,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
CanvasItem *ci = gui.mouse_focus;
while (ci) {
- Control *control = ci->cast_to<Control>();
+ Control *control = Object::cast_to<Control>(ci);
if (control) {
gui.drag_data = control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos) - gui.drag_accum);
@@ -1932,8 +1879,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Control *top = gui.modal_stack.back()->get();
if (over != top && !top->is_a_parent_of(over)) {
-
- return; // don't send motion event to anything below modal stack top
+ over = NULL; //nothing can be found outside the modal stack
}
}
@@ -2237,7 +2183,7 @@ void Viewport::_gui_remove_from_modal_stack(List<Control *>::Element *MI, Object
if (!next) { //top of stack
Object *pfo = ObjectDB::get_instance(p_prev_focus_owner);
- Control *pfoc = pfo->cast_to<Control>();
+ Control *pfoc = Object::cast_to<Control>(pfo);
if (!pfoc)
return;
@@ -2267,7 +2213,7 @@ void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control *
void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
ERR_FAIL_NULL(p_control);
- ERR_FAIL_COND(!((Object *)p_control)->cast_to<Control>());
+ ERR_FAIL_COND(!Object::cast_to<Control>((Object *)p_control));
ERR_FAIL_COND(p_control->is_inside_tree());
ERR_FAIL_COND(p_control->get_parent() != NULL);
@@ -2442,14 +2388,18 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event) {
get_tree()->_call_input_pause(unhandled_input_group, "_unhandled_input", p_event);
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev);
- if (!get_tree()->input_handled && p_event->cast_to<InputEventKey>() != NULL) {
+ if (!get_tree()->input_handled && Object::cast_to<InputEventKey>(*p_event) != NULL) {
get_tree()->_call_input_pause(unhandled_key_input_group, "_unhandled_key_input", p_event);
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev);
}
if (physics_object_picking && !get_tree()->input_handled) {
- if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED && (p_event->cast_to<InputEventMouseButton>() || p_event->cast_to<InputEventMouseMotion>() || p_event->cast_to<InputEventScreenDrag>() || p_event->cast_to<InputEventScreenTouch>())) {
+ if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED &&
+ (Object::cast_to<InputEventMouseButton>(*p_event) ||
+ Object::cast_to<InputEventMouseMotion>(*p_event) ||
+ Object::cast_to<InputEventScreenDrag>(*p_event) ||
+ Object::cast_to<InputEventScreenTouch>(*p_event))) {
physics_picking_events.push_back(p_event);
}
}
@@ -2564,7 +2514,7 @@ Control *Viewport::get_modal_stack_top() const {
String Viewport::get_configuration_warning() const {
- /*if (get_parent() && !get_parent()->cast_to<Control>() && !render_target) {
+ /*if (get_parent() && !Object::cast_to<Control>(get_parent()) && !render_target) {
return TTR("This viewport is not set as render target. If you intend for it to display its contents directly to the screen, make it a child of a Control so it can obtain a size. Otherwise, make it a RenderTarget and assign its internal texture to some node for display.");
}*/
@@ -2742,7 +2692,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "use_arvr");
- ADD_PROPERTY(PropertyInfo(Variant::RECT2, "size"), "set_size", "get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "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") ;
@@ -2773,38 +2723,38 @@ void Viewport::_bind_methods() {
ADD_SIGNAL(MethodInfo("size_changed"));
- BIND_CONSTANT(UPDATE_DISABLED);
- BIND_CONSTANT(UPDATE_ONCE);
- BIND_CONSTANT(UPDATE_WHEN_VISIBLE);
- BIND_CONSTANT(UPDATE_ALWAYS);
-
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_4);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_16);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_64);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_256);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1024);
- BIND_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_MAX);
-
- BIND_CONSTANT(RENDER_INFO_OBJECTS_IN_FRAME);
- BIND_CONSTANT(RENDER_INFO_VERTICES_IN_FRAME);
- BIND_CONSTANT(RENDER_INFO_MATERIAL_CHANGES_IN_FRAME);
- BIND_CONSTANT(RENDER_INFO_SHADER_CHANGES_IN_FRAME);
- BIND_CONSTANT(RENDER_INFO_SURFACE_CHANGES_IN_FRAME);
- BIND_CONSTANT(RENDER_INFO_DRAW_CALLS_IN_FRAME);
- BIND_CONSTANT(RENDER_INFO_MAX);
-
- BIND_CONSTANT(DEBUG_DRAW_DISABLED);
- BIND_CONSTANT(DEBUG_DRAW_UNSHADED);
- BIND_CONSTANT(DEBUG_DRAW_OVERDRAW);
- BIND_CONSTANT(DEBUG_DRAW_WIREFRAME);
-
- BIND_CONSTANT(MSAA_DISABLED);
- BIND_CONSTANT(MSAA_2X);
- BIND_CONSTANT(MSAA_4X);
- BIND_CONSTANT(MSAA_8X);
- BIND_CONSTANT(MSAA_16X);
+ BIND_ENUM_CONSTANT(UPDATE_DISABLED);
+ BIND_ENUM_CONSTANT(UPDATE_ONCE);
+ BIND_ENUM_CONSTANT(UPDATE_WHEN_VISIBLE);
+ BIND_ENUM_CONSTANT(UPDATE_ALWAYS);
+
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_4);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_16);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_64);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_256);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1024);
+ BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_MAX);
+
+ BIND_ENUM_CONSTANT(RENDER_INFO_OBJECTS_IN_FRAME);
+ BIND_ENUM_CONSTANT(RENDER_INFO_VERTICES_IN_FRAME);
+ BIND_ENUM_CONSTANT(RENDER_INFO_MATERIAL_CHANGES_IN_FRAME);
+ BIND_ENUM_CONSTANT(RENDER_INFO_SHADER_CHANGES_IN_FRAME);
+ BIND_ENUM_CONSTANT(RENDER_INFO_SURFACE_CHANGES_IN_FRAME);
+ BIND_ENUM_CONSTANT(RENDER_INFO_DRAW_CALLS_IN_FRAME);
+ BIND_ENUM_CONSTANT(RENDER_INFO_MAX);
+
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_DISABLED);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_UNSHADED);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_OVERDRAW);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_WIREFRAME);
+
+ BIND_ENUM_CONSTANT(MSAA_DISABLED);
+ BIND_ENUM_CONSTANT(MSAA_2X);
+ BIND_ENUM_CONSTANT(MSAA_4X);
+ BIND_ENUM_CONSTANT(MSAA_8X);
+ BIND_ENUM_CONSTANT(MSAA_16X);
}
Viewport::Viewport() {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 83c989db54..f527fa4f5b 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 3e6d80d314..e01f5e3cdf 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,21 +28,44 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_scene_types.h"
-#include "os/os.h"
-#include "project_settings.h"
-#include "scene/io/resource_format_image.h"
-#include "scene/io/resource_format_wav.h"
-
-//#include "scene/io/scene_format_script.h"
-#include "class_db.h"
-#include "resources/default_theme/default_theme.h"
+
+#include "core/class_db.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
+#include "scene/2d/animated_sprite.h"
+#include "scene/2d/area_2d.h"
+#include "scene/2d/audio_stream_player_2d.h"
+#include "scene/2d/back_buffer_copy.h"
+#include "scene/2d/camera_2d.h"
+#include "scene/2d/canvas_item.h"
+#include "scene/2d/canvas_modulate.h"
+#include "scene/2d/collision_polygon_2d.h"
+#include "scene/2d/collision_shape_2d.h"
+#include "scene/2d/joints_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/light_occluder_2d.h"
+#include "scene/2d/line_2d.h"
+#include "scene/2d/navigation2d.h"
+#include "scene/2d/parallax_background.h"
+#include "scene/2d/parallax_layer.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/path_2d.h"
+#include "scene/2d/physics_body_2d.h"
+#include "scene/2d/polygon_2d.h"
+#include "scene/2d/position_2d.h"
+#include "scene/2d/ray_cast_2d.h"
+#include "scene/2d/remote_transform_2d.h"
+#include "scene/2d/screen_button.h"
+#include "scene/2d/sprite.h"
+#include "scene/2d/tile_map.h"
+#include "scene/2d/visibility_notifier_2d.h"
+#include "scene/2d/y_sort.h"
+#include "scene/animation/animation_player.h"
+#include "scene/animation/animation_tree_player.h"
+#include "scene/animation/tween.h"
+#include "scene/audio/audio_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
-
#include "scene/gui/button_group.h"
#include "scene/gui/center_container.h"
#include "scene/gui/check_box.h"
@@ -88,154 +111,85 @@
#include "scene/main/canvas_layer.h"
#include "scene/main/http_request.h"
#include "scene/main/instance_placeholder.h"
-#include "scene/main/viewport.h"
-#include "scene/resources/audio_stream_sample.h"
-#include "scene/resources/video_stream.h"
-
-#include "scene/2d/animated_sprite.h"
-#include "scene/2d/back_buffer_copy.h"
-#include "scene/2d/canvas_item.h"
-#include "scene/2d/polygon_2d.h"
-#include "scene/2d/sprite.h"
-
-#include "scene/2d/visibility_notifier_2d.h"
-
-#include "scene/2d/area_2d.h"
-#include "scene/2d/camera_2d.h"
-#include "scene/2d/collision_polygon_2d.h"
-#include "scene/2d/collision_shape_2d.h"
-#include "scene/2d/joints_2d.h"
-#include "scene/2d/parallax_background.h"
-#include "scene/2d/parallax_layer.h"
-#include "scene/2d/physics_body_2d.h"
-#include "scene/2d/ray_cast_2d.h"
-//#include "scene/2d/sound_player_2d.h"
-//#include "scene/2d/sample_player_2d.h"
-#include "scene/2d/audio_stream_player_2d.h"
-#include "scene/2d/canvas_modulate.h"
-#include "scene/2d/navigation2d.h"
-#include "scene/2d/remote_transform_2d.h"
-#include "scene/2d/screen_button.h"
-#include "scene/2d/y_sort.h"
-
-#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"
-#include "scene/animation/animation_tree_player.h"
-#include "scene/animation/tween.h"
#include "scene/main/resource_preloader.h"
#include "scene/main/scene_tree.h"
-#include "scene/resources/packed_scene.h"
-
-#include "scene/resources/mesh_data_tool.h"
-#include "scene/resources/surface_tool.h"
-
-#include "scene/resources/dynamic_font.h"
-#include "scene/resources/dynamic_font_stb.h"
-
#include "scene/main/timer.h"
-
-#include "scene/audio/audio_player.h"
-//#include "scene/audio/event_player.h"
-//#include "scene/audio/sound_room_params.h"
+#include "scene/main/viewport.h"
+#include "scene/resources/audio_stream_sample.h"
+#include "scene/resources/bit_mask.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/plane_shape.h"
-#include "scene/resources/ray_shape.h"
-#include "scene/resources/sphere_shape.h"
-
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
+#include "scene/resources/color_ramp.h"
+#include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/concave_polygon_shape_2d.h"
+#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/convex_polygon_shape_2d.h"
+#include "scene/resources/default_theme/default_theme.h"
+#include "scene/resources/dynamic_font.h"
+#include "scene/resources/dynamic_font_stb.h"
+#include "scene/resources/material.h"
+#include "scene/resources/mesh.h"
+#include "scene/resources/mesh_data_tool.h"
+#include "scene/resources/mesh_library.h"
+#include "scene/resources/packed_scene.h"
+#include "scene/resources/plane_shape.h"
+#include "scene/resources/polygon_path_finder.h"
+#include "scene/resources/primitive_meshes.h"
+#include "scene/resources/ray_shape.h"
#include "scene/resources/rectangle_shape_2d.h"
+#include "scene/resources/scene_format_text.h"
#include "scene/resources/segment_shape_2d.h"
+#include "scene/resources/shader_graph.h"
#include "scene/resources/shape_line_2d.h"
-
-#include "scene/resources/mesh_library.h"
-
-#include "scene/resources/polygon_path_finder.h"
-
-//#include "scene/resources/sample.h"
-#include "scene/3d/audio_stream_player_3d.h"
-#include "scene/resources/material.h"
-#include "scene/resources/mesh.h"
-#include "scene/resources/room.h"
#include "scene/resources/sky_box.h"
+#include "scene/resources/sphere_shape.h"
+#include "scene/resources/surface_tool.h"
#include "scene/resources/texture.h"
-
-#include "scene/resources/primitive_meshes.h"
-
-#include "scene/resources/shader_graph.h"
-
+#include "scene/resources/tile_set.h"
+#include "scene/resources/video_stream.h"
#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/bit_mask.h"
-#include "scene/resources/color_ramp.h"
-#include "scene/resources/gibberish_stream.h"
#include "scene/scene_string_names.h"
-#include "scene/3d/bone_attachment.h"
-#include "scene/3d/path.h"
-#include "scene/3d/remote_transform.h"
-#include "scene/3d/room_instance.h"
-#include "scene/3d/scenario_fx.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
-
-#include "scene/3d/visibility_notifier.h"
-
#ifndef _3D_DISABLED
-#include "scene/3d/camera.h"
-#include "scene/3d/listener.h"
-
+#include "scene/3d/area.h"
#include "scene/3d/arvr_nodes.h"
-
+#include "scene/3d/audio_stream_player_3d.h"
+#include "scene/3d/bone_attachment.h"
+#include "scene/3d/camera.h"
+#include "scene/3d/collision_polygon.h"
+#include "scene/3d/collision_shape.h"
#include "scene/3d/gi_probe.h"
+#include "scene/3d/immediate_geometry.h"
#include "scene/3d/interpolated_camera.h"
#include "scene/3d/light.h"
+#include "scene/3d/listener.h"
#include "scene/3d/mesh_instance.h"
+#include "scene/3d/multimesh_instance.h"
+#include "scene/3d/navigation.h"
+#include "scene/3d/navigation_mesh.h"
#include "scene/3d/particles.h"
+#include "scene/3d/path.h"
#include "scene/3d/physics_body.h"
+#include "scene/3d/physics_joint.h"
#include "scene/3d/portal.h"
#include "scene/3d/position_3d.h"
-#include "scene/3d/reflection_probe.h"
-#include "scene/resources/environment.h"
-
-#include "scene/3d/area.h"
-
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/immediate_geometry.h"
-#include "scene/3d/multimesh_instance.h"
-#include "scene/3d/physics_joint.h"
+#include "scene/3d/proximity_group.h"
#include "scene/3d/ray_cast.h"
+#include "scene/3d/reflection_probe.h"
+#include "scene/3d/remote_transform.h"
+#include "scene/3d/room_instance.h"
+#include "scene/3d/scenario_fx.h"
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
#include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body.h"
-//#include "scene/3d/spatial_sample_player.h"
-//#include "scene/3d/spatial_stream_player.h"
-#include "scene/3d/collision_polygon.h"
-#include "scene/3d/navigation.h"
-#include "scene/3d/navigation_mesh.h"
-#include "scene/3d/proximity_group.h"
+#include "scene/3d/visibility_notifier.h"
+#include "scene/resources/environment.h"
#endif
-#include "scene/resources/scene_format_text.h"
-
-//static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
-
-#ifdef TOOLS_ENABLED
-
-#endif
static ResourceFormatLoaderTheme *resource_loader_theme = NULL;
static ResourceFormatSaverText *resource_saver_text = NULL;
@@ -245,8 +199,6 @@ static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL;
static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture = NULL;
-//static SceneStringNames *string_names;
-
void register_scene_types() {
SceneStringNames::create();
@@ -255,20 +207,12 @@ void register_scene_types() {
Node::init_node_hrcr();
- //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!
-
-#endif
-
resource_loader_theme = memnew(ResourceFormatLoaderTheme);
ResourceLoader::add_resource_format_loader(resource_loader_theme);
@@ -316,7 +260,6 @@ void register_scene_types() {
ClassDB::register_class<ShortCut>();
ClassDB::register_class<Control>();
- //ClassDB::register_type<EmptyControl>();
ClassDB::register_class<Button>();
ClassDB::register_class<Label>();
ClassDB::register_class<HScrollBar>();
@@ -424,7 +367,6 @@ void register_scene_types() {
ClassDB::register_class<GIProbe>();
ClassDB::register_class<GIProbeData>();
ClassDB::register_class<AnimationTreePlayer>();
- ClassDB::register_class<Portal>();
ClassDB::register_class<Particles>();
ClassDB::register_class<Position3D>();
ClassDB::register_class<NavigationMeshInstance>();
@@ -446,14 +388,12 @@ void register_scene_types() {
ClassDB::register_class<CollisionPolygon>();
ClassDB::register_class<RayCast>();
ClassDB::register_class<MultiMeshInstance>();
- ClassDB::register_class<Room>();
+
ClassDB::register_class<Curve3D>();
ClassDB::register_class<Path>();
ClassDB::register_class<PathFollow>();
ClassDB::register_class<VisibilityNotifier>();
ClassDB::register_class<VisibilityEnabler>();
- // ClassDB::register_class<BakedLight>();
- //ClassDB::register_type<BakedLightSampler>();
ClassDB::register_class<WorldEnvironment>();
ClassDB::register_class<RemoteTransform>();
@@ -464,8 +404,6 @@ void register_scene_types() {
ClassDB::register_class<ConeTwistJoint>();
ClassDB::register_class<Generic6DOFJoint>();
- //scenariofx
-
OS::get_singleton()->yield(); //may take time to init
#endif
@@ -545,8 +483,6 @@ void register_scene_types() {
SceneTree::add_idle_callback(ParticlesMaterial::flush_changes);
ParticlesMaterial::init_shaders();
- //ClassDB::register_type<ShaderMaterial>();
- ClassDB::register_class<RoomBounds>();
ClassDB::register_class<MultiMesh>();
ClassDB::register_class<MeshLibrary>();
@@ -562,7 +498,6 @@ void register_scene_types() {
ClassDB::register_class<SurfaceTool>();
ClassDB::register_class<MeshDataTool>();
- //ClassDB::register_type<BakedLight>();
OS::get_singleton()->yield(); //may take time to init
@@ -661,14 +596,8 @@ void unregister_scene_types() {
clear_default_theme();
- // memdelete( resource_loader_wav );
memdelete(resource_loader_dynamic_font);
memdelete(resource_loader_stream_texture);
-
-#ifdef TOOLS_ENABLED
-
-#endif
-
memdelete(resource_loader_theme);
if (resource_saver_text) {
diff --git a/scene/register_scene_types.h b/scene/register_scene_types.h
index dee0af9063..956b12a7cd 100644
--- a/scene/register_scene_types.h
+++ b/scene/register_scene_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 459d3ffe41..1a2c8333ef 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "animation.h"
+
#include "geometry.h"
bool Animation::_set(const StringName &p_name, const Variant &p_value) {
@@ -83,44 +84,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
TransformTrack *tt = static_cast<TransformTrack *>(tracks[track]);
PoolVector<float> values = p_value;
int vcount = values.size();
-
-#if 0 // old compatibility hack
- if ((vcount%11) == 0) {
-
-
- PoolVector<float>::Read r = values.read();
-
- tt->transforms.resize(vcount/11);
-
-
- for(int i=0;i<(vcount/11);i++) {
-
-
- TKey<TransformKey> &tk=tt->transforms[i];
- const float *ofs=&r[i*11];
- tk.time=ofs[0];
-
- tk.value.loc.x=ofs[1];
- tk.value.loc.y=ofs[2];
- tk.value.loc.z=ofs[3];
-
- tk.value.rot.x=ofs[4];
- tk.value.rot.y=ofs[5];
- tk.value.rot.z=ofs[6];
- tk.value.rot.w=ofs[7];
-
- tk.value.scale.x=ofs[8];
- tk.value.scale.y=ofs[9];
- tk.value.scale.z=ofs[10];
-
-
- }
- return true;
-
-
-
- }
-#endif
ERR_FAIL_COND_V(vcount % 12, false); // shuld be multiple of 11
PoolVector<float>::Read r = values.read();
@@ -733,7 +696,7 @@ int Animation::track_find_key(int p_track, float p_time, bool p_exact) const {
return -1;
}
-void Animation::track_insert_key(int p_track, float p_time, const Variant &p_value, float p_transition) {
+void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key, float p_transition) {
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
@@ -742,7 +705,7 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_val
case TYPE_TRANSFORM: {
- Dictionary d = p_value;
+ Dictionary d = p_key;
Vector3 loc;
if (d.has("loc"))
loc = d["loc"];
@@ -766,7 +729,7 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_val
TKey<Variant> k;
k.time = p_time;
k.transition = p_transition;
- k.value = p_value;
+ k.value = p_key;
_insert(p_time, vt->values, k);
} break;
@@ -774,9 +737,9 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_val
MethodTrack *mt = static_cast<MethodTrack *>(t);
- ERR_FAIL_COND(p_value.get_type() != Variant::DICTIONARY);
+ ERR_FAIL_COND(p_key.get_type() != Variant::DICTIONARY);
- Dictionary d = p_value;
+ Dictionary d = p_key;
ERR_FAIL_COND(!d.has("method") || d["method"].get_type() != Variant::STRING);
ERR_FAIL_COND(!d.has("args") || !d["args"].is_array());
@@ -1676,17 +1639,17 @@ void Animation::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &Animation::clear);
- BIND_CONSTANT(TYPE_VALUE);
- BIND_CONSTANT(TYPE_TRANSFORM);
- BIND_CONSTANT(TYPE_METHOD);
+ BIND_ENUM_CONSTANT(TYPE_VALUE);
+ BIND_ENUM_CONSTANT(TYPE_TRANSFORM);
+ BIND_ENUM_CONSTANT(TYPE_METHOD);
- BIND_CONSTANT(INTERPOLATION_NEAREST);
- BIND_CONSTANT(INTERPOLATION_LINEAR);
- BIND_CONSTANT(INTERPOLATION_CUBIC);
+ BIND_ENUM_CONSTANT(INTERPOLATION_NEAREST);
+ BIND_ENUM_CONSTANT(INTERPOLATION_LINEAR);
+ BIND_ENUM_CONSTANT(INTERPOLATION_CUBIC);
- BIND_CONSTANT(UPDATE_CONTINUOUS);
- BIND_CONSTANT(UPDATE_DISCRETE);
- BIND_CONSTANT(UPDATE_TRIGGER);
+ BIND_ENUM_CONSTANT(UPDATE_CONTINUOUS);
+ BIND_ENUM_CONSTANT(UPDATE_DISCRETE);
+ BIND_ENUM_CONSTANT(UPDATE_TRIGGER);
}
void Animation::clear() {
@@ -1871,7 +1834,7 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
return erase;
}
-void Animation::_transform_track_optimize(int p_idx, float p_alowed_linear_err, float p_alowed_angular_err, float p_max_optimizable_angle) {
+void Animation::_transform_track_optimize(int p_idx, float p_allowed_linear_err, float p_allowed_angular_err, float p_max_optimizable_angle) {
ERR_FAIL_INDEX(p_idx, tracks.size());
ERR_FAIL_COND(tracks[p_idx]->type != TYPE_TRANSFORM);
@@ -1887,12 +1850,12 @@ void Animation::_transform_track_optimize(int p_idx, float p_alowed_linear_err,
TKey<TransformKey> &t1 = tt->transforms[i];
TKey<TransformKey> &t2 = tt->transforms[i + 1];
- bool erase = _transform_track_optimize_key(t0, t1, t2, p_alowed_linear_err, p_alowed_angular_err, p_max_optimizable_angle, norm);
+ bool erase = _transform_track_optimize_key(t0, t1, t2, p_allowed_linear_err, p_allowed_angular_err, p_max_optimizable_angle, norm);
if (erase && !prev_erased) {
norm = (t2.value.loc - t1.value.loc).normalized();
}
- if (prev_erased && !_transform_track_optimize_key(t0, first_erased, t2, p_alowed_linear_err, p_alowed_angular_err, p_max_optimizable_angle, norm)) {
+ if (prev_erased && !_transform_track_optimize_key(t0, first_erased, t2, p_allowed_linear_err, p_allowed_angular_err, p_max_optimizable_angle, norm)) {
//avoid error to go beyond first erased key
erase = false;
}
@@ -1914,12 +1877,12 @@ void Animation::_transform_track_optimize(int p_idx, float p_alowed_linear_err,
}
}
-void Animation::optimize(float p_allowed_linear_err, float p_allowed_angular_err, float p_angle_max) {
+void Animation::optimize(float p_allowed_linear_err, float p_allowed_angular_err, float p_max_optimizable_angle) {
for (int i = 0; i < tracks.size(); i++) {
if (tracks[i]->type == TYPE_TRANSFORM)
- _transform_track_optimize(i, p_allowed_linear_err, p_allowed_angular_err, p_angle_max);
+ _transform_track_optimize(i, p_allowed_linear_err, p_allowed_angular_err, p_max_optimizable_angle);
}
}
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index b363f2b666..e653f6b124 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -212,7 +212,7 @@ private:
}
bool _transform_track_optimize_key(const TKey<TransformKey> &t0, const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err, float p_alowed_angular_err, float p_max_optimizable_angle, const Vector3 &p_norm);
- void _transform_track_optimize(int p_idx, float p_allowed_err = 0.05, float p_alowed_angular_err = 0.01, float p_max_optimizable_angle = Math_PI * 0.125);
+ void _transform_track_optimize(int p_idx, float p_allowed_linear_err = 0.05, float p_allowed_angular_err = 0.01, float p_max_optimizable_angle = Math_PI * 0.125);
protected:
bool _set(const StringName &p_name, const Variant &p_value);
diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp
deleted file mode 100644
index 1b1d6f8587..0000000000
--- a/scene/resources/audio_stream_resampled.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/*************************************************************************/
-/* audio_stream_resampled.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "audio_stream_resampled.h"
-#include "project_settings.h"
-
-#if 0
-int AudioStreamResampled::get_channel_count() const {
-
- if (!rb)
- return 0;
-
- return channels;
-}
-
-
-template<int C>
-uint32_t AudioStreamResampled::_resample(int32_t *p_dest,int p_todo,int32_t p_increment) {
-
- uint32_t read=offset&MIX_FRAC_MASK;
-
- for (int i=0;i<p_todo;i++) {
-
- offset = (offset + p_increment)&(((1<<(rb_bits+MIX_FRAC_BITS))-1));
- read+=p_increment;
- uint32_t pos = offset >> MIX_FRAC_BITS;
- uint32_t frac = offset & MIX_FRAC_MASK;
-#ifndef FAST_AUDIO
- ERR_FAIL_COND_V(pos>=rb_len,0);
-#endif
- uint32_t pos_next = (pos+1)&rb_mask;
- //printf("rb pos %i\n",pos);
-
- // since this is a template with a known compile time value (C), conditionals go away when compiling.
- if (C==1) {
-
- int32_t v0 = rb[pos];
- int32_t v0n=rb[pos_next];
-#ifndef FAST_AUDIO
- v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS;
-#endif
- v0<<=16;
- p_dest[i]=v0;
-
- }
- if (C==2) {
-
- int32_t v0 = rb[(pos<<1)+0];
- int32_t v1 = rb[(pos<<1)+1];
- int32_t v0n=rb[(pos_next<<1)+0];
- int32_t v1n=rb[(pos_next<<1)+1];
-
-#ifndef FAST_AUDIO
- v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS;
- v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS;
-#endif
- v0<<=16;
- v1<<=16;
- p_dest[(i<<1)+0]=v0;
- p_dest[(i<<1)+1]=v1;
-
- }
-
- if (C==4) {
-
- int32_t v0 = rb[(pos<<2)+0];
- int32_t v1 = rb[(pos<<2)+1];
- int32_t v2 = rb[(pos<<2)+2];
- int32_t v3 = rb[(pos<<2)+3];
- int32_t v0n = rb[(pos_next<<2)+0];
- int32_t v1n=rb[(pos_next<<2)+1];
- int32_t v2n=rb[(pos_next<<2)+2];
- int32_t v3n=rb[(pos_next<<2)+3];
-
-#ifndef FAST_AUDIO
- v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS;
- v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS;
- v2+=(v2n-v2)*(int32_t)frac >> MIX_FRAC_BITS;
- v3+=(v3n-v3)*(int32_t)frac >> MIX_FRAC_BITS;
-#endif
- v0<<=16;
- v1<<=16;
- v2<<=16;
- v3<<=16;
- p_dest[(i<<2)+0]=v0;
- p_dest[(i<<2)+1]=v1;
- p_dest[(i<<2)+2]=v2;
- p_dest[(i<<2)+3]=v3;
-
- }
-
- if (C==6) {
-
- int32_t v0 = rb[(pos*6)+0];
- int32_t v1 = rb[(pos*6)+1];
- int32_t v2 = rb[(pos*6)+2];
- int32_t v3 = rb[(pos*6)+3];
- int32_t v4 = rb[(pos*6)+4];
- int32_t v5 = rb[(pos*6)+5];
- int32_t v0n = rb[(pos_next*6)+0];
- int32_t v1n=rb[(pos_next*6)+1];
- int32_t v2n=rb[(pos_next*6)+2];
- int32_t v3n=rb[(pos_next*6)+3];
- int32_t v4n=rb[(pos_next*6)+4];
- int32_t v5n=rb[(pos_next*6)+5];
-
-#ifndef FAST_AUDIO
- v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS;
- v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS;
- v2+=(v2n-v2)*(int32_t)frac >> MIX_FRAC_BITS;
- v3+=(v3n-v3)*(int32_t)frac >> MIX_FRAC_BITS;
- v4+=(v4n-v4)*(int32_t)frac >> MIX_FRAC_BITS;
- v5+=(v5n-v5)*(int32_t)frac >> MIX_FRAC_BITS;
-#endif
- v0<<=16;
- v1<<=16;
- v2<<=16;
- v3<<=16;
- v4<<=16;
- v5<<=16;
- p_dest[(i*6)+0]=v0;
- p_dest[(i*6)+1]=v1;
- p_dest[(i*6)+2]=v2;
- p_dest[(i*6)+3]=v3;
- p_dest[(i*6)+4]=v4;
- p_dest[(i*6)+5]=v5;
-
- }
-
-
- }
-
-
- return read>>MIX_FRAC_BITS;//rb_read_pos=offset>>MIX_FRAC_BITS;
-
-}
-
-
-bool AudioStreamResampled::mix(int32_t *p_dest, int p_frames) {
-
-
- if (!rb || !_can_mix())
- return false;
-
- int write_pos_cache=rb_write_pos;
-
- int32_t increment=(mix_rate*MIX_FRAC_LEN)/get_mix_rate();
-
- int rb_todo;
-
- if (write_pos_cache==rb_read_pos) {
- return false; //out of buffer
-
- } else if (rb_read_pos<write_pos_cache) {
-
- rb_todo=write_pos_cache-rb_read_pos; //-1?
- } else {
-
- rb_todo=(rb_len-rb_read_pos)+write_pos_cache; //-1?
- }
-
- int todo = MIN( ((int64_t(rb_todo)<<MIX_FRAC_BITS)/increment)+1, p_frames );
-#if 0
- if (int(mix_rate)==get_mix_rate()) {
-
-
- if (channels==6) {
-
- for(int i=0;i<p_frames;i++) {
-
- int from = ((rb_read_pos+i)&rb_mask)*6;
- int to = i*6;
-
- p_dest[from+0]=int32_t(rb[to+0])<<16;
- p_dest[from+1]=int32_t(rb[to+1])<<16;
- p_dest[from+2]=int32_t(rb[to+2])<<16;
- p_dest[from+3]=int32_t(rb[to+3])<<16;
- p_dest[from+4]=int32_t(rb[to+4])<<16;
- p_dest[from+5]=int32_t(rb[to+5])<<16;
- }
-
- } else {
- int len=p_frames*channels;
- int from=rb_read_pos*channels;
- int mask=0;
- switch(channels) {
- case 1: mask=rb_len-1; break;
- case 2: mask=(rb_len*2)-1; break;
- case 4: mask=(rb_len*4)-1; break;
- }
-
- for(int i=0;i<len;i++) {
-
- p_dest[i]=int32_t(rb[(from+i)&mask])<<16;
- }
- }
-
- rb_read_pos = (rb_read_pos+p_frames)&rb_mask;
- } else
-#endif
- {
-
- uint32_t read=0;
- switch(channels) {
- case 1: read=_resample<1>(p_dest,todo,increment); break;
- case 2: read=_resample<2>(p_dest,todo,increment); break;
- case 4: read=_resample<4>(p_dest,todo,increment); break;
- case 6: read=_resample<6>(p_dest,todo,increment); break;
- }
-#if 1
- //end of stream, fadeout
- int remaining = p_frames-todo;
- if (remaining && todo>0) {
-
- //print_line("fadeout");
- for(int c=0;c<channels;c++) {
-
- for(int i=0;i<todo;i++) {
-
- int32_t samp = p_dest[i*channels+c]>>8;
- uint32_t mul = (todo-i) * 256 /todo;
- //print_line("mul: "+itos(i)+" "+itos(mul));
- p_dest[i*channels+c]=samp*mul;
- }
-
- }
-
- }
-
-#else
- int remaining = p_frames-todo;
- if (remaining && todo>0) {
-
-
- for(int c=0;c<channels;c++) {
-
- int32_t from = p_dest[(todo-1)*channels+c]>>8;
-
- for(int i=0;i<remaining;i++) {
-
- uint32_t mul = (remaining-i) * 256 /remaining;
- p_dest[(todo+i)*channels+c]=from*mul;
- }
-
- }
-
- }
-#endif
-
- //zero out what remains there to avoid glitches
- for(int i=todo*channels;i<int(p_frames)*channels;i++) {
-
- p_dest[i]=0;
- }
-
- if (read>rb_todo)
- read=rb_todo;
-
- rb_read_pos = (rb_read_pos+read)&rb_mask;
-
-
-
-
- }
-
- return true;
-}
-
-
-Error AudioStreamResampled::_setup(int p_channels,int p_mix_rate,int p_minbuff_needed) {
-
- ERR_FAIL_COND_V(p_channels!=1 && p_channels!=2 && p_channels!=4 && p_channels!=6,ERR_INVALID_PARAMETER);
-
-
- float buffering_sec = int(GLOBAL_DEF("audio/stream_buffering_ms",500))/1000.0;
- int desired_rb_bits =nearest_shift(MAX(buffering_sec*p_mix_rate,p_minbuff_needed));
-
- bool recreate=!rb;
-
- if (rb && (uint32_t(desired_rb_bits)!=rb_bits || channels!=uint32_t(p_channels))) {
- //recreate
-
- memdelete_arr(rb);
- memdelete_arr(read_buf);
- recreate=true;
-
- }
-
- if (recreate) {
-
- channels=p_channels;
- rb_bits=desired_rb_bits;
- rb_len=(1<<rb_bits);
- rb_mask=rb_len-1;
- rb = memnew_arr( int16_t, rb_len * p_channels );
- read_buf = memnew_arr( int16_t, rb_len * p_channels );
-
- }
-
- mix_rate=p_mix_rate;
- offset=0;
- rb_read_pos=0;
- rb_write_pos=0;
-
- //avoid maybe strange noises upon load
- for (int i=0;i<(rb_len*channels);i++) {
-
- rb[i]=0;
- read_buf[i]=0;
- }
-
- return OK;
-
-}
-
-void AudioStreamResampled::_clear() {
-
- if (!rb)
- return;
-
- AudioServer::get_singleton()->lock();
- //should be stopped at this point but just in case
- if (rb) {
- memdelete_arr(rb);
- memdelete_arr(read_buf);
- }
- rb=NULL;
- offset=0;
- rb_read_pos=0;
- rb_write_pos=0;
- read_buf=NULL;
- AudioServer::get_singleton()->unlock();
-
-}
-
-AudioStreamResampled::AudioStreamResampled() {
-
- rb=NULL;
- offset=0;
- read_buf=NULL;
- rb_read_pos=0;
- rb_write_pos=0;
-
- rb_bits=0;
- rb_len=0;
- rb_mask=0;
- read_buff_len=0;
- channels=0;
- mix_rate=0;
-
-}
-
-AudioStreamResampled::~AudioStreamResampled() {
-
- if (rb) {
- memdelete_arr(rb);
- memdelete_arr(read_buf);
- }
-
-}
-
-#endif
diff --git a/scene/resources/audio_stream_resampled.h b/scene/resources/audio_stream_resampled.h
deleted file mode 100644
index 53fa3bd0b9..0000000000
--- a/scene/resources/audio_stream_resampled.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*************************************************************************/
-/* audio_stream_resampled.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef AUDIO_STREAM_RESAMPLED_H
-#define AUDIO_STREAM_RESAMPLED_H
-
-//#include "scene/resources/audio_stream.h"
-
-#if 0
-
-class AudioStreamResampled : public AudioStream {
- GDCLASS(AudioStreamResampled,AudioStream);
-
- uint32_t rb_bits;
- uint32_t rb_len;
- uint32_t rb_mask;
- uint32_t read_buff_len;
- uint32_t channels;
- uint32_t mix_rate;
-
- volatile int rb_read_pos;
- volatile int rb_write_pos;
-
- int32_t offset; //contains the fractional remainder of the resampler
- enum {
- MIX_FRAC_BITS=13,
- MIX_FRAC_LEN=(1<<MIX_FRAC_BITS),
- MIX_FRAC_MASK=MIX_FRAC_LEN-1,
- };
-
- int16_t *read_buf;
- int16_t *rb;
-
-
- template<int C>
- uint32_t _resample(int32_t *p_dest,int p_todo,int32_t p_increment);
-
-
-protected:
-
- _FORCE_INLINE_ int get_total() const {
-
- return rb_len;
- }
-
- _FORCE_INLINE_ int get_todo() const { //return amount of frames to mix
-
- int todo;
- int read_pos_cache=rb_read_pos;
-
- if (read_pos_cache==rb_write_pos) {
- todo=rb_len-1;
- } else if (read_pos_cache>rb_write_pos) {
-
- todo=read_pos_cache-rb_write_pos-1;
- } else {
-
- todo=(rb_len-rb_write_pos)+read_pos_cache-1;
- }
-
- return todo;
- }
-
- //Stream virtual funcs
- virtual int get_channel_count() const;
- virtual bool mix(int32_t *p_dest, int p_frames);
-
- _FORCE_INLINE_ void _flush() {
- rb_read_pos=0;
- rb_write_pos=0;
- }
-
- _FORCE_INLINE_ int16_t *get_write_buffer() { return read_buf; }
- _FORCE_INLINE_ void write(uint32_t p_frames) {
-
- ERR_FAIL_COND(p_frames >= rb_len);
-
- switch(channels) {
- case 1: {
-
- for(uint32_t i=0;i<p_frames;i++) {
-
- rb[ rb_write_pos ] = read_buf[i];
- rb_write_pos=(rb_write_pos+1)&rb_mask;
- }
- } break;
- case 2: {
-
- for(uint32_t i=0;i<p_frames;i++) {
-
- rb[ (rb_write_pos<<1)+0 ] = read_buf[(i<<1)+0];
- rb[ (rb_write_pos<<1)+1 ] = read_buf[(i<<1)+1];
- rb_write_pos=(rb_write_pos+1)&rb_mask;
- }
- } break;
- case 4: {
-
- for(uint32_t i=0;i<p_frames;i++) {
-
- rb[ (rb_write_pos<<2)+0 ] = read_buf[(i<<2)+0];
- rb[ (rb_write_pos<<2)+1 ] = read_buf[(i<<2)+1];
- rb[ (rb_write_pos<<2)+2 ] = read_buf[(i<<2)+2];
- rb[ (rb_write_pos<<2)+3 ] = read_buf[(i<<2)+3];
- rb_write_pos=(rb_write_pos+1)&rb_mask;
- }
- } break;
- case 6: {
-
- for(uint32_t i=0;i<p_frames;i++) {
-
- rb[ (rb_write_pos*6)+0 ] = read_buf[(i*6)+0];
- rb[ (rb_write_pos*6)+1 ] = read_buf[(i*6)+1];
- rb[ (rb_write_pos*6)+2 ] = read_buf[(i*6)+2];
- rb[ (rb_write_pos*6)+3 ] = read_buf[(i*6)+3];
- rb[ (rb_write_pos*6)+4 ] = read_buf[(i*6)+4];
- rb[ (rb_write_pos*6)+5 ] = read_buf[(i*6)+5];
- rb_write_pos=(rb_write_pos+1)&rb_mask;
- }
- } break;
-
-
- }
-
- }
-
- virtual bool _can_mix() const =0;
-
- _FORCE_INLINE_ bool _is_ready() const{
- return rb!=NULL;
- }
-
- Error _setup(int p_channels,int p_mix_rate,int p_minbuff_needed=-1);
- void _clear();
-
-public:
- AudioStreamResampled();
- ~AudioStreamResampled();
-};
-#endif
-#endif // AUDIO_STREAM_RESAMPLED_H
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index c8f6007e60..659322897a 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h
index 680f037f15..6cb255fedf 100644
--- a/scene/resources/audio_stream_sample.h
+++ b/scene/resources/audio_stream_sample.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index a473067937..be994e3b33 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/bit_mask.h b/scene/resources/bit_mask.h
index 5ab7a3134d..72090f2ebe 100644
--- a/scene/resources/bit_mask.h
+++ b/scene/resources/bit_mask.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/bounds.cpp b/scene/resources/bounds.cpp
index b088426013..ee1e750c82 100644
--- a/scene/resources/bounds.cpp
+++ b/scene/resources/bounds.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/bounds.h b/scene/resources/bounds.h
index 8c0d1dcf6e..3378101836 100644
--- a/scene/resources/bounds.h
+++ b/scene/resources/bounds.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp
index d5c25b718e..bbc85ce0f6 100644
--- a/scene/resources/box_shape.cpp
+++ b/scene/resources/box_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/box_shape.h b/scene/resources/box_shape.h
index fdf1e98020..8884c9b75a 100644
--- a/scene/resources/box_shape.h
+++ b/scene/resources/box_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/canvas.cpp b/scene/resources/canvas.cpp
index b6a909f3fa..f5bf0ad78e 100644
--- a/scene/resources/canvas.cpp
+++ b/scene/resources/canvas.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/canvas.h b/scene/resources/canvas.h
index 331a997914..b9977e11b9 100644
--- a/scene/resources/canvas.h
+++ b/scene/resources/canvas.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp
index 1fcc9da5b6..e11b98f82e 100644
--- a/scene/resources/capsule_shape.cpp
+++ b/scene/resources/capsule_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/capsule_shape.h b/scene/resources/capsule_shape.h
index 2864e7e23f..9b43823c83 100644
--- a/scene/resources/capsule_shape.h
+++ b/scene/resources/capsule_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 20177692a1..56a09bc3bf 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/capsule_shape_2d.h b/scene/resources/capsule_shape_2d.h
index 93e7d846a4..610f9a4cf9 100644
--- a/scene/resources/capsule_shape_2d.h
+++ b/scene/resources/capsule_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index 1b7e09ddfb..ecfc98ea60 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/circle_shape_2d.h b/scene/resources/circle_shape_2d.h
index a4a4601e66..3ba5ec949c 100644
--- a/scene/resources/circle_shape_2d.h
+++ b/scene/resources/circle_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index 1825225abd..9f6150ae63 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -149,7 +149,7 @@ void Gradient::set_offset(int pos, const float offset) {
}
float Gradient::get_offset(int pos) const {
- if (points.size() > pos)
+ if (points.size() && points.size() > pos)
return points[pos].offset;
return 0; //TODO: Maybe throw some error instead?
}
@@ -164,7 +164,7 @@ void Gradient::set_color(int pos, const Color &color) {
}
Color Gradient::get_color(int pos) const {
- if (points.size() > pos)
+ if (points.size() && points.size() > pos)
return points[pos].color;
return Color(0, 0, 0, 1); //TODO: Maybe throw some error instead?
}
diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h
index d7ec20b324..816152d51f 100644
--- a/scene/resources/color_ramp.h
+++ b/scene/resources/color_ramp.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -60,7 +60,7 @@ public:
void add_point(float p_offset, const Color &p_color);
void remove_point(int p_index);
- void set_points(Vector<Point> &points);
+ void set_points(Vector<Point> &p_points);
Vector<Point> &get_points();
void set_offset(int pos, const float offset);
@@ -69,10 +69,10 @@ public:
void set_color(int pos, const Color &color);
Color get_color(int pos) const;
- void set_offsets(const Vector<float> &offsets);
+ void set_offsets(const Vector<float> &p_offsets);
Vector<float> get_offsets() const;
- void set_colors(const Vector<Color> &colors);
+ void set_colors(const Vector<Color> &p_colors);
Vector<Color> get_colors() const;
_FORCE_INLINE_ Color get_color_at_offset(float p_offset) {
diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp
index 47cc49c631..6ae4fde85e 100644
--- a/scene/resources/concave_polygon_shape.cpp
+++ b/scene/resources/concave_polygon_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/concave_polygon_shape.h b/scene/resources/concave_polygon_shape.h
index a8f9d50674..82e052fee7 100644
--- a/scene/resources/concave_polygon_shape.h
+++ b/scene/resources/concave_polygon_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index b8c931421e..7f4abf7ae0 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/concave_polygon_shape_2d.h b/scene/resources/concave_polygon_shape_2d.h
index d4c102e0d6..e766e88a4b 100644
--- a/scene/resources/concave_polygon_shape_2d.h
+++ b/scene/resources/concave_polygon_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index 10e92b43ae..bba52bd5ff 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/convex_polygon_shape.h b/scene/resources/convex_polygon_shape.h
index 4340b0ef7c..e103f2d90c 100644
--- a/scene/resources/convex_polygon_shape.h
+++ b/scene/resources/convex_polygon_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index e13f7faf70..7588909d90 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/convex_polygon_shape_2d.h b/scene/resources/convex_polygon_shape_2d.h
index ba4a5ae8aa..3354199e05 100644
--- a/scene/resources/convex_polygon_shape_2d.h
+++ b/scene/resources/convex_polygon_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index fe0759fcba..7fbaa1f73c 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "curve.h"
+
#include "core_string_names.h"
template <class T>
@@ -42,344 +43,6 @@ static _FORCE_INLINE_ T _bezier_interp(real_t t, T start, T control_1, T control
return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
}
-#if 0
-
-int Curve2D::get_point_count() const {
-
- return points.size();
-}
-void Curve2D::add_point(const Vector2& p_pos, const Vector2& p_in, const Vector2& p_out) {
-
- Point n;
- n.pos=p_pos;
- n.in=p_in;
- n.out=p_out;
- points.push_back(n);
- emit_signal(CoreStringNames::get_singleton()->changed);
-}
-void Curve2D::set_point_pos(int p_index, const Vector2& p_pos) {
-
- ERR_FAIL_INDEX(p_index,points.size());
-
- points[p_index].pos=p_pos;
- emit_signal(CoreStringNames::get_singleton()->changed);
-
-}
-Vector2 Curve2D::get_point_pos(int p_index) const {
-
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector2());
- return points[p_index].pos;
-
-}
-
-
-void Curve2D::set_point_in(int p_index, const Vector2& p_in) {
-
- ERR_FAIL_INDEX(p_index,points.size());
-
- points[p_index].in=p_in;
- emit_signal(CoreStringNames::get_singleton()->changed);
-
-}
-Vector2 Curve2D::get_point_in(int p_index) const {
-
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector2());
- return points[p_index].in;
-
-}
-
-void Curve2D::set_point_out(int p_index, const Vector2& p_out) {
-
- ERR_FAIL_INDEX(p_index,points.size());
-
- points[p_index].out=p_out;
- emit_signal(CoreStringNames::get_singleton()->changed);
-}
-
-Vector2 Curve2D::get_point_out(int p_index) const {
-
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector2());
- return points[p_index].out;
-
-}
-
-
-void Curve2D::remove_point(int p_index) {
-
- ERR_FAIL_INDEX(p_index,points.size());
- points.remove(p_index);
- emit_signal(CoreStringNames::get_singleton()->changed);
-}
-
-Vector2 Curve2D::interpolate(int p_index, float p_offset) const {
-
- int pc = points.size();
- ERR_FAIL_COND_V(pc==0,Vector2());
-
- if (p_index >= pc-1)
- return points[pc-1].pos;
- else if (p_index<0)
- return points[0].pos;
-
- Vector2 p0 = points[p_index].pos;
- Vector2 p1 = p0+points[p_index].out;
- Vector2 p3 = points[p_index+1].pos;
- Vector2 p2 = p3+points[p_index+1].in;
-
- return _bezier_interp(p_offset,p0,p1,p2,p3);
-}
-
-Vector2 Curve2D::interpolatef(real_t p_findex) const {
-
-
- if (p_findex<0)
- p_findex=0;
- else if (p_findex>=points.size())
- p_findex=points.size();
-
- return interpolate((int)p_findex,Math::fmod(p_findex,1.0));
-
-}
-
-PoolVector<Point2> Curve2D::bake(int p_subdivs) const {
-
- int pc = points.size();
-
- PoolVector<Point2> ret;
- if (pc<2)
- return ret;
-
- ret.resize((pc-1)*p_subdivs+1);
-
- PoolVector<Point2>::Write w = ret.write();
- const Point *r = points.ptr();
-
- for(int i=0;i<pc;i++) {
-
- int ofs = pc*p_subdivs;
-
- int limit=(i==pc-1)?p_subdivs+1:p_subdivs;
-
- for(int j=0;j<limit;j++) {
-
- Vector2 p0 = r[i].pos;
- Vector2 p1 = p0+r[i].out;
- Vector2 p3 = r[i].pos;
- Vector2 p2 = p3+r[i].in;
- real_t t = j/(real_t)p_subdivs;
-
- w[ofs+j]=_bezier_interp(t,p0,p1,p2,p3);
-
- }
- }
-
- w = PoolVector<Point2>::Write();
-
- return ret;
-}
-
-void Curve2D::advance(real_t p_distance,int &r_index, real_t &r_pos) const {
-
- int pc = points.size();
- ERR_FAIL_COND(pc<2);
- if (r_index<0 || r_index>=(pc-1))
- return;
-
- Vector2 pos = interpolate(r_index,r_pos);
-
- float sign=p_distance<0 ? -1 : 1;
- p_distance=Math::abs(p_distance);
-
- real_t base = r_index+r_pos;
- real_t top = 0.1; //a tenth is in theory representative
- int iterations=32;
-
-
-
- for(int i=0;i<iterations;i++) {
-
-
- real_t o=base+top*sign;
- if (sign>0 && o >=pc) {
- top=pc-base;
- break;
- } else if (sign<0 && o <0) {
- top=-base;
- break;
- }
-
- Vector2 new_d = interpolatef(o);
-
- if (new_d.distance_to(pos) > p_distance)
- break;
- top*=2.0;
- }
-
-
- real_t bottom = 0.0;
- iterations=8;
- real_t final_offset;
-
-
- for(int i=0;i<iterations;i++) {
-
- real_t middle = (bottom+top)*0.5;
- real_t o=base+middle*sign;
- Vector2 new_d = interpolatef(o);
-
- if (new_d.distance_to(pos) > p_distance) {
- bottom=middle;
- } else {
- top=middle;
- }
- final_offset=o;
- }
-
- r_index=(int)final_offset;
- r_pos=Math::fmod(final_offset,1.0);
-
-}
-
-void Curve2D::get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs) const {
-
- ERR_FAIL_COND(points.size()<2);
-
- real_t accum=0;
-
-
-
- for(int i=0;i<points.size();i++) {
-
- Vector2 prev_p=interpolate(i,0);
-
-
- for(int j=1;j<=p_subdivs;j++) {
-
- real_t frac = j/(real_t)p_subdivs;
- Vector2 p = interpolate(i,frac);
- real_t d = p.distance_to(prev_p);
-
- accum+=d;
- if (accum>p_offset) {
-
-
- r_index=j-1;
- if (d>0) {
- real_t mf = (p_offset-(accum-d)) / d;
- r_pos=frac-(1.0-mf);
- } else {
- r_pos=frac;
- }
-
- return;
- }
-
- prev_p=p;
- }
- }
-
- r_index=points.size()-1;
- r_pos=1.0;
-
-
-}
-
-void Curve2D::set_points_in(const Vector2Array& p_points) {
-
- points.resize(p_points.size());
- for (int i=0; i<p_points.size(); i++) {
-
- Point p = points[i];
- p.in = p_points[i];
- points[i] = p;
- };
-};
-
-void Curve2D::set_points_out(const Vector2Array& p_points) {
-
- points.resize(p_points.size());
- for (int i=0; i<p_points.size(); i++) {
-
- Point p = points[i];
- p.out = p_points[i];
- points[i] = p;
- };
-};
-
-void Curve2D::set_points_pos(const Vector2Array& p_points) {
-
- points.resize(p_points.size());
- for (int i=0; i<p_points.size(); i++) {
-
- Point p = points[i];
- p.pos = p_points[i];
- points[i] = p;
- };
-};
-
-Vector2Array Curve2D::get_points_in() const {
- Vector2Array ret;
- ret.resize(points.size());
- for (int i=0; i<points.size(); i++) {
- ret.set(i, points[i].in);
- };
- return ret;
-};
-
-Vector2Array Curve2D::get_points_out() const {
- Vector2Array ret;
- ret.resize(points.size());
- for (int i=0; i<points.size(); i++) {
- ret.set(i, points[i].out);
- };
- return ret;
-};
-
-Vector2Array Curve2D::get_points_pos() const {
- Vector2Array ret;
- ret.resize(points.size());
- for (int i=0; i<points.size(); i++) {
- ret.set(i, points[i].pos);
- };
- return ret;
-};
-
-
-void Curve2D::_bind_methods() {
-
- 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(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(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"), "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");
-}
-
-
-Curve2D::Curve2D()
-{
-}
-
-#endif
-
const char *Curve::SIGNAL_RANGE_CHANGED = "range_changed";
Curve::Curve() {
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 2815c12c4b..3071aee5de 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -31,56 +31,6 @@
#define CURVE_H
#include "resource.h"
-#if 0
-class Curve2D : public Resource {
-
- GDCLASS(Curve2D,Resource);
-
- struct Point {
-
- Vector2 in;
- Vector2 out;
- Vector2 pos;
- };
-
-
- Vector<Point> points;
-
-protected:
-
- static void _bind_methods();
-
- void set_points_in(const Vector2Array& p_points_in);
- void set_points_out(const Vector2Array& p_points_out);
- void set_points_pos(const Vector2Array& p_points_pos);
-
- Vector2Array get_points_in() const;
- Vector2Array get_points_out() const;
- Vector2Array get_points_pos() const;
-
-public:
-
-
- int get_point_count() const;
- void add_point(const Vector2& p_pos, const Vector2& p_in=Vector2(), const Vector2& p_out=Vector2());
- void set_point_pos(int p_index, const Vector2& p_pos);
- Vector2 get_point_pos(int p_index) const;
- void set_point_in(int p_index, const Vector2& p_in);
- Vector2 get_point_in(int p_index) const;
- void set_point_out(int p_index, const Vector2& p_out);
- Vector2 get_point_out(int p_index) const;
- void remove_point(int p_index);
-
- Vector2 interpolate(int p_index, float p_offset) const;
- Vector2 interpolatef(real_t p_findex) const;
- PoolVector<Point2> bake(int p_subdivs=10) const;
- void advance(real_t p_distance,int &r_index, real_t &r_pos) const;
- void get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs=16) const;
-
- Curve2D();
-};
-
-#endif
// y(x) curve
class Curve : public Resource {
@@ -174,7 +124,7 @@ public:
void bake();
int get_bake_resolution() const { return _bake_resolution; }
- void set_bake_resolution(int p_interval);
+ void set_bake_resolution(int p_resolution);
real_t interpolate_baked(real_t offset);
protected:
@@ -242,7 +192,7 @@ public:
Vector2 interpolate(int p_index, float p_offset) const;
Vector2 interpolatef(real_t p_findex) const;
- void set_bake_interval(float p_distance);
+ void set_bake_interval(float p_tolerance);
float get_bake_interval() const;
float get_baked_length() const;
@@ -309,7 +259,7 @@ public:
Vector3 interpolate(int p_index, float p_offset) const;
Vector3 interpolatef(real_t p_findex) const;
- void set_bake_interval(float p_distance);
+ void set_bake_interval(float p_tolerance);
float get_bake_interval() const;
float get_baked_length() const;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 3e612c745f..08de33175a 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -203,7 +203,7 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margi
return style;
}
-void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale) {
+void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale) {
scale = p_scale;
@@ -223,7 +223,7 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
// Panel
- t->set_stylebox("panel", "Panel", make_stylebox(panel_bg_png, 0, 0, 0, 0));
+ theme->set_stylebox("panel", "Panel", make_stylebox(panel_bg_png, 0, 0, 0, 0));
// Focus
@@ -240,63 +240,63 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
Ref<StyleBox> sb_button_disabled = sb_expand(make_stylebox(button_disabled_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
Ref<StyleBox> sb_button_focus = sb_expand(make_stylebox(button_focus_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
- t->set_stylebox("normal", "Button", sb_button_normal);
- t->set_stylebox("pressed", "Button", sb_button_pressed);
- t->set_stylebox("hover", "Button", sb_button_hover);
- t->set_stylebox("disabled", "Button", sb_button_disabled);
- t->set_stylebox("focus", "Button", sb_button_focus);
+ theme->set_stylebox("normal", "Button", sb_button_normal);
+ theme->set_stylebox("pressed", "Button", sb_button_pressed);
+ theme->set_stylebox("hover", "Button", sb_button_hover);
+ theme->set_stylebox("disabled", "Button", sb_button_disabled);
+ theme->set_stylebox("focus", "Button", sb_button_focus);
- t->set_font("font", "Button", default_font);
+ theme->set_font("font", "Button", default_font);
- t->set_color("font_color", "Button", control_font_color);
- t->set_color("font_color_pressed", "Button", control_font_color_pressed);
- t->set_color("font_color_hover", "Button", control_font_color_hover);
- t->set_color("font_color_disabled", "Button", control_font_color_disabled);
+ theme->set_color("font_color", "Button", control_font_color);
+ theme->set_color("font_color_pressed", "Button", control_font_color_pressed);
+ theme->set_color("font_color_hover", "Button", control_font_color_hover);
+ theme->set_color("font_color_disabled", "Button", control_font_color_disabled);
- t->set_constant("hseparation", "Button", 2 * scale);
+ theme->set_constant("hseparation", "Button", 2 * scale);
// LinkButton
- t->set_font("font", "LinkButton", default_font);
+ theme->set_font("font", "LinkButton", default_font);
- t->set_color("font_color", "LinkButton", control_font_color);
- t->set_color("font_color_pressed", "LinkButton", control_font_color_pressed);
- t->set_color("font_color_hover", "LinkButton", control_font_color_hover);
+ theme->set_color("font_color", "LinkButton", control_font_color);
+ theme->set_color("font_color_pressed", "LinkButton", control_font_color_pressed);
+ theme->set_color("font_color_hover", "LinkButton", control_font_color_hover);
- t->set_constant("underline_spacing", "LinkButton", 2 * scale);
+ theme->set_constant("underline_spacing", "LinkButton", 2 * scale);
// ColorPickerButton
- t->set_stylebox("normal", "ColorPickerButton", sb_button_normal);
- t->set_stylebox("pressed", "ColorPickerButton", sb_button_pressed);
- t->set_stylebox("hover", "ColorPickerButton", sb_button_hover);
- t->set_stylebox("disabled", "ColorPickerButton", sb_button_disabled);
- t->set_stylebox("focus", "ColorPickerButton", sb_button_focus);
+ theme->set_stylebox("normal", "ColorPickerButton", sb_button_normal);
+ theme->set_stylebox("pressed", "ColorPickerButton", sb_button_pressed);
+ theme->set_stylebox("hover", "ColorPickerButton", sb_button_hover);
+ theme->set_stylebox("disabled", "ColorPickerButton", sb_button_disabled);
+ theme->set_stylebox("focus", "ColorPickerButton", sb_button_focus);
- t->set_font("font", "ColorPickerButton", default_font);
+ theme->set_font("font", "ColorPickerButton", default_font);
- t->set_color("font_color", "ColorPickerButton", Color(1, 1, 1, 1));
- t->set_color("font_color_pressed", "ColorPickerButton", Color(0.8, 0.8, 0.8, 1));
- t->set_color("font_color_hover", "ColorPickerButton", Color(1, 1, 1, 1));
- t->set_color("font_color_disabled", "ColorPickerButton", Color(0.9, 0.9, 0.9, 0.3));
+ theme->set_color("font_color", "ColorPickerButton", Color(1, 1, 1, 1));
+ theme->set_color("font_color_pressed", "ColorPickerButton", Color(0.8, 0.8, 0.8, 1));
+ theme->set_color("font_color_hover", "ColorPickerButton", Color(1, 1, 1, 1));
+ theme->set_color("font_color_disabled", "ColorPickerButton", Color(0.9, 0.9, 0.9, 0.3));
- t->set_constant("hseparation", "ColorPickerButton", 2 * scale);
+ theme->set_constant("hseparation", "ColorPickerButton", 2 * scale);
// ToolButton
- t->set_stylebox("normal", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
- t->set_stylebox("pressed", "ToolButton", make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 4, 6, 4));
- t->set_stylebox("hover", "ToolButton", make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 4, 6, 4));
- t->set_stylebox("disabled", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
- t->set_stylebox("focus", "ToolButton", focus);
- t->set_font("font", "ToolButton", default_font);
+ theme->set_stylebox("normal", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
+ theme->set_stylebox("pressed", "ToolButton", make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 4, 6, 4));
+ theme->set_stylebox("hover", "ToolButton", make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 4, 6, 4));
+ theme->set_stylebox("disabled", "ToolButton", make_empty_stylebox(6, 4, 6, 4));
+ theme->set_stylebox("focus", "ToolButton", focus);
+ theme->set_font("font", "ToolButton", default_font);
- t->set_color("font_color", "ToolButton", control_font_color);
- t->set_color("font_color_pressed", "ToolButton", control_font_color_pressed);
- t->set_color("font_color_hover", "ToolButton", control_font_color_hover);
- t->set_color("font_color_disabled", "ToolButton", Color(0.9, 0.95, 1, 0.3));
+ theme->set_color("font_color", "ToolButton", control_font_color);
+ theme->set_color("font_color_pressed", "ToolButton", control_font_color_pressed);
+ theme->set_color("font_color_hover", "ToolButton", control_font_color_hover);
+ theme->set_color("font_color_disabled", "ToolButton", Color(0.9, 0.95, 1, 0.3));
- t->set_constant("hseparation", "ToolButton", 3);
+ theme->set_constant("hseparation", "ToolButton", 3);
// OptionButton
@@ -306,44 +306,44 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
Ref<StyleBox> sb_optbutton_disabled = sb_expand(make_stylebox(option_button_disabled_png, 4, 4, 21, 4, 6, 2, 21, 2), 2, 2, 2, 2);
Ref<StyleBox> sb_optbutton_focus = sb_expand(make_stylebox(button_focus_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
- t->set_stylebox("normal", "OptionButton", sb_optbutton_normal);
- t->set_stylebox("pressed", "OptionButton", sb_optbutton_pressed);
- t->set_stylebox("hover", "OptionButton", sb_optbutton_hover);
- t->set_stylebox("disabled", "OptionButton", sb_optbutton_disabled);
- t->set_stylebox("focus", "OptionButton", sb_button_focus);
+ theme->set_stylebox("normal", "OptionButton", sb_optbutton_normal);
+ theme->set_stylebox("pressed", "OptionButton", sb_optbutton_pressed);
+ theme->set_stylebox("hover", "OptionButton", sb_optbutton_hover);
+ theme->set_stylebox("disabled", "OptionButton", sb_optbutton_disabled);
+ theme->set_stylebox("focus", "OptionButton", sb_button_focus);
- t->set_icon("arrow", "OptionButton", make_icon(option_arrow_png));
+ theme->set_icon("arrow", "OptionButton", make_icon(option_arrow_png));
- t->set_font("font", "OptionButton", default_font);
+ theme->set_font("font", "OptionButton", default_font);
- t->set_color("font_color", "OptionButton", control_font_color);
- t->set_color("font_color_pressed", "OptionButton", control_font_color_pressed);
- t->set_color("font_color_hover", "OptionButton", control_font_color_hover);
- t->set_color("font_color_disabled", "OptionButton", control_font_color_disabled);
+ theme->set_color("font_color", "OptionButton", control_font_color);
+ theme->set_color("font_color_pressed", "OptionButton", control_font_color_pressed);
+ theme->set_color("font_color_hover", "OptionButton", control_font_color_hover);
+ theme->set_color("font_color_disabled", "OptionButton", control_font_color_disabled);
- t->set_constant("hseparation", "OptionButton", 2 * scale);
- t->set_constant("arrow_margin", "OptionButton", 2 * scale);
+ theme->set_constant("hseparation", "OptionButton", 2 * scale);
+ theme->set_constant("arrow_margin", "OptionButton", 2 * scale);
// MenuButton
- t->set_stylebox("normal", "MenuButton", sb_button_normal);
- t->set_stylebox("pressed", "MenuButton", sb_button_pressed);
- t->set_stylebox("hover", "MenuButton", sb_button_pressed);
- t->set_stylebox("disabled", "MenuButton", make_empty_stylebox(0, 0, 0, 0));
- t->set_stylebox("focus", "MenuButton", sb_button_focus);
+ theme->set_stylebox("normal", "MenuButton", sb_button_normal);
+ theme->set_stylebox("pressed", "MenuButton", sb_button_pressed);
+ theme->set_stylebox("hover", "MenuButton", sb_button_pressed);
+ theme->set_stylebox("disabled", "MenuButton", make_empty_stylebox(0, 0, 0, 0));
+ theme->set_stylebox("focus", "MenuButton", sb_button_focus);
- t->set_font("font", "MenuButton", default_font);
+ theme->set_font("font", "MenuButton", default_font);
- t->set_color("font_color", "MenuButton", control_font_color);
- t->set_color("font_color_pressed", "MenuButton", control_font_color_pressed);
- t->set_color("font_color_hover", "MenuButton", control_font_color_hover);
- t->set_color("font_color_disabled", "MenuButton", Color(1, 1, 1, 0.3));
+ theme->set_color("font_color", "MenuButton", control_font_color);
+ theme->set_color("font_color_pressed", "MenuButton", control_font_color_pressed);
+ theme->set_color("font_color_hover", "MenuButton", control_font_color_hover);
+ theme->set_color("font_color_disabled", "MenuButton", Color(1, 1, 1, 0.3));
- t->set_constant("hseparation", "MenuButton", 3 * scale);
+ theme->set_constant("hseparation", "MenuButton", 3 * scale);
// ButtonGroup
- t->set_stylebox("panel", "ButtonGroup", memnew(StyleBoxEmpty));
+ theme->set_stylebox("panel", "ButtonGroup", memnew(StyleBoxEmpty));
// CheckBox
@@ -358,26 +358,26 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
cbx_focus->set_default_margin(MARGIN_TOP, 4 * scale);
cbx_focus->set_default_margin(MARGIN_BOTTOM, 5 * scale);
- t->set_stylebox("normal", "CheckBox", cbx_empty);
- t->set_stylebox("pressed", "CheckBox", cbx_empty);
- t->set_stylebox("disabled", "CheckBox", cbx_empty);
- t->set_stylebox("hover", "CheckBox", cbx_empty);
- t->set_stylebox("focus", "CheckBox", cbx_focus);
+ theme->set_stylebox("normal", "CheckBox", cbx_empty);
+ theme->set_stylebox("pressed", "CheckBox", cbx_empty);
+ theme->set_stylebox("disabled", "CheckBox", cbx_empty);
+ theme->set_stylebox("hover", "CheckBox", cbx_empty);
+ theme->set_stylebox("focus", "CheckBox", cbx_focus);
- t->set_icon("checked", "CheckBox", make_icon(checked_png));
- t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
- t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
- t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
+ theme->set_icon("checked", "CheckBox", make_icon(checked_png));
+ theme->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
+ theme->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
+ theme->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
- t->set_font("font", "CheckBox", default_font);
+ theme->set_font("font", "CheckBox", default_font);
- t->set_color("font_color", "CheckBox", control_font_color);
- t->set_color("font_color_pressed", "CheckBox", control_font_color_pressed);
- t->set_color("font_color_hover", "CheckBox", control_font_color_hover);
- t->set_color("font_color_disabled", "CheckBox", control_font_color_disabled);
+ theme->set_color("font_color", "CheckBox", control_font_color);
+ theme->set_color("font_color_pressed", "CheckBox", control_font_color_pressed);
+ theme->set_color("font_color_hover", "CheckBox", control_font_color_hover);
+ theme->set_color("font_color_disabled", "CheckBox", control_font_color_disabled);
- t->set_constant("hseparation", "CheckBox", 4 * scale);
- t->set_constant("check_vadjust", "CheckBox", 0 * scale);
+ theme->set_constant("hseparation", "CheckBox", 4 * scale);
+ theme->set_constant("check_vadjust", "CheckBox", 0 * scale);
// CheckButton
@@ -387,170 +387,172 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
cb_empty->set_default_margin(MARGIN_TOP, 4 * scale);
cb_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale);
- t->set_stylebox("normal", "CheckButton", cb_empty);
- t->set_stylebox("pressed", "CheckButton", cb_empty);
- t->set_stylebox("disabled", "CheckButton", cb_empty);
- t->set_stylebox("hover", "CheckButton", cb_empty);
- t->set_stylebox("focus", "CheckButton", focus);
+ theme->set_stylebox("normal", "CheckButton", cb_empty);
+ theme->set_stylebox("pressed", "CheckButton", cb_empty);
+ theme->set_stylebox("disabled", "CheckButton", cb_empty);
+ theme->set_stylebox("hover", "CheckButton", cb_empty);
+ theme->set_stylebox("focus", "CheckButton", focus);
- t->set_icon("on", "CheckButton", make_icon(toggle_on_png));
- t->set_icon("off", "CheckButton", make_icon(toggle_off_png));
+ theme->set_icon("on", "CheckButton", make_icon(toggle_on_png));
+ theme->set_icon("off", "CheckButton", make_icon(toggle_off_png));
- t->set_font("font", "CheckButton", default_font);
+ theme->set_font("font", "CheckButton", default_font);
- t->set_color("font_color", "CheckButton", control_font_color);
- t->set_color("font_color_pressed", "CheckButton", control_font_color_pressed);
- t->set_color("font_color_hover", "CheckButton", control_font_color_hover);
- t->set_color("font_color_disabled", "CheckButton", control_font_color_disabled);
+ theme->set_color("font_color", "CheckButton", control_font_color);
+ theme->set_color("font_color_pressed", "CheckButton", control_font_color_pressed);
+ theme->set_color("font_color_hover", "CheckButton", control_font_color_hover);
+ theme->set_color("font_color_disabled", "CheckButton", control_font_color_disabled);
- t->set_constant("hseparation", "CheckButton", 4 * scale);
- t->set_constant("check_vadjust", "CheckButton", 0 * scale);
+ theme->set_constant("hseparation", "CheckButton", 4 * scale);
+ theme->set_constant("check_vadjust", "CheckButton", 0 * scale);
// Label
- t->set_font("font", "Label", default_font);
+ theme->set_font("font", "Label", default_font);
- t->set_color("font_color", "Label", Color(1, 1, 1));
- t->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
+ theme->set_color("font_color", "Label", Color(1, 1, 1));
+ theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
- t->set_constant("shadow_offset_x", "Label", 1 * scale);
- t->set_constant("shadow_offset_y", "Label", 1 * scale);
- t->set_constant("shadow_as_outline", "Label", 0 * scale);
- t->set_constant("line_spacing", "Label", 3 * scale);
+ theme->set_constant("shadow_offset_x", "Label", 1 * scale);
+ theme->set_constant("shadow_offset_y", "Label", 1 * scale);
+ theme->set_constant("shadow_as_outline", "Label", 0 * scale);
+ theme->set_constant("line_spacing", "Label", 3 * scale);
// LineEdit
- t->set_stylebox("normal", "LineEdit", make_stylebox(line_edit_png, 5, 5, 5, 5));
- t->set_stylebox("focus", "LineEdit", focus);
- t->set_stylebox("read_only", "LineEdit", make_stylebox(line_edit_disabled_png, 6, 6, 6, 6));
+ theme->set_stylebox("normal", "LineEdit", make_stylebox(line_edit_png, 5, 5, 5, 5));
+ theme->set_stylebox("focus", "LineEdit", focus);
+ theme->set_stylebox("read_only", "LineEdit", make_stylebox(line_edit_disabled_png, 6, 6, 6, 6));
- t->set_font("font", "LineEdit", default_font);
+ theme->set_font("font", "LineEdit", default_font);
- t->set_color("font_color", "LineEdit", control_font_color);
- t->set_color("font_color_selected", "LineEdit", Color(0, 0, 0));
- t->set_color("cursor_color", "LineEdit", control_font_color_hover);
- t->set_color("selection_color", "LineEdit", font_color_selection);
+ theme->set_color("font_color", "LineEdit", control_font_color);
+ theme->set_color("font_color_selected", "LineEdit", Color(0, 0, 0));
+ theme->set_color("cursor_color", "LineEdit", control_font_color_hover);
+ theme->set_color("selection_color", "LineEdit", font_color_selection);
- t->set_constant("minimum_spaces", "LineEdit", 12 * scale);
+ theme->set_constant("minimum_spaces", "LineEdit", 12 * scale);
// ProgressBar
- t->set_stylebox("bg", "ProgressBar", make_stylebox(progress_bar_png, 4, 4, 4, 4, 0, 0, 0, 0));
- t->set_stylebox("fg", "ProgressBar", make_stylebox(progress_fill_png, 6, 6, 6, 6, 2, 1, 2, 1));
+ theme->set_stylebox("bg", "ProgressBar", make_stylebox(progress_bar_png, 4, 4, 4, 4, 0, 0, 0, 0));
+ theme->set_stylebox("fg", "ProgressBar", make_stylebox(progress_fill_png, 6, 6, 6, 6, 2, 1, 2, 1));
- t->set_font("font", "ProgressBar", default_font);
+ theme->set_font("font", "ProgressBar", default_font);
- t->set_color("font_color", "ProgressBar", control_font_color_hover);
- t->set_color("font_color_shadow", "ProgressBar", Color(0, 0, 0));
+ theme->set_color("font_color", "ProgressBar", control_font_color_hover);
+ theme->set_color("font_color_shadow", "ProgressBar", Color(0, 0, 0));
// TextEdit
- t->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
- t->set_stylebox("focus", "TextEdit", focus);
- t->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
-
- t->set_icon("tab", "TextEdit", make_icon(tab_png));
-
- t->set_font("font", "TextEdit", default_font);
-
- t->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));
- t->set_color("completion_background_color", "TextEdit", Color::html("2C2A32"));
- t->set_color("completion_selected_color", "TextEdit", Color::html("434244"));
- t->set_color("completion_existing_color", "TextEdit", Color::html("21dfdfdf"));
- t->set_color("completion_scroll_color", "TextEdit", control_font_color_pressed);
- t->set_color("completion_font_color", "TextEdit", Color::html("aaaaaa"));
- t->set_color("font_color", "TextEdit", control_font_color);
- t->set_color("font_color_selected", "TextEdit", Color(0, 0, 0));
- t->set_color("selection_color", "TextEdit", font_color_selection);
- t->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4));
- t->set_color("breakpoint_color", "TextEdit", Color(0.8, 0.8, 0.4, 0.2));
- t->set_color("current_line_color", "TextEdit", Color(0.25, 0.25, 0.26, 0.8));
- t->set_color("caret_color", "TextEdit", control_font_color);
- t->set_color("caret_background_color", "TextEdit", Color::html("000000"));
- t->set_color("symbol_color", "TextEdit", control_font_color_hover);
- t->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
- t->set_color("line_number_color", "TextEdit", Color::html("66aaaaaa"));
- t->set_color("function_color", "TextEdit", Color::html("66a2ce"));
- t->set_color("member_variable_color", "TextEdit", Color::html("e64e59"));
- t->set_color("number_color", "TextEdit", Color::html("EB9532"));
- t->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));
-
- t->set_constant("completion_lines", "TextEdit", 7);
- t->set_constant("completion_max_width", "TextEdit", 50);
- t->set_constant("completion_scroll_width", "TextEdit", 3);
- t->set_constant("line_spacing", "TextEdit", 4 * scale);
+ theme->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
+ theme->set_stylebox("focus", "TextEdit", focus);
+ theme->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
+
+ theme->set_icon("tab", "TextEdit", make_icon(tab_png));
+
+ theme->set_font("font", "TextEdit", default_font);
+
+ theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));
+ theme->set_color("completion_background_color", "TextEdit", Color::html("2C2A32"));
+ theme->set_color("completion_selected_color", "TextEdit", Color::html("434244"));
+ theme->set_color("completion_existing_color", "TextEdit", Color::html("21dfdfdf"));
+ theme->set_color("completion_scroll_color", "TextEdit", control_font_color_pressed);
+ theme->set_color("completion_font_color", "TextEdit", Color::html("aaaaaa"));
+ theme->set_color("font_color", "TextEdit", control_font_color);
+ theme->set_color("font_color_selected", "TextEdit", Color(0, 0, 0));
+ theme->set_color("selection_color", "TextEdit", font_color_selection);
+ theme->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4));
+ theme->set_color("breakpoint_color", "TextEdit", Color(0.8, 0.8, 0.4, 0.2));
+ theme->set_color("current_line_color", "TextEdit", Color(0.25, 0.25, 0.26, 0.8));
+ theme->set_color("caret_color", "TextEdit", control_font_color);
+ theme->set_color("caret_background_color", "TextEdit", Color::html("000000"));
+ theme->set_color("symbol_color", "TextEdit", control_font_color_hover);
+ theme->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
+ theme->set_color("line_number_color", "TextEdit", Color::html("66aaaaaa"));
+ theme->set_color("function_color", "TextEdit", Color::html("66a2ce"));
+ theme->set_color("member_variable_color", "TextEdit", Color::html("e64e59"));
+ theme->set_color("number_color", "TextEdit", Color::html("EB9532"));
+ theme->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));
+
+ theme->set_constant("completion_lines", "TextEdit", 7);
+ theme->set_constant("completion_max_width", "TextEdit", 50);
+ theme->set_constant("completion_scroll_width", "TextEdit", 3);
+ theme->set_constant("line_spacing", "TextEdit", 4 * scale);
Ref<Texture> empty_icon = memnew(ImageTexture);
// HScrollBar
- t->set_stylebox("scroll", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
- t->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
- t->set_stylebox("grabber", "HScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
- t->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("scroll", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("grabber", "HScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(scroll_grabber_pressed_png, 5, 5, 5, 5, 2, 2, 2, 2));
- t->set_icon("increment", "HScrollBar", empty_icon);
- t->set_icon("increment_highlight", "HScrollBar", empty_icon);
- t->set_icon("decrement", "HScrollBar", empty_icon);
- t->set_icon("decrement_highlight", "HScrollBar", empty_icon);
+ theme->set_icon("increment", "HScrollBar", empty_icon);
+ theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
+ theme->set_icon("decrement", "HScrollBar", empty_icon);
+ theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
// VScrollBar
- t->set_stylebox("scroll", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
- t->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
- t->set_stylebox("grabber", "VScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
- t->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("scroll", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("grabber", "VScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(scroll_grabber_pressed_png, 5, 5, 5, 5, 2, 2, 2, 2));
- t->set_icon("increment", "VScrollBar", empty_icon);
- t->set_icon("increment_highlight", "VScrollBar", empty_icon);
- t->set_icon("decrement", "VScrollBar", empty_icon);
- t->set_icon("decrement_highlight", "VScrollBar", empty_icon);
+ theme->set_icon("increment", "VScrollBar", empty_icon);
+ theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
+ theme->set_icon("decrement", "VScrollBar", empty_icon);
+ theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
// HSlider
- t->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
- t->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
- t->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6));
- t->set_stylebox("focus", "HSlider", focus);
+ theme->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
+ theme->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
+ theme->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6));
+ theme->set_stylebox("focus", "HSlider", focus);
- t->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
- t->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png));
- t->set_icon("grabber_disabled", "HSlider", make_icon(hslider_grabber_disabled_png));
- t->set_icon("tick", "HSlider", make_icon(hslider_tick_png));
+ theme->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
+ theme->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png));
+ theme->set_icon("grabber_disabled", "HSlider", make_icon(hslider_grabber_disabled_png));
+ theme->set_icon("tick", "HSlider", make_icon(hslider_tick_png));
// VSlider
- t->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
- t->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
- t->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6));
- t->set_stylebox("focus", "HSlider", focus);
+ theme->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
+ theme->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
+ theme->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6));
+ theme->set_stylebox("focus", "HSlider", focus);
- t->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
- t->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));
- t->set_icon("grabber_disabled", "VSlider", make_icon(vslider_grabber_disabled_png));
- t->set_icon("tick", "VSlider", make_icon(vslider_tick_png));
+ theme->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
+ theme->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));
+ theme->set_icon("grabber_disabled", "VSlider", make_icon(vslider_grabber_disabled_png));
+ theme->set_icon("tick", "VSlider", make_icon(vslider_tick_png));
// SpinBox
- t->set_icon("updown", "SpinBox", make_icon(spinbox_updown_png));
+ theme->set_icon("updown", "SpinBox", make_icon(spinbox_updown_png));
// WindowDialog
- t->set_stylebox("panel", "WindowDialog", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
- t->set_constant("scaleborder_size", "WindowDialog", 4 * scale);
+ theme->set_stylebox("panel", "WindowDialog", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
+ theme->set_constant("scaleborder_size", "WindowDialog", 4 * scale);
- t->set_font("title_font", "WindowDialog", large_font);
- t->set_color("title_color", "WindowDialog", Color(0, 0, 0));
- t->set_constant("title_height", "WindowDialog", 20 * scale);
+ theme->set_font("title_font", "WindowDialog", large_font);
+ theme->set_color("title_color", "WindowDialog", Color(0, 0, 0));
+ theme->set_constant("title_height", "WindowDialog", 20 * scale);
- t->set_icon("close", "WindowDialog", make_icon(close_png));
- t->set_icon("close_highlight", "WindowDialog", make_icon(close_hl_png));
- t->set_constant("close_h_ofs", "WindowDialog", 18 * scale);
- t->set_constant("close_v_ofs", "WindowDialog", 18 * scale);
+ theme->set_icon("close", "WindowDialog", make_icon(close_png));
+ theme->set_icon("close_highlight", "WindowDialog", make_icon(close_hl_png));
+ theme->set_constant("close_h_ofs", "WindowDialog", 18 * scale);
+ theme->set_constant("close_v_ofs", "WindowDialog", 18 * scale);
// File Dialog
- t->set_icon("reload", "FileDialog", make_icon(icon_reload_png));
+ theme->set_icon("reload", "FileDialog", make_icon(icon_reload_png));
// Popup
@@ -561,28 +563,28 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
selected->set_expand_margin_size(Margin(i), 2 * scale);
}
- t->set_stylebox("panel", "PopupPanel", style_pp);
+ theme->set_stylebox("panel", "PopupPanel", style_pp);
// PopupMenu
- t->set_stylebox("panel", "PopupMenu", make_stylebox(popup_bg_png, 4, 4, 4, 4, 10, 10, 10, 10));
- t->set_stylebox("panel_disabled", "PopupMenu", make_stylebox(popup_bg_disabled_png, 4, 4, 4, 4));
- t->set_stylebox("hover", "PopupMenu", selected);
- t->set_stylebox("separator", "PopupMenu", make_stylebox(vseparator_png, 3, 3, 3, 3));
+ theme->set_stylebox("panel", "PopupMenu", make_stylebox(popup_bg_png, 4, 4, 4, 4, 10, 10, 10, 10));
+ theme->set_stylebox("panel_disabled", "PopupMenu", make_stylebox(popup_bg_disabled_png, 4, 4, 4, 4));
+ theme->set_stylebox("hover", "PopupMenu", selected);
+ theme->set_stylebox("separator", "PopupMenu", make_stylebox(vseparator_png, 3, 3, 3, 3));
- t->set_icon("checked", "PopupMenu", make_icon(checked_png));
- t->set_icon("unchecked", "PopupMenu", make_icon(unchecked_png));
- t->set_icon("submenu", "PopupMenu", make_icon(submenu_png));
+ theme->set_icon("checked", "PopupMenu", make_icon(checked_png));
+ theme->set_icon("unchecked", "PopupMenu", make_icon(unchecked_png));
+ theme->set_icon("submenu", "PopupMenu", make_icon(submenu_png));
- t->set_font("font", "PopupMenu", default_font);
+ theme->set_font("font", "PopupMenu", default_font);
- t->set_color("font_color", "PopupMenu", control_font_color);
- t->set_color("font_color_accel", "PopupMenu", Color(0.7, 0.7, 0.7, 0.8));
- t->set_color("font_color_disabled", "PopupMenu", Color(0.4, 0.4, 0.4, 0.8));
- t->set_color("font_color_hover", "PopupMenu", control_font_color);
+ theme->set_color("font_color", "PopupMenu", control_font_color);
+ theme->set_color("font_color_accel", "PopupMenu", Color(0.7, 0.7, 0.7, 0.8));
+ theme->set_color("font_color_disabled", "PopupMenu", Color(0.4, 0.4, 0.4, 0.8));
+ theme->set_color("font_color_hover", "PopupMenu", control_font_color);
- t->set_constant("hseparation", "PopupMenu", 4 * scale);
- t->set_constant("vseparation", "PopupMenu", 4 * scale);
+ theme->set_constant("hseparation", "PopupMenu", 4 * scale);
+ theme->set_constant("vseparation", "PopupMenu", 4 * scale);
// GraphNode
@@ -597,90 +599,90 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
//graphsb->set_expand_margin_size(MARGIN_RIGHT,10);
- t->set_stylebox("frame", "GraphNode", graphsb);
- t->set_stylebox("selectedframe", "GraphNode", graphsbselected);
- t->set_stylebox("defaultframe", "GraphNode", graphsbdefault);
- t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus);
- t->set_stylebox("comment", "GraphNode", graphsbcomment);
- t->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
- t->set_stylebox("breakpoint", "GraphNode", graph_bpoint);
- t->set_stylebox("position", "GraphNode", graph_position);
- t->set_constant("separation", "GraphNode", 1 * scale);
- t->set_icon("port", "GraphNode", make_icon(graph_port_png));
- t->set_icon("close", "GraphNode", make_icon(graph_node_close_png));
- t->set_icon("resizer", "GraphNode", make_icon(window_resizer_png));
- t->set_font("title_font", "GraphNode", default_font);
- t->set_color("title_color", "GraphNode", Color(0, 0, 0, 1));
- t->set_constant("title_offset", "GraphNode", 20 * scale);
- t->set_constant("close_offset", "GraphNode", 18 * scale);
- t->set_constant("port_offset", "GraphNode", 3 * scale);
+ theme->set_stylebox("frame", "GraphNode", graphsb);
+ theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
+ theme->set_stylebox("defaultframe", "GraphNode", graphsbdefault);
+ theme->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus);
+ theme->set_stylebox("comment", "GraphNode", graphsbcomment);
+ theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
+ theme->set_stylebox("breakpoint", "GraphNode", graph_bpoint);
+ theme->set_stylebox("position", "GraphNode", graph_position);
+ theme->set_constant("separation", "GraphNode", 1 * scale);
+ theme->set_icon("port", "GraphNode", make_icon(graph_port_png));
+ theme->set_icon("close", "GraphNode", make_icon(graph_node_close_png));
+ theme->set_icon("resizer", "GraphNode", make_icon(window_resizer_png));
+ theme->set_font("title_font", "GraphNode", default_font);
+ theme->set_color("title_color", "GraphNode", Color(0, 0, 0, 1));
+ theme->set_constant("title_offset", "GraphNode", 20 * scale);
+ theme->set_constant("close_offset", "GraphNode", 18 * scale);
+ theme->set_constant("port_offset", "GraphNode", 3 * scale);
// Tree
Ref<StyleBoxTexture> tree_selected = make_stylebox(selection_png, 4, 4, 4, 4, 8, 0, 8, 0);
Ref<StyleBoxTexture> tree_selected_oof = make_stylebox(selection_oof_png, 4, 4, 4, 4, 8, 0, 8, 0);
- t->set_stylebox("bg", "Tree", make_stylebox(tree_bg_png, 4, 4, 4, 5));
- t->set_stylebox("bg_focus", "Tree", focus);
- t->set_stylebox("selected", "Tree", tree_selected_oof);
- t->set_stylebox("selected_focus", "Tree", tree_selected);
- t->set_stylebox("cursor", "Tree", focus);
- t->set_stylebox("cursor_unfocused", "Tree", focus);
- t->set_stylebox("button_pressed", "Tree", make_stylebox(button_pressed_png, 4, 4, 4, 4));
- t->set_stylebox("title_button_normal", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
- t->set_stylebox("title_button_pressed", "Tree", make_stylebox(tree_title_pressed_png, 4, 4, 4, 4));
- t->set_stylebox("title_button_hover", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
- t->set_stylebox("custom_button", "Tree", sb_button_normal);
- t->set_stylebox("custom_button_pressed", "Tree", sb_button_pressed);
- t->set_stylebox("custom_button_hover", "Tree", sb_button_hover);
-
- t->set_icon("checked", "Tree", make_icon(checked_png));
- t->set_icon("unchecked", "Tree", make_icon(unchecked_png));
- t->set_icon("updown", "Tree", make_icon(updown_png));
- t->set_icon("select_arrow", "Tree", make_icon(dropdown_png));
- t->set_icon("arrow", "Tree", make_icon(arrow_down_png));
- t->set_icon("arrow_collapsed", "Tree", make_icon(arrow_right_png));
-
- t->set_font("title_button_font", "Tree", default_font);
- t->set_font("font", "Tree", default_font);
-
- t->set_color("title_button_color", "Tree", control_font_color);
- t->set_color("font_color", "Tree", control_font_color_low);
- t->set_color("font_color_selected", "Tree", control_font_color_pressed);
- t->set_color("selection_color", "Tree", Color(0.1, 0.1, 1, 0.8));
- t->set_color("cursor_color", "Tree", Color(0, 0, 0));
- t->set_color("guide_color", "Tree", Color(0, 0, 0, 0.1));
- t->set_color("drop_position_color", "Tree", Color(1, 0.3, 0.2));
- t->set_color("relationship_line_color", "Tree", Color::html("464646"));
- t->set_color("custom_button_font_highlight", "Tree", control_font_color_hover);
-
- t->set_constant("hseparation", "Tree", 4 * scale);
- t->set_constant("vseparation", "Tree", 4 * scale);
- t->set_constant("guide_width", "Tree", 2 * scale);
- t->set_constant("item_margin", "Tree", 12 * scale);
- t->set_constant("button_margin", "Tree", 4 * scale);
- t->set_constant("draw_relationship_lines", "Tree", 0);
- t->set_constant("scroll_border", "Tree", 4);
- t->set_constant("scroll_speed", "Tree", 12);
+ theme->set_stylebox("bg", "Tree", make_stylebox(tree_bg_png, 4, 4, 4, 5));
+ theme->set_stylebox("bg_focus", "Tree", focus);
+ theme->set_stylebox("selected", "Tree", tree_selected_oof);
+ theme->set_stylebox("selected_focus", "Tree", tree_selected);
+ theme->set_stylebox("cursor", "Tree", focus);
+ theme->set_stylebox("cursor_unfocused", "Tree", focus);
+ theme->set_stylebox("button_pressed", "Tree", make_stylebox(button_pressed_png, 4, 4, 4, 4));
+ theme->set_stylebox("title_button_normal", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
+ theme->set_stylebox("title_button_pressed", "Tree", make_stylebox(tree_title_pressed_png, 4, 4, 4, 4));
+ theme->set_stylebox("title_button_hover", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
+ theme->set_stylebox("custom_button", "Tree", sb_button_normal);
+ theme->set_stylebox("custom_button_pressed", "Tree", sb_button_pressed);
+ theme->set_stylebox("custom_button_hover", "Tree", sb_button_hover);
+
+ theme->set_icon("checked", "Tree", make_icon(checked_png));
+ theme->set_icon("unchecked", "Tree", make_icon(unchecked_png));
+ theme->set_icon("updown", "Tree", make_icon(updown_png));
+ theme->set_icon("select_arrow", "Tree", make_icon(dropdown_png));
+ theme->set_icon("arrow", "Tree", make_icon(arrow_down_png));
+ theme->set_icon("arrow_collapsed", "Tree", make_icon(arrow_right_png));
+
+ theme->set_font("title_button_font", "Tree", default_font);
+ theme->set_font("font", "Tree", default_font);
+
+ theme->set_color("title_button_color", "Tree", control_font_color);
+ theme->set_color("font_color", "Tree", control_font_color_low);
+ theme->set_color("font_color_selected", "Tree", control_font_color_pressed);
+ theme->set_color("selection_color", "Tree", Color(0.1, 0.1, 1, 0.8));
+ theme->set_color("cursor_color", "Tree", Color(0, 0, 0));
+ theme->set_color("guide_color", "Tree", Color(0, 0, 0, 0.1));
+ theme->set_color("drop_position_color", "Tree", Color(1, 0.3, 0.2));
+ theme->set_color("relationship_line_color", "Tree", Color::html("464646"));
+ theme->set_color("custom_button_font_highlight", "Tree", control_font_color_hover);
+
+ theme->set_constant("hseparation", "Tree", 4 * scale);
+ theme->set_constant("vseparation", "Tree", 4 * scale);
+ theme->set_constant("guide_width", "Tree", 2 * scale);
+ theme->set_constant("item_margin", "Tree", 12 * scale);
+ theme->set_constant("button_margin", "Tree", 4 * scale);
+ theme->set_constant("draw_relationship_lines", "Tree", 0);
+ theme->set_constant("scroll_border", "Tree", 4);
+ theme->set_constant("scroll_speed", "Tree", 12);
// ItemList
Ref<StyleBoxTexture> item_selected = make_stylebox(selection_png, 4, 4, 4, 4, 8, 2, 8, 2);
Ref<StyleBoxTexture> item_selected_oof = make_stylebox(selection_oof_png, 4, 4, 4, 4, 8, 2, 8, 2);
- t->set_stylebox("bg", "ItemList", make_stylebox(tree_bg_png, 4, 4, 4, 5));
- t->set_stylebox("bg_focus", "ItemList", focus);
- t->set_constant("hseparation", "ItemList", 4);
- t->set_constant("vseparation", "ItemList", 2);
- t->set_constant("icon_margin", "ItemList", 4);
- t->set_constant("line_separation", "ItemList", 2 * scale);
- t->set_font("font", "ItemList", default_font);
- t->set_color("font_color", "ItemList", control_font_color_lower);
- t->set_color("font_color_selected", "ItemList", control_font_color_pressed);
- t->set_color("guide_color", "ItemList", Color(0, 0, 0, 0.1));
- t->set_stylebox("selected", "ItemList", item_selected_oof);
- t->set_stylebox("selected_focus", "ItemList", item_selected);
- t->set_stylebox("cursor", "ItemList", focus);
- t->set_stylebox("cursor_unfocused", "ItemList", focus);
+ theme->set_stylebox("bg", "ItemList", make_stylebox(tree_bg_png, 4, 4, 4, 5));
+ theme->set_stylebox("bg_focus", "ItemList", focus);
+ theme->set_constant("hseparation", "ItemList", 4);
+ theme->set_constant("vseparation", "ItemList", 2);
+ theme->set_constant("icon_margin", "ItemList", 4);
+ theme->set_constant("line_separation", "ItemList", 2 * scale);
+ theme->set_font("font", "ItemList", default_font);
+ theme->set_color("font_color", "ItemList", control_font_color_lower);
+ theme->set_color("font_color_selected", "ItemList", control_font_color_pressed);
+ theme->set_color("guide_color", "ItemList", Color(0, 0, 0, 0.1));
+ theme->set_stylebox("selected", "ItemList", item_selected_oof);
+ theme->set_stylebox("selected_focus", "ItemList", item_selected);
+ theme->set_stylebox("cursor", "ItemList", focus);
+ theme->set_stylebox("cursor_unfocused", "ItemList", focus);
// TabContainer
@@ -689,88 +691,88 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
tc_sb->set_expand_margin_size(MARGIN_TOP, 2 * scale);
tc_sb->set_default_margin(MARGIN_TOP, 8 * scale);
- 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("panel", "TabContainer", tc_sb);
+ theme->set_stylebox("tab_fg", "TabContainer", sb_expand(make_stylebox(tab_current_png, 4, 4, 4, 1, 16, 4, 16, 4), 2, 2, 2, 2));
+ theme->set_stylebox("tab_bg", "TabContainer", sb_expand(make_stylebox(tab_behind_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3));
+ theme->set_stylebox("panel", "TabContainer", tc_sb);
- t->set_icon("increment", "TabContainer", make_icon(scroll_button_right_png));
- t->set_icon("increment_highlight", "TabContainer", make_icon(scroll_button_right_hl_png));
- t->set_icon("decrement", "TabContainer", make_icon(scroll_button_left_png));
- t->set_icon("decrement_highlight", "TabContainer", make_icon(scroll_button_left_hl_png));
- t->set_icon("menu", "TabContainer", make_icon(tab_menu_png));
- t->set_icon("menu_highlight", "TabContainer", make_icon(tab_menu_hl_png));
+ theme->set_icon("increment", "TabContainer", make_icon(scroll_button_right_png));
+ theme->set_icon("increment_highlight", "TabContainer", make_icon(scroll_button_right_hl_png));
+ theme->set_icon("decrement", "TabContainer", make_icon(scroll_button_left_png));
+ theme->set_icon("decrement_highlight", "TabContainer", make_icon(scroll_button_left_hl_png));
+ theme->set_icon("menu", "TabContainer", make_icon(tab_menu_png));
+ theme->set_icon("menu_highlight", "TabContainer", make_icon(tab_menu_hl_png));
- t->set_font("font", "TabContainer", default_font);
+ theme->set_font("font", "TabContainer", default_font);
- 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);
+ theme->set_color("font_color_fg", "TabContainer", control_font_color_hover);
+ theme->set_color("font_color_bg", "TabContainer", control_font_color_low);
+ theme->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);
- t->set_constant("label_valign_fg", "TabContainer", 0 * scale);
- t->set_constant("label_valign_bg", "TabContainer", 2 * scale);
- t->set_constant("hseparation", "TabContainer", 4 * scale);
+ theme->set_constant("side_margin", "TabContainer", 8 * scale);
+ theme->set_constant("top_margin", "TabContainer", 24 * scale);
+ theme->set_constant("label_valign_fg", "TabContainer", 0 * scale);
+ theme->set_constant("label_valign_bg", "TabContainer", 2 * scale);
+ theme->set_constant("hseparation", "TabContainer", 4 * scale);
// Tabs
- 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("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));
+ theme->set_stylebox("tab_fg", "Tabs", sb_expand(make_stylebox(tab_current_png, 4, 3, 4, 1, 16, 3, 16, 2), 2, 2, 2, 2));
+ theme->set_stylebox("tab_bg", "Tabs", sb_expand(make_stylebox(tab_behind_png, 5, 4, 5, 1, 16, 5, 16, 2), 3, 3, 3, 3));
+ theme->set_stylebox("panel", "Tabs", tc_sb);
+ theme->set_stylebox("button_pressed", "Tabs", make_stylebox(button_pressed_png, 4, 4, 4, 4));
+ theme->set_stylebox("button", "Tabs", make_stylebox(button_normal_png, 4, 4, 4, 4));
- t->set_icon("increment", "Tabs", make_icon(scroll_button_right_png));
- t->set_icon("increment_highlight", "Tabs", make_icon(scroll_button_right_hl_png));
- t->set_icon("decrement", "Tabs", make_icon(scroll_button_left_png));
- t->set_icon("decrement_highlight", "Tabs", make_icon(scroll_button_left_hl_png));
- t->set_icon("close", "Tabs", make_icon(tab_close_png));
+ theme->set_icon("increment", "Tabs", make_icon(scroll_button_right_png));
+ theme->set_icon("increment_highlight", "Tabs", make_icon(scroll_button_right_hl_png));
+ theme->set_icon("decrement", "Tabs", make_icon(scroll_button_left_png));
+ theme->set_icon("decrement_highlight", "Tabs", make_icon(scroll_button_left_hl_png));
+ theme->set_icon("close", "Tabs", make_icon(tab_close_png));
- t->set_font("font", "Tabs", default_font);
+ theme->set_font("font", "Tabs", default_font);
- 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);
+ theme->set_color("font_color_fg", "Tabs", control_font_color_hover);
+ theme->set_color("font_color_bg", "Tabs", control_font_color_low);
+ theme->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);
- t->set_constant("label_valign_bg", "Tabs", 2 * scale);
- t->set_constant("hseparation", "Tabs", 4 * scale);
+ theme->set_constant("top_margin", "Tabs", 24 * scale);
+ theme->set_constant("label_valign_fg", "Tabs", 0 * scale);
+ theme->set_constant("label_valign_bg", "Tabs", 2 * scale);
+ theme->set_constant("hseparation", "Tabs", 4 * scale);
// Separators
- t->set_stylebox("separator", "HSeparator", make_stylebox(vseparator_png, 3, 3, 3, 3));
- t->set_stylebox("separator", "VSeparator", make_stylebox(hseparator_png, 3, 3, 3, 3));
+ theme->set_stylebox("separator", "HSeparator", make_stylebox(vseparator_png, 3, 3, 3, 3));
+ theme->set_stylebox("separator", "VSeparator", make_stylebox(hseparator_png, 3, 3, 3, 3));
- t->set_icon("close", "Icons", make_icon(icon_close_png));
- t->set_font("normal", "Fonts", default_font);
- t->set_font("large", "Fonts", large_font);
+ theme->set_icon("close", "Icons", make_icon(icon_close_png));
+ theme->set_font("normal", "Fonts", default_font);
+ theme->set_font("large", "Fonts", large_font);
- t->set_constant("separation", "HSeparator", 4 * scale);
- t->set_constant("separation", "VSeparator", 4 * scale);
+ theme->set_constant("separation", "HSeparator", 4 * scale);
+ theme->set_constant("separation", "VSeparator", 4 * scale);
// Dialogs
- t->set_constant("margin", "Dialogs", 8 * scale);
- t->set_constant("button_margin", "Dialogs", 32 * scale);
+ theme->set_constant("margin", "Dialogs", 8 * scale);
+ theme->set_constant("button_margin", "Dialogs", 32 * scale);
// FileDialog
- t->set_icon("folder", "FileDialog", make_icon(icon_folder_png));
- t->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
+ theme->set_icon("folder", "FileDialog", make_icon(icon_folder_png));
+ theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
// colorPicker
- t->set_constant("margin", "ColorPicker", 4 * scale);
- t->set_constant("sv_width", "ColorPicker", 256 * scale);
- t->set_constant("sv_height", "ColorPicker", 256 * scale);
- t->set_constant("h_width", "ColorPicker", 30 * scale);
- t->set_constant("label_width", "ColorPicker", 10 * scale);
+ theme->set_constant("margin", "ColorPicker", 4 * scale);
+ theme->set_constant("sv_width", "ColorPicker", 256 * scale);
+ theme->set_constant("sv_height", "ColorPicker", 256 * scale);
+ theme->set_constant("h_width", "ColorPicker", 30 * scale);
+ theme->set_constant("label_width", "ColorPicker", 10 * scale);
- t->set_icon("screen_picker", "ColorPicker", make_icon(icon_color_pick_png));
- t->set_icon("add_preset", "ColorPicker", make_icon(icon_add_png));
- t->set_icon("color_hue", "ColorPicker", make_icon(color_picker_hue_png));
- t->set_icon("color_sample", "ColorPicker", make_icon(color_picker_sample_png));
+ theme->set_icon("screen_picker", "ColorPicker", make_icon(icon_color_pick_png));
+ theme->set_icon("add_preset", "ColorPicker", make_icon(icon_add_png));
+ theme->set_icon("color_hue", "ColorPicker", make_icon(color_picker_hue_png));
+ theme->set_icon("color_sample", "ColorPicker", make_icon(color_picker_sample_png));
// TooltipPanel
@@ -778,111 +780,111 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<
for (int i = 0; i < 4; i++)
style_tt->set_expand_margin_size((Margin)i, 4 * scale);
- t->set_stylebox("panel", "TooltipPanel", style_tt);
+ theme->set_stylebox("panel", "TooltipPanel", style_tt);
- t->set_font("font", "TooltipLabel", default_font);
+ theme->set_font("font", "TooltipLabel", default_font);
- t->set_color("font_color", "TooltipLabel", Color(0, 0, 0));
- t->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0.1));
+ theme->set_color("font_color", "TooltipLabel", Color(0, 0, 0));
+ theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0.1));
- t->set_constant("shadow_offset_x", "TooltipLabel", 1);
- t->set_constant("shadow_offset_y", "TooltipLabel", 1);
+ theme->set_constant("shadow_offset_x", "TooltipLabel", 1);
+ theme->set_constant("shadow_offset_y", "TooltipLabel", 1);
// RichTextLabel
- t->set_stylebox("focus", "RichTextLabel", focus);
+ theme->set_stylebox("focus", "RichTextLabel", focus);
- t->set_font("normal_font", "RichTextLabel", default_font);
- t->set_font("bold_font", "RichTextLabel", default_font);
- t->set_font("italics_font", "RichTextLabel", default_font);
- t->set_font("bold_italics_font", "RichTextLabel", default_font);
- t->set_font("mono_font", "RichTextLabel", default_font);
+ theme->set_font("normal_font", "RichTextLabel", default_font);
+ theme->set_font("bold_font", "RichTextLabel", default_font);
+ theme->set_font("italics_font", "RichTextLabel", default_font);
+ theme->set_font("bold_italics_font", "RichTextLabel", default_font);
+ theme->set_font("mono_font", "RichTextLabel", default_font);
- t->set_color("default_color", "RichTextLabel", control_font_color);
- t->set_color("font_color_selected", "RichTextLabel", font_color_selection);
- t->set_color("selection_color", "RichTextLabel", Color(0.1, 0.1, 1, 0.8));
+ theme->set_color("default_color", "RichTextLabel", control_font_color);
+ theme->set_color("font_color_selected", "RichTextLabel", font_color_selection);
+ theme->set_color("selection_color", "RichTextLabel", Color(0.1, 0.1, 1, 0.8));
- t->set_constant("line_separation", "RichTextLabel", 1 * scale);
- t->set_constant("table_hseparation", "RichTextLabel", 3 * scale);
- t->set_constant("table_vseparation", "RichTextLabel", 3 * scale);
+ theme->set_constant("line_separation", "RichTextLabel", 1 * scale);
+ theme->set_constant("table_hseparation", "RichTextLabel", 3 * scale);
+ theme->set_constant("table_vseparation", "RichTextLabel", 3 * scale);
// Containers
- t->set_stylebox("bg", "VSplitContainer", make_stylebox(vsplit_bg_png, 1, 1, 1, 1));
- t->set_stylebox("bg", "HSplitContainer", make_stylebox(hsplit_bg_png, 1, 1, 1, 1));
-
- t->set_icon("grabber", "VSplitContainer", make_icon(vsplitter_png));
- t->set_icon("grabber", "HSplitContainer", make_icon(hsplitter_png));
-
- t->set_constant("separation", "HBoxContainer", 4 * scale);
- t->set_constant("separation", "VBoxContainer", 4 * scale);
- t->set_constant("margin_left", "MarginContainer", 8 * scale);
- t->set_constant("margin_top", "MarginContainer", 0 * scale);
- t->set_constant("margin_right", "MarginContainer", 0 * scale);
- t->set_constant("margin_bottom", "MarginContainer", 0 * scale);
- t->set_constant("hseparation", "GridContainer", 4 * scale);
- t->set_constant("vseparation", "GridContainer", 4 * scale);
- t->set_constant("separation", "HSplitContainer", 12 * scale);
- t->set_constant("separation", "VSplitContainer", 12 * scale);
- t->set_constant("autohide", "HSplitContainer", 1 * scale);
- t->set_constant("autohide", "VSplitContainer", 1 * scale);
+ theme->set_stylebox("bg", "VSplitContainer", make_stylebox(vsplit_bg_png, 1, 1, 1, 1));
+ theme->set_stylebox("bg", "HSplitContainer", make_stylebox(hsplit_bg_png, 1, 1, 1, 1));
+
+ theme->set_icon("grabber", "VSplitContainer", make_icon(vsplitter_png));
+ theme->set_icon("grabber", "HSplitContainer", make_icon(hsplitter_png));
+
+ theme->set_constant("separation", "HBoxContainer", 4 * scale);
+ theme->set_constant("separation", "VBoxContainer", 4 * scale);
+ theme->set_constant("margin_left", "MarginContainer", 8 * scale);
+ theme->set_constant("margin_top", "MarginContainer", 0 * scale);
+ theme->set_constant("margin_right", "MarginContainer", 0 * scale);
+ theme->set_constant("margin_bottom", "MarginContainer", 0 * scale);
+ theme->set_constant("hseparation", "GridContainer", 4 * scale);
+ theme->set_constant("vseparation", "GridContainer", 4 * scale);
+ theme->set_constant("separation", "HSplitContainer", 12 * scale);
+ theme->set_constant("separation", "VSplitContainer", 12 * scale);
+ theme->set_constant("autohide", "HSplitContainer", 1 * scale);
+ theme->set_constant("autohide", "VSplitContainer", 1 * scale);
// HButtonArray
- t->set_stylebox("normal", "HButtonArray", sb_button_normal);
- t->set_stylebox("selected", "HButtonArray", sb_button_pressed);
- t->set_stylebox("hover", "HButtonArray", sb_button_hover);
+ theme->set_stylebox("normal", "HButtonArray", sb_button_normal);
+ theme->set_stylebox("selected", "HButtonArray", sb_button_pressed);
+ theme->set_stylebox("hover", "HButtonArray", sb_button_hover);
- t->set_font("font", "HButtonArray", default_font);
- t->set_font("font_selected", "HButtonArray", default_font);
+ theme->set_font("font", "HButtonArray", default_font);
+ theme->set_font("font_selected", "HButtonArray", default_font);
- t->set_color("font_color", "HButtonArray", control_font_color_low);
- t->set_color("font_color_selected", "HButtonArray", control_font_color_hover);
+ theme->set_color("font_color", "HButtonArray", control_font_color_low);
+ theme->set_color("font_color_selected", "HButtonArray", control_font_color_hover);
- t->set_constant("icon_separator", "HButtonArray", 2 * scale);
- t->set_constant("button_separator", "HButtonArray", 4 * scale);
+ theme->set_constant("icon_separator", "HButtonArray", 2 * scale);
+ theme->set_constant("button_separator", "HButtonArray", 4 * scale);
- t->set_stylebox("focus", "HButtonArray", focus);
+ theme->set_stylebox("focus", "HButtonArray", focus);
// VButtonArray
- t->set_stylebox("normal", "VButtonArray", sb_button_normal);
- t->set_stylebox("selected", "VButtonArray", sb_button_pressed);
- t->set_stylebox("hover", "VButtonArray", sb_button_hover);
+ theme->set_stylebox("normal", "VButtonArray", sb_button_normal);
+ theme->set_stylebox("selected", "VButtonArray", sb_button_pressed);
+ theme->set_stylebox("hover", "VButtonArray", sb_button_hover);
- t->set_font("font", "VButtonArray", default_font);
- t->set_font("font_selected", "VButtonArray", default_font);
+ theme->set_font("font", "VButtonArray", default_font);
+ theme->set_font("font_selected", "VButtonArray", default_font);
- t->set_color("font_color", "VButtonArray", control_font_color_low);
- t->set_color("font_color_selected", "VButtonArray", control_font_color_hover);
+ theme->set_color("font_color", "VButtonArray", control_font_color_low);
+ theme->set_color("font_color_selected", "VButtonArray", control_font_color_hover);
- t->set_constant("icon_separator", "VButtonArray", 2 * scale);
- t->set_constant("button_separator", "VButtonArray", 4 * scale);
+ theme->set_constant("icon_separator", "VButtonArray", 2 * scale);
+ theme->set_constant("button_separator", "VButtonArray", 4 * scale);
- t->set_stylebox("focus", "VButtonArray", focus);
+ theme->set_stylebox("focus", "VButtonArray", focus);
// ReferenceRect
Ref<StyleBoxTexture> ttnc = make_stylebox(full_panel_bg_png, 8, 8, 8, 8);
ttnc->set_draw_center(false);
- 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);
+ theme->set_stylebox("border", "ReferenceRect", make_stylebox(reference_border_png, 4, 4, 4, 4));
+ theme->set_stylebox("panelnc", "Panel", ttnc);
+ theme->set_stylebox("panelf", "Panel", tc_sb);
Ref<StyleBoxTexture> sb_pc = make_stylebox(tab_container_bg_png, 4, 4, 4, 4, 7, 7, 7, 7);
- t->set_stylebox("panel", "PanelContainer", sb_pc);
-
- t->set_icon("minus", "GraphEdit", make_icon(icon_zoom_less_png));
- t->set_icon("reset", "GraphEdit", make_icon(icon_zoom_reset_png));
- t->set_icon("more", "GraphEdit", make_icon(icon_zoom_more_png));
- t->set_icon("snap", "GraphEdit", make_icon(icon_snap_png));
- t->set_stylebox("bg", "GraphEdit", make_stylebox(tree_bg_png, 4, 4, 4, 5));
- t->set_color("grid_minor", "GraphEdit", Color(1, 1, 1, 0.05));
- t->set_color("grid_major", "GraphEdit", Color(1, 1, 1, 0.2));
- t->set_constant("bezier_len_pos", "GraphEdit", 80 * scale);
- t->set_constant("bezier_len_neg", "GraphEdit", 160 * scale);
-
- t->set_icon("logo", "Icons", make_icon(logo_png));
+ theme->set_stylebox("panel", "PanelContainer", sb_pc);
+
+ theme->set_icon("minus", "GraphEdit", make_icon(icon_zoom_less_png));
+ theme->set_icon("reset", "GraphEdit", make_icon(icon_zoom_reset_png));
+ theme->set_icon("more", "GraphEdit", make_icon(icon_zoom_more_png));
+ theme->set_icon("snap", "GraphEdit", make_icon(icon_snap_png));
+ theme->set_stylebox("bg", "GraphEdit", make_stylebox(tree_bg_png, 4, 4, 4, 5));
+ theme->set_color("grid_minor", "GraphEdit", Color(1, 1, 1, 0.05));
+ theme->set_color("grid_major", "GraphEdit", Color(1, 1, 1, 0.2));
+ theme->set_constant("bezier_len_pos", "GraphEdit", 80 * scale);
+ theme->set_constant("bezier_len_neg", "GraphEdit", 160 * scale);
+
+ theme->set_icon("logo", "Icons", make_icon(logo_png));
// Theme
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index 6fd57b6f22..9032b71775 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/default_theme/scroll_grabber_pressed.png b/scene/resources/default_theme/scroll_grabber_pressed.png
new file mode 100644
index 0000000000..a46d242ddd
--- /dev/null
+++ b/scene/resources/default_theme/scroll_grabber_pressed.png
Binary files differ
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 70a8ad12cb..bed4bdb760 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -334,6 +334,10 @@ static const unsigned char scroll_grabber_hl_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x3, 0x0, 0x0, 0x0, 0x61, 0xab, 0xac, 0xd5, 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, 0x6c, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x97, 0xd0, 0xdf, 0x92, 0xcb, 0xdc, 0x84, 0xbb, 0xd4, 0x92, 0xca, 0xdc, 0x95, 0xd0, 0xdd, 0x83, 0xbb, 0xd3, 0x8b, 0xc8, 0xd7, 0x79, 0xb5, 0xcb, 0x78, 0xb4, 0xca, 0x73, 0xb0, 0xc7, 0x73, 0xb0, 0xc7, 0x7b, 0xc0, 0xcf, 0x79, 0xc5, 0xd1, 0x6b, 0xae, 0xc1, 0x75, 0xc6, 0xcf, 0x70, 0xbc, 0xca, 0x64, 0xa6, 0xbc, 0x71, 0xbc, 0xc9, 0x82, 0xba, 0xd4, 0x6a, 0xa2, 0xc6, 0x62, 0x9a, 0xc2, 0x61, 0x9a, 0xc1, 0x68, 0x9f, 0xc2, 0x5d, 0x92, 0xbb, 0x5c, 0x92, 0xb8, 0x58, 0x8d, 0xb6, 0x59, 0x8e, 0xb3, 0x56, 0x89, 0xb0, 0x5c, 0x91, 0xb2, 0x53, 0x84, 0xa9, 0x58, 0x8f, 0xae, 0x54, 0x83, 0xa4, 0x57, 0x8e, 0xad, 0x64, 0xa5, 0xba, 0xff, 0xff, 0xff, 0xbb, 0x65, 0x65, 0x27, 0x0, 0x0, 0x0, 0x13, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x25, 0xad, 0xf1, 0xad, 0x27, 0xef, 0xad, 0xf1, 0xf3, 0xf1, 0xf3, 0xad, 0x28, 0xef, 0x27, 0xad, 0xf2, 0xad, 0xcd, 0x8a, 0x27, 0xfe, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x23, 0x2a, 0x62, 0x6c, 0x3a, 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, 0x50, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc0, 0x7, 0x18, 0x99, 0x98, 0x85, 0x59, 0x18, 0x21, 0x6c, 0x56, 0x36, 0x11, 0x51, 0x31, 0x11, 0x36, 0x56, 0x30, 0x87, 0x5d, 0x5c, 0x2, 0x8, 0xc4, 0xd9, 0xc1, 0x1c, 0xe, 0x49, 0x29, 0x20, 0x90, 0xe4, 0x4, 0x73, 0xb8, 0xa4, 0x65, 0x80, 0x40, 0x9a, 0x1b, 0xcc, 0xe1, 0x91, 0x95, 0x3, 0x2, 0x59, 0x1e, 0x30, 0x87, 0x97, 0x4f, 0x5e, 0x41, 0x41, 0x91, 0x8f, 0x17, 0x62, 0x1c, 0xbf, 0x80, 0xa0, 0x92, 0x10, 0x3f, 0x5e, 0xdb, 0x1, 0x41, 0x87, 0x4, 0x7d, 0x15, 0xc4, 0xfd, 0x6a, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
+static const unsigned char scroll_grabber_pressed_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x6, 0x0, 0x0, 0x0, 0x56, 0x75, 0x5c, 0xe7, 0x0, 0x0, 0x0, 0x4, 0x73, 0x42, 0x49, 0x54, 0x8, 0x8, 0x8, 0x8, 0x7c, 0x8, 0x64, 0x88, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xd, 0xd7, 0x0, 0x0, 0xd, 0xd7, 0x1, 0x42, 0x28, 0x9b, 0x78, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x0, 0x0, 0x0, 0x66, 0x49, 0x44, 0x41, 0x54, 0x28, 0x91, 0xcd, 0x91, 0xb1, 0xa, 0xc0, 0x20, 0x10, 0x43, 0x63, 0x71, 0xbf, 0x5f, 0x12, 0x9c, 0xfd, 0x1a, 0x3f, 0xcd, 0xa9, 0x83, 0xe0, 0x2f, 0x65, 0x2f, 0x9c, 0x8b, 0x83, 0x47, 0xed, 0x60, 0xbb, 0x34, 0xdb, 0x3d, 0x12, 0x48, 0x38, 0xa7, 0xaa, 0xd8, 0xd1, 0xb1, 0xe5, 0x7e, 0x13, 0xf0, 0xf3, 0xd1, 0x5a, 0xf3, 0x24, 0x23, 0x80, 0x34, 0x50, 0x11, 0x91, 0x1a, 0x42, 0xb8, 0x96, 0x1, 0x92, 0x51, 0x55, 0xf3, 0x84, 0x32, 0x49, 0x0, 0x38, 0x9f, 0x2a, 0x25, 0xdc, 0x65, 0xd8, 0xe7, 0xd1, 0x65, 0xe1, 0x31, 0xcc, 0x6c, 0x10, 0x91, 0x3a, 0x3a, 0x9b, 0xd1, 0xb3, 0xc7, 0xfd, 0xef, 0x71, 0x1d, 0x42, 0xe6, 0x21, 0x43, 0xf5, 0x2b, 0xd8, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
static const unsigned char selection_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, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 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, 0x2d, 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, 0xfd, 0xfb, 0xff, 0xfd, 0xf7, 0xff, 0xfd, 0xf7, 0xff, 0xfd, 0xf7, 0xff, 0xfd, 0xf6, 0xff, 0xf6, 0xf4, 0xff, 0x15, 0x15, 0x17, 0xff, 0x70, 0xc0, 0x21, 0x0, 0x0, 0x0, 0xe, 0x74, 0x52, 0x4e, 0x53, 0x6, 0xf, 0x16, 0x18, 0x2a, 0x3b, 0x40, 0x3c, 0x6, 0x3d, 0x44, 0x3e, 0x31, 0x25, 0x8, 0x3d, 0x16, 0xb4, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xe, 0x6f, 0xbd, 0x30, 0x4f, 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, 0x37, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x54, 0x36, 0x6, 0x2, 0x23, 0x1, 0x6, 0x91, 0xb0, 0x34, 0x20, 0x48, 0x75, 0x64, 0x50, 0xef, 0x5c, 0x5, 0x4, 0x33, 0x8a, 0x18, 0xcc, 0xf6, 0xdc, 0x5, 0x82, 0xd3, 0xc9, 0xc, 0x66, 0x6b, 0x41, 0x8c, 0x5b, 0x94, 0x33, 0x60, 0x6, 0xc2, 0xad, 0x80, 0x5b, 0xa, 0x73, 0x6, 0x0, 0x45, 0x34, 0x48, 0x41, 0xa3, 0xc5, 0x91, 0x23, 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
};
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 23bf6be68c..82739b58a0 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -43,10 +43,10 @@ bool DynamicFontData::CacheID::operator<(CacheID right) const {
return false;
}
-Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_id) {
+Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cache_id) {
- if (size_cache.has(p_id)) {
- return Ref<DynamicFontAtSize>(size_cache[p_id]);
+ if (size_cache.has(p_cache_id)) {
+ return Ref<DynamicFontAtSize>(size_cache[p_cache_id]);
}
Ref<DynamicFontAtSize> dfas;
@@ -55,8 +55,8 @@ Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_id)
dfas->font = Ref<DynamicFontData>(this);
- size_cache[p_id] = dfas.ptr();
- dfas->id = p_id;
+ size_cache[p_cache_id] = dfas.ptr();
+ dfas->id = p_cache_id;
dfas->_load();
return dfas;
@@ -524,7 +524,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
if (mh > texsize)
texsize = mh; //special case, adapt to it?
- texsize = nearest_power_of_2(texsize);
+ texsize = next_power_of_2(texsize);
texsize = MIN(texsize, 4096);
@@ -892,10 +892,10 @@ void DynamicFont::_bind_methods() {
ADD_GROUP("Font", "");
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);
- BIND_CONSTANT(SPACING_CHAR);
- BIND_CONSTANT(SPACING_SPACE);
+ BIND_ENUM_CONSTANT(SPACING_TOP);
+ BIND_ENUM_CONSTANT(SPACING_BOTTOM);
+ BIND_ENUM_CONSTANT(SPACING_CHAR);
+ BIND_ENUM_CONSTANT(SPACING_SPACE);
}
DynamicFont::DynamicFont() {
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index 7c94def5aa..52c3f30590 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -72,7 +72,7 @@ private:
friend class DynamicFont;
- Ref<DynamicFontAtSize> _get_dynamic_font_at_size(CacheID p_cache);
+ Ref<DynamicFontAtSize> _get_dynamic_font_at_size(CacheID p_cache_id);
protected:
static void _bind_methods();
@@ -236,6 +236,8 @@ public:
~DynamicFont();
};
+VARIANT_ENUM_CAST(DynamicFont::SpacingType);
+
/////////////
class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader {
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 8efad94b9a..91263fb125 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -289,7 +289,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
if (mh > texsize)
texsize = mh; //special case, adapt to it?
- texsize = nearest_power_of_2(texsize);
+ texsize = next_power_of_2(texsize);
texsize = MIN(texsize, 4096);
diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h
index a2c081a925..24d764e716 100644
--- a/scene/resources/dynamic_font_stb.h
+++ b/scene/resources/dynamic_font_stb.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index c121dae1f1..14225d945d 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -994,10 +994,10 @@ void Environment::_bind_methods() {
ADD_GROUP("SSAO", "ssao_");
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_radius", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_ssao_radius", "get_ssao_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_intensity", PROPERTY_HINT_RANGE, "0.0,128,0.1"), "set_ssao_intensity", "get_ssao_intensity");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_radius2", PROPERTY_HINT_RANGE, "0.0,128,0.1"), "set_ssao_radius2", "get_ssao_radius2");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_intensity2", PROPERTY_HINT_RANGE, "0.0,128,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");
@@ -1114,27 +1114,32 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_adjustment_color_correction", "get_adjustment_color_correction");
- BIND_CONSTANT(BG_KEEP);
- BIND_CONSTANT(BG_CLEAR_COLOR);
- BIND_CONSTANT(BG_COLOR);
- BIND_CONSTANT(BG_SKY);
- BIND_CONSTANT(BG_CANVAS);
- BIND_CONSTANT(BG_MAX);
- BIND_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
- BIND_CONSTANT(GLOW_BLEND_MODE_SCREEN);
- BIND_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
- BIND_CONSTANT(GLOW_BLEND_MODE_REPLACE);
- BIND_CONSTANT(TONE_MAPPER_LINEAR);
- BIND_CONSTANT(TONE_MAPPER_REINHARDT);
- BIND_CONSTANT(TONE_MAPPER_FILMIC);
- BIND_CONSTANT(TONE_MAPPER_ACES);
- BIND_CONSTANT(DOF_BLUR_QUALITY_LOW);
- BIND_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);
- BIND_CONSTANT(DOF_BLUR_QUALITY_HIGH);
+ BIND_ENUM_CONSTANT(BG_KEEP);
+ BIND_ENUM_CONSTANT(BG_CLEAR_COLOR);
+ BIND_ENUM_CONSTANT(BG_COLOR);
+ BIND_ENUM_CONSTANT(BG_SKY);
+ BIND_ENUM_CONSTANT(BG_CANVAS);
+ BIND_ENUM_CONSTANT(BG_MAX);
+
+ BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
+ BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SCREEN);
+ BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
+ BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_REPLACE);
+
+ BIND_ENUM_CONSTANT(TONE_MAPPER_LINEAR);
+ BIND_ENUM_CONSTANT(TONE_MAPPER_REINHARDT);
+ BIND_ENUM_CONSTANT(TONE_MAPPER_FILMIC);
+ BIND_ENUM_CONSTANT(TONE_MAPPER_ACES);
+
+ BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW);
+ BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);
+ BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH);
}
Environment::Environment() {
+ environment = VS::get_singleton()->environment_create();
+
bg_mode = BG_CLEAR_COLOR;
bg_sky_scale = 1.0;
bg_energy = 1.0;
@@ -1160,8 +1165,6 @@ Environment::Environment() {
set_adjustment_enable(adjustment_enabled); //update
- environment = VS::get_singleton()->environment_create();
-
ssr_enabled = false;
ssr_max_steps = 64;
ssr_fade_in = 0.15;
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index a7c0e2a03d..6337981b95 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -224,10 +224,10 @@ public:
void set_ssr_max_steps(int p_steps);
int get_ssr_max_steps() const;
- void set_ssr_fade_in(float p_transition);
+ void set_ssr_fade_in(float p_fade_in);
float get_ssr_fade_in() const;
- void set_ssr_fade_out(float p_transition);
+ void set_ssr_fade_out(float p_fade_out);
float get_ssr_fade_out() const;
void set_ssr_depth_tolerance(float p_depth_tolerance);
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index d1431176d6..d9ccd31f88 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -179,14 +179,14 @@ Vector<Variant> BitmapFont::_get_textures() const {
return rtextures;
}
-Error BitmapFont::create_from_fnt(const String &p_string) {
+Error BitmapFont::create_from_fnt(const String &p_file) {
//fnt format used by angelcode bmfont
//http://www.angelcode.com/products/bmfont/
- FileAccess *f = FileAccess::open(p_string, FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_file, FileAccess::READ);
if (!f) {
- ERR_EXPLAIN("Can't open font: " + p_string);
+ ERR_EXPLAIN("Can't open font: " + p_file);
ERR_FAIL_V(ERR_FILE_NOT_FOUND);
}
@@ -255,7 +255,7 @@ Error BitmapFont::create_from_fnt(const String &p_string) {
if (keys.has("file")) {
String file = keys["file"];
- file = p_string.get_base_dir() + "/" + file;
+ file = p_file.get_base_dir() + "/" + file;
Ref<Texture> tex = ResourceLoader::load(file);
if (tex.is_null()) {
ERR_PRINT("Can't load font texture!");
diff --git a/scene/resources/font.h b/scene/resources/font.h
index a04ffbdd4b..3bb7aeac85 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/gibberish_stream.cpp b/scene/resources/gibberish_stream.cpp
deleted file mode 100644
index e2994f1419..0000000000
--- a/scene/resources/gibberish_stream.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*************************************************************************/
-/* gibberish_stream.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "gibberish_stream.h"
-#include "servers/audio_server.h"
-
-//TODO: This class needs to be adapted to the new AudioStream API,
-// or dropped if nobody cares about fixing it :) (GH-3307)
-
-#if 0
-
-int AudioStreamGibberish::get_channel_count() const {
-
- return 1;
-}
-
-
-static float _get_vol_at_pos(int p_pos, int p_len, int p_x_fade) {
-
- if (p_pos < p_x_fade)
- return float(p_pos)/p_x_fade;
- else if (p_pos>(p_len-p_x_fade))
- return float(p_len-p_pos)/p_x_fade;
- else
- return 1.0;
-
-}
- int AudioStreamGibberish::randomize() {
-
- if (rand_idx==_rand_pool.size()) {
-
- for(int i=0;i<_rand_pool.size();i++) {
-
- SWAP(_rand_pool[i],_rand_pool[Math::rand()%_rand_pool.size()]);
- }
- rand_idx=0;
- }
-
- return _rand_pool[rand_idx++];
-}
-
-bool AudioStreamGibberish::mix(int32_t *p_buffer, int p_frames) {
-
- if (!active)
- return false;
-
- zeromem(p_buffer,p_frames*sizeof(int32_t));
-
- if (!paused && active_voices==0) {
-
- active_voices=1;
- playback[0].idx=randomize();
- playback[0].fp_pos=0;
- playback[0].scale=Math::random(1,1+pitch_random_scale);
- }
-
- for(int i=0;i<active_voices;i++) {
-
- RID s = _samples[playback[i].idx]->get_rid();
-
- uint64_t fp_pos=playback[i].fp_pos;
- const void *data = AudioServer::get_singleton()->sample_get_data_ptr(s);
- bool is16 = AudioServer::get_singleton()->sample_get_format(s)==AudioServer::SAMPLE_FORMAT_PCM16;
- int skip = AudioServer::get_singleton()->sample_is_stereo(s) ? 1: 0;
- uint64_t max = AudioServer::get_singleton()->sample_get_length(s) * uint64_t(FP_LEN);
- int mrate = AudioServer::get_singleton()->sample_get_mix_rate(s) * pitch_scale * playback[i].scale;
- uint64_t increment = uint64_t(mrate) * uint64_t(FP_LEN) / get_mix_rate();
-
-
- float vol_begin = _get_vol_at_pos(fp_pos>>FP_BITS,max>>FP_BITS,xfade_time*mrate);
- float vol_end = _get_vol_at_pos((fp_pos+p_frames*increment)>>FP_BITS,max>>FP_BITS,xfade_time*mrate);
-
- int32_t vol = CLAMP(int32_t(vol_begin * 65535),0,65535);
- int32_t vol_to = CLAMP(int32_t(vol_end * 65535),0,65535);
- int32_t vol_inc = (vol_to-vol)/p_frames;
-
- bool done=false;
-
- if (is16) {
-
- const int16_t *smp = (int16_t*)data;
- for(int i=0;i<p_frames;i++) {
-
- if (fp_pos >= max) {
- done=true;
- break;
- }
-
- int idx = (fp_pos>>FP_BITS)<<skip;
- p_buffer[i]+=int32_t(smp[idx])*vol;
- vol+=vol_inc;
-
- fp_pos+=increment;
- }
- } else {
-
- const int8_t *smp = (int8_t*)data;
- for(int i=0;i<p_frames;i++) {
-
- if (fp_pos >= max) {
- done=true;
- break;
- }
-
- int idx = (fp_pos>>FP_BITS)<<skip;
- p_buffer[i]+=(int32_t(smp[idx])<<8)*vol;
- vol+=vol_inc;
- fp_pos+=increment;
- }
-
- }
-
- playback[i].fp_pos=fp_pos;
- if (!paused && active_voices==1 && (vol_end < vol_begin || done)) {
- //xfade to something else i gues
- active_voices=2;
- playback[1].idx=randomize();
- playback[1].fp_pos=0;
- playback[1].scale=Math::random(1,1+pitch_random_scale);
- }
-
- if (done) {
-
- if (i==0 && active_voices==2) {
- playback[0]=playback[1];
- i--;
- }
- active_voices--;
-
- }
- }
-
- return true;
-}
-
-
-void AudioStreamGibberish::play() {
- if (active)
- stop();
-
-
- if (!phonemes.is_valid())
- return;
-
-
- List<StringName> slist;
- phonemes->get_sample_list(&slist);
- if (slist.size()==0)
- return;
-
- _samples.resize(slist.size());
- _rand_pool.resize(slist.size());
-
- int i=0;
- for(List<StringName>::Element *E=slist.front();E;E=E->next()) {
-
- _rand_pool[i]=i;
- _samples[i++]=phonemes->get_sample(E->get());
- }
-
- rand_idx=0;
- active_voices=0;
- active=true;
-}
-
-void AudioStreamGibberish::stop(){
-
- active=false;
-
-
-}
-
-bool AudioStreamGibberish::is_playing() const {
-
- return active;
-}
-
-
-void AudioStreamGibberish::set_paused(bool p_paused){
-
- paused=p_paused;
-}
-
-bool AudioStreamGibberish::is_paused(bool p_paused) const{
-
- return paused;
-}
-
-void AudioStreamGibberish::set_loop(bool p_enable){
-
-
-}
-
-bool AudioStreamGibberish::has_loop() const{
-
- return false;
-}
-
-
-float AudioStreamGibberish::get_length() const{
-
- return 0;
-}
-
-
-String AudioStreamGibberish::get_stream_name() const{
-
- return "Gibberish";
-}
-
-
-int AudioStreamGibberish::get_loop_count() const{
-
- return 0;
-}
-
-
-float AudioStreamGibberish::get_pos() const{
-
- return 0;
-}
-
-void AudioStreamGibberish::seek_pos(float p_time){
-
-
-}
-
-
-AudioStream::UpdateMode AudioStreamGibberish::get_update_mode() const{
-
- return AudioStream::UPDATE_NONE;
-}
-
-void AudioStreamGibberish::update(){
-
-
-}
-
-
-void AudioStreamGibberish::set_phonemes(const Ref<SampleLibrary>& p_phonemes) {
-
- phonemes=p_phonemes;
-
-}
-
-Ref<SampleLibrary> AudioStreamGibberish::get_phonemes() const {
-
- return phonemes;
-}
-
-void AudioStreamGibberish::set_xfade_time(float p_xfade) {
-
- xfade_time=p_xfade;
-}
-
-float AudioStreamGibberish::get_xfade_time() const {
-
- return xfade_time;
-}
-
-void AudioStreamGibberish::set_pitch_scale(float p_scale) {
-
- pitch_scale=p_scale;
-}
-
-float AudioStreamGibberish::get_pitch_scale() const {
-
- return pitch_scale;
-}
-
-void AudioStreamGibberish::set_pitch_random_scale(float p_random_scale) {
-
- pitch_random_scale=p_random_scale;
-}
-
-float AudioStreamGibberish::get_pitch_random_scale() const {
-
- return pitch_random_scale;
-}
-
-void AudioStreamGibberish::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
- ClassDB::bind_method(D_METHOD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
-
- 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(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(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"),"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");
-
-}
-
-AudioStreamGibberish::AudioStreamGibberish() {
-
- xfade_time=0.1;
- pitch_scale=1;
- pitch_random_scale=0;
- active=false;
- paused=false;
- active_voices=0;
-}
-#endif
diff --git a/scene/resources/gibberish_stream.h b/scene/resources/gibberish_stream.h
deleted file mode 100644
index ebe61382eb..0000000000
--- a/scene/resources/gibberish_stream.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************/
-/* gibberish_stream.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef GIBBERISH_STREAM_H
-#define GIBBERISH_STREAM_H
-
-//TODO: This class needs to be adapted to the new AudioStream API,
-// or dropped if nobody cares about fixing it :) (GH-3307)
-
-#if 0
-#include "scene/resources/audio_stream.h"
-#include "scene/resources/sample_library.h"
-class AudioStreamGibberish : public AudioStream {
-
- GDCLASS( AudioStreamGibberish, AudioStream );
-
- enum {
-
- FP_BITS = 12,
- FP_LEN = (1<<12),
- };
- bool active;
- bool paused;
-
- float xfade_time;
- float pitch_scale;
- float pitch_random_scale;
- Vector<Ref<Sample> > _samples;
- Vector<int> _rand_pool;
- int rand_idx;
- _FORCE_INLINE_ int randomize();
-
- struct Playback {
-
- int idx;
- uint64_t fp_pos;
- float scale;
- };
-
- Playback playback[2];
- int active_voices;
-
- Ref<SampleLibrary> phonemes;
-protected:
-
- virtual int get_channel_count() const;
- virtual bool mix(int32_t *p_buffer, int p_frames);
-
- static void _bind_methods();
-
-public:
-
- void set_phonemes(const Ref<SampleLibrary>& p_phonemes);
- Ref<SampleLibrary> get_phonemes() const;
-
- virtual void play();
- virtual void stop();
- virtual bool is_playing() const;
-
- virtual void set_paused(bool p_paused);
- virtual bool is_paused(bool p_paused) const;
-
- virtual void set_loop(bool p_enable);
- virtual bool has_loop() const;
-
- virtual float get_length() const;
-
- virtual String get_stream_name() const;
-
- virtual int get_loop_count() const;
-
- virtual float get_pos() const;
- virtual void seek_pos(float p_time);
-
- virtual UpdateMode get_update_mode() const;
- virtual void update();
-
- void set_xfade_time(float p_xfade);
- float get_xfade_time() const;
-
- void set_pitch_scale(float p_scale);
- float get_pitch_scale() const;
-
- void set_pitch_random_scale(float p_random_scale);
- float get_pitch_random_scale() const;
-
- AudioStreamGibberish();
-};
-
-#endif
-
-#endif // GIBBERISH_STREAM_H
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index bc23a41ede..5236461ad3 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "material.h"
+
#include "scene/scene_string_names.h"
void Material::set_next_pass(const Ref<Material> &p_pass) {
@@ -226,8 +227,8 @@ void SpatialMaterial::init_shaders() {
shader_names->uv1_blend_sharpness = "uv1_blend_sharpness";
shader_names->uv2_blend_sharpness = "uv2_blend_sharpness";
- shader_names->particle_h_frames = "particle_h_frames";
- shader_names->particle_v_frames = "particle_v_frames";
+ shader_names->particles_anim_h_frames = "particles_anim_h_frames";
+ shader_names->particles_anim_v_frames = "particles_anim_v_frames";
shader_names->particles_anim_loop = "particles_anim_loop";
shader_names->depth_min_layers = "depth_min_layers";
shader_names->depth_max_layers = "depth_max_layers";
@@ -502,8 +503,8 @@ void SpatialMaterial::_update_shader() {
code += "\tint particle_total_frames = particles_anim_h_frames * particles_anim_v_frames;\n";
code += "\tint particle_frame = int(INSTANCE_CUSTOM.y * float(particle_total_frames));\n";
code += "\tif (particles_anim_loop) particle_frame=clamp(particle_frame,0,particle_total_frames-1); else particle_frame=abs(particle_frame)%particle_total_frames;\n";
- //code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n";
- //code += "\tUV+= UV * vec2(float(particle_frame % particles_anim_h_frames),float(particle_frame / particles_anim_v_frames));\n";
+ code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n";
+ code += "\tUV += vec2(float(particle_frame % particles_anim_h_frames) / float(particles_anim_h_frames),float(particle_frame / particles_anim_h_frames) / float(particles_anim_v_frames));\n";
//handle rotation
// code += "\tmat4 rotation = mat4("
} break;
@@ -1280,7 +1281,7 @@ SpatialMaterial::BillboardMode SpatialMaterial::get_billboard_mode() const {
void SpatialMaterial::set_particles_anim_h_frames(int p_frames) {
particles_anim_h_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particle_h_frames, p_frames);
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
}
int SpatialMaterial::get_particles_anim_h_frames() const {
@@ -1290,7 +1291,7 @@ int SpatialMaterial::get_particles_anim_h_frames() const {
void SpatialMaterial::set_particles_anim_v_frames(int p_frames) {
particles_anim_v_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particle_v_frames, p_frames);
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
}
int SpatialMaterial::get_particles_anim_v_frames() const {
@@ -1384,7 +1385,7 @@ static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) {
}
void SpatialMaterial::set_metallic_texture_channel(TextureChannel p_channel) {
-
+ ERR_FAIL_INDEX(p_channel, 5);
metallic_texture_channel = p_channel;
VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel));
}
@@ -1395,6 +1396,7 @@ SpatialMaterial::TextureChannel SpatialMaterial::get_metallic_texture_channel()
void SpatialMaterial::set_roughness_texture_channel(TextureChannel p_channel) {
+ ERR_FAIL_INDEX(p_channel, 5);
roughness_texture_channel = p_channel;
VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness_texture_channel, _get_texture_mask(p_channel));
}
@@ -1717,88 +1719,88 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_TRIPLANAR);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness");
- BIND_CONSTANT(TEXTURE_ALBEDO);
- BIND_CONSTANT(TEXTURE_METALLIC);
- BIND_CONSTANT(TEXTURE_ROUGHNESS);
- BIND_CONSTANT(TEXTURE_EMISSION);
- BIND_CONSTANT(TEXTURE_NORMAL);
- BIND_CONSTANT(TEXTURE_RIM);
- BIND_CONSTANT(TEXTURE_CLEARCOAT);
- BIND_CONSTANT(TEXTURE_FLOWMAP);
- BIND_CONSTANT(TEXTURE_AMBIENT_OCCLUSION);
- BIND_CONSTANT(TEXTURE_DEPTH);
- BIND_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING);
- BIND_CONSTANT(TEXTURE_REFRACTION);
- BIND_CONSTANT(TEXTURE_DETAIL_MASK);
- BIND_CONSTANT(TEXTURE_DETAIL_ALBEDO);
- BIND_CONSTANT(TEXTURE_DETAIL_NORMAL);
- BIND_CONSTANT(TEXTURE_MAX);
-
- BIND_CONSTANT(DETAIL_UV_1);
- BIND_CONSTANT(DETAIL_UV_2);
-
- BIND_CONSTANT(FEATURE_TRANSPARENT);
- BIND_CONSTANT(FEATURE_EMISSION);
- BIND_CONSTANT(FEATURE_NORMAL_MAPPING);
- BIND_CONSTANT(FEATURE_RIM);
- BIND_CONSTANT(FEATURE_CLEARCOAT);
- BIND_CONSTANT(FEATURE_ANISOTROPY);
- BIND_CONSTANT(FEATURE_AMBIENT_OCCLUSION);
- BIND_CONSTANT(FEATURE_DEPTH_MAPPING);
- BIND_CONSTANT(FEATURE_SUBSURACE_SCATTERING);
- BIND_CONSTANT(FEATURE_REFRACTION);
- BIND_CONSTANT(FEATURE_DETAIL);
- BIND_CONSTANT(FEATURE_MAX);
-
- BIND_CONSTANT(BLEND_MODE_MIX);
- BIND_CONSTANT(BLEND_MODE_ADD);
- BIND_CONSTANT(BLEND_MODE_SUB);
- BIND_CONSTANT(BLEND_MODE_MUL);
-
- BIND_CONSTANT(DEPTH_DRAW_OPAQUE_ONLY);
- BIND_CONSTANT(DEPTH_DRAW_ALWAYS);
- BIND_CONSTANT(DEPTH_DRAW_DISABLED);
- BIND_CONSTANT(DEPTH_DRAW_ALPHA_OPAQUE_PREPASS);
-
- BIND_CONSTANT(CULL_BACK);
- BIND_CONSTANT(CULL_FRONT);
- BIND_CONSTANT(CULL_DISABLED);
-
- BIND_CONSTANT(FLAG_UNSHADED);
- BIND_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
- BIND_CONSTANT(FLAG_ONTOP);
- BIND_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
- BIND_CONSTANT(FLAG_SRGB_VERTEX_COLOR);
- BIND_CONSTANT(FLAG_USE_POINT_SIZE);
- BIND_CONSTANT(FLAG_FIXED_SIZE);
- BIND_CONSTANT(FLAG_UV1_USE_TRIPLANAR);
- BIND_CONSTANT(FLAG_UV2_USE_TRIPLANAR);
- BIND_CONSTANT(FLAG_AO_ON_UV2);
- BIND_CONSTANT(FLAG_USE_ALPHA_SCISSOR);
- BIND_CONSTANT(FLAG_MAX);
-
- BIND_CONSTANT(DIFFUSE_LAMBERT);
- BIND_CONSTANT(DIFFUSE_HALF_LAMBERT);
- BIND_CONSTANT(DIFFUSE_OREN_NAYAR);
- BIND_CONSTANT(DIFFUSE_BURLEY);
- BIND_CONSTANT(DIFFUSE_TOON);
-
- BIND_CONSTANT(SPECULAR_SCHLICK_GGX);
- BIND_CONSTANT(SPECULAR_BLINN);
- BIND_CONSTANT(SPECULAR_PHONG);
- BIND_CONSTANT(SPECULAR_TOON);
- BIND_CONSTANT(SPECULAR_DISABLED);
-
- BIND_CONSTANT(BILLBOARD_DISABLED);
- BIND_CONSTANT(BILLBOARD_ENABLED);
- BIND_CONSTANT(BILLBOARD_FIXED_Y);
- BIND_CONSTANT(BILLBOARD_PARTICLES);
-
- BIND_CONSTANT(TEXTURE_CHANNEL_RED);
- BIND_CONSTANT(TEXTURE_CHANNEL_GREEN);
- BIND_CONSTANT(TEXTURE_CHANNEL_BLUE);
- BIND_CONSTANT(TEXTURE_CHANNEL_ALPHA);
- BIND_CONSTANT(TEXTURE_CHANNEL_GRAYSCALE);
+ BIND_ENUM_CONSTANT(TEXTURE_ALBEDO);
+ BIND_ENUM_CONSTANT(TEXTURE_METALLIC);
+ BIND_ENUM_CONSTANT(TEXTURE_ROUGHNESS);
+ BIND_ENUM_CONSTANT(TEXTURE_EMISSION);
+ BIND_ENUM_CONSTANT(TEXTURE_NORMAL);
+ BIND_ENUM_CONSTANT(TEXTURE_RIM);
+ BIND_ENUM_CONSTANT(TEXTURE_CLEARCOAT);
+ BIND_ENUM_CONSTANT(TEXTURE_FLOWMAP);
+ BIND_ENUM_CONSTANT(TEXTURE_AMBIENT_OCCLUSION);
+ BIND_ENUM_CONSTANT(TEXTURE_DEPTH);
+ BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING);
+ BIND_ENUM_CONSTANT(TEXTURE_REFRACTION);
+ BIND_ENUM_CONSTANT(TEXTURE_DETAIL_MASK);
+ BIND_ENUM_CONSTANT(TEXTURE_DETAIL_ALBEDO);
+ BIND_ENUM_CONSTANT(TEXTURE_DETAIL_NORMAL);
+ BIND_ENUM_CONSTANT(TEXTURE_MAX);
+
+ BIND_ENUM_CONSTANT(DETAIL_UV_1);
+ BIND_ENUM_CONSTANT(DETAIL_UV_2);
+
+ BIND_ENUM_CONSTANT(FEATURE_TRANSPARENT);
+ BIND_ENUM_CONSTANT(FEATURE_EMISSION);
+ BIND_ENUM_CONSTANT(FEATURE_NORMAL_MAPPING);
+ BIND_ENUM_CONSTANT(FEATURE_RIM);
+ BIND_ENUM_CONSTANT(FEATURE_CLEARCOAT);
+ BIND_ENUM_CONSTANT(FEATURE_ANISOTROPY);
+ BIND_ENUM_CONSTANT(FEATURE_AMBIENT_OCCLUSION);
+ BIND_ENUM_CONSTANT(FEATURE_DEPTH_MAPPING);
+ BIND_ENUM_CONSTANT(FEATURE_SUBSURACE_SCATTERING);
+ BIND_ENUM_CONSTANT(FEATURE_REFRACTION);
+ BIND_ENUM_CONSTANT(FEATURE_DETAIL);
+ BIND_ENUM_CONSTANT(FEATURE_MAX);
+
+ BIND_ENUM_CONSTANT(BLEND_MODE_MIX);
+ BIND_ENUM_CONSTANT(BLEND_MODE_ADD);
+ BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
+ BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+
+ BIND_ENUM_CONSTANT(DEPTH_DRAW_OPAQUE_ONLY);
+ BIND_ENUM_CONSTANT(DEPTH_DRAW_ALWAYS);
+ BIND_ENUM_CONSTANT(DEPTH_DRAW_DISABLED);
+ BIND_ENUM_CONSTANT(DEPTH_DRAW_ALPHA_OPAQUE_PREPASS);
+
+ BIND_ENUM_CONSTANT(CULL_BACK);
+ BIND_ENUM_CONSTANT(CULL_FRONT);
+ BIND_ENUM_CONSTANT(CULL_DISABLED);
+
+ BIND_ENUM_CONSTANT(FLAG_UNSHADED);
+ BIND_ENUM_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
+ BIND_ENUM_CONSTANT(FLAG_ONTOP);
+ BIND_ENUM_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
+ BIND_ENUM_CONSTANT(FLAG_SRGB_VERTEX_COLOR);
+ BIND_ENUM_CONSTANT(FLAG_USE_POINT_SIZE);
+ BIND_ENUM_CONSTANT(FLAG_FIXED_SIZE);
+ BIND_ENUM_CONSTANT(FLAG_UV1_USE_TRIPLANAR);
+ BIND_ENUM_CONSTANT(FLAG_UV2_USE_TRIPLANAR);
+ BIND_ENUM_CONSTANT(FLAG_AO_ON_UV2);
+ BIND_ENUM_CONSTANT(FLAG_USE_ALPHA_SCISSOR);
+ BIND_ENUM_CONSTANT(FLAG_MAX);
+
+ BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT);
+ BIND_ENUM_CONSTANT(DIFFUSE_HALF_LAMBERT);
+ BIND_ENUM_CONSTANT(DIFFUSE_OREN_NAYAR);
+ BIND_ENUM_CONSTANT(DIFFUSE_BURLEY);
+ BIND_ENUM_CONSTANT(DIFFUSE_TOON);
+
+ BIND_ENUM_CONSTANT(SPECULAR_SCHLICK_GGX);
+ BIND_ENUM_CONSTANT(SPECULAR_BLINN);
+ BIND_ENUM_CONSTANT(SPECULAR_PHONG);
+ BIND_ENUM_CONSTANT(SPECULAR_TOON);
+ BIND_ENUM_CONSTANT(SPECULAR_DISABLED);
+
+ BIND_ENUM_CONSTANT(BILLBOARD_DISABLED);
+ BIND_ENUM_CONSTANT(BILLBOARD_ENABLED);
+ BIND_ENUM_CONSTANT(BILLBOARD_FIXED_Y);
+ BIND_ENUM_CONSTANT(BILLBOARD_PARTICLES);
+
+ BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_RED);
+ BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_GREEN);
+ BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_BLUE);
+ BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_ALPHA);
+ BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_GRAYSCALE);
}
SpatialMaterial::SpatialMaterial()
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 25628e272a..6a0eead708 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -283,8 +283,8 @@ private:
StringName uv1_offset;
StringName uv2_scale;
StringName uv2_offset;
- StringName particle_h_frames;
- StringName particle_v_frames;
+ StringName particles_anim_h_frames;
+ StringName particles_anim_v_frames;
StringName particles_anim_loop;
StringName depth_min_layers;
StringName depth_max_layers;
@@ -431,7 +431,7 @@ public:
void set_depth_deep_parallax_max_layers(int p_layer);
int get_depth_deep_parallax_max_layers() const;
- void set_subsurface_scattering_strength(float p_strength);
+ void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
float get_subsurface_scattering_strength() const;
void set_refraction(float p_refraction);
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index af30e75aed..aa7827a61a 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -415,13 +415,13 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
void Mesh::_bind_methods() {
- BIND_CONSTANT(PRIMITIVE_POINTS);
- BIND_CONSTANT(PRIMITIVE_LINES);
- BIND_CONSTANT(PRIMITIVE_LINE_STRIP);
- BIND_CONSTANT(PRIMITIVE_LINE_LOOP);
- BIND_CONSTANT(PRIMITIVE_TRIANGLES);
- BIND_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
- BIND_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
+ BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
+ BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
+ BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
+ BIND_ENUM_CONSTANT(PRIMITIVE_LINE_LOOP);
+ BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
+ BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
+ BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
}
Mesh::Mesh() {
@@ -1026,25 +1026,26 @@ void ArrayMesh::_bind_methods() {
BIND_CONSTANT(NO_INDEX_ARRAY);
BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
- BIND_CONSTANT(ARRAY_VERTEX);
- BIND_CONSTANT(ARRAY_NORMAL);
- BIND_CONSTANT(ARRAY_TANGENT);
- BIND_CONSTANT(ARRAY_COLOR);
- BIND_CONSTANT(ARRAY_TEX_UV);
- BIND_CONSTANT(ARRAY_TEX_UV2);
- BIND_CONSTANT(ARRAY_BONES);
- BIND_CONSTANT(ARRAY_WEIGHTS);
- BIND_CONSTANT(ARRAY_INDEX);
-
- BIND_CONSTANT(ARRAY_FORMAT_VERTEX);
- BIND_CONSTANT(ARRAY_FORMAT_NORMAL);
- BIND_CONSTANT(ARRAY_FORMAT_TANGENT);
- BIND_CONSTANT(ARRAY_FORMAT_COLOR);
- BIND_CONSTANT(ARRAY_FORMAT_TEX_UV);
- BIND_CONSTANT(ARRAY_FORMAT_TEX_UV2);
- BIND_CONSTANT(ARRAY_FORMAT_BONES);
- BIND_CONSTANT(ARRAY_FORMAT_WEIGHTS);
- BIND_CONSTANT(ARRAY_FORMAT_INDEX);
+ BIND_ENUM_CONSTANT(ARRAY_VERTEX);
+ BIND_ENUM_CONSTANT(ARRAY_NORMAL);
+ BIND_ENUM_CONSTANT(ARRAY_TANGENT);
+ BIND_ENUM_CONSTANT(ARRAY_COLOR);
+ BIND_ENUM_CONSTANT(ARRAY_TEX_UV);
+ BIND_ENUM_CONSTANT(ARRAY_TEX_UV2);
+ BIND_ENUM_CONSTANT(ARRAY_BONES);
+ BIND_ENUM_CONSTANT(ARRAY_WEIGHTS);
+ BIND_ENUM_CONSTANT(ARRAY_INDEX);
+ BIND_ENUM_CONSTANT(ARRAY_MAX);
+
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_VERTEX);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_NORMAL);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_TANGENT);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_COLOR);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_TEX_UV2);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_BONES);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_WEIGHTS);
+ BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX);
}
ArrayMesh::ArrayMesh() {
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index e40ef99237..53c6eb2d89 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -187,7 +187,7 @@ public:
int get_surface_count() const;
void surface_remove(int p_idx);
- void surface_set_custom_aabb(int p_surface, const Rect3 &p_aabb); //only recognized by driver
+ void surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb); //only recognized by driver
int surface_get_array_len(int p_idx) const;
int surface_get_array_index_len(int p_idx) const;
@@ -218,6 +218,7 @@ public:
};
VARIANT_ENUM_CAST(Mesh::ArrayType);
+VARIANT_ENUM_CAST(Mesh::ArrayFormat);
VARIANT_ENUM_CAST(Mesh::PrimitiveType);
VARIANT_ENUM_CAST(Mesh::BlendShapeMode);
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index f1092a90cb..116ddc4ac6 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/mesh_data_tool.h b/scene/resources/mesh_data_tool.h
index ad771edbd1..119b49161b 100644
--- a/scene/resources/mesh_data_tool.h
+++ b/scene/resources/mesh_data_tool.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 7d51a2617e..4e1ffd2ab3 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -43,9 +43,15 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
set_item_name(idx, p_value);
else if (what == "mesh")
set_item_mesh(idx, p_value);
- else if (what == "shape")
- set_item_shape(idx, p_value);
- else if (what == "preview")
+ else if (what == "shape") {
+ Vector<ShapeData> shapes;
+ ShapeData sd;
+ sd.shape = p_value;
+ shapes.push_back(sd);
+ set_item_shapes(idx, shapes);
+ } else if (what == "shapes") {
+ _set_item_shapes(idx, p_value);
+ } else if (what == "preview")
set_item_preview(idx, p_value);
else if (what == "navmesh")
set_item_navmesh(idx, p_value);
@@ -69,8 +75,8 @@ bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_item_name(idx);
else if (what == "mesh")
r_ret = get_item_mesh(idx);
- else if (what == "shape")
- r_ret = get_item_shape(idx);
+ else if (what == "shapes")
+ r_ret = _get_item_shapes(idx);
else if (what == "navmesh")
r_ret = get_item_navmesh(idx);
else if (what == "preview")
@@ -88,7 +94,7 @@ void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
String name = "item/" + itos(E->key()) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, name + "name"));
p_list->push_back(PropertyInfo(Variant::OBJECT, name + "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, name + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, name + "shapes"));
p_list->push_back(PropertyInfo(Variant::OBJECT, name + "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
}
@@ -118,10 +124,10 @@ void MeshLibrary::set_item_mesh(int p_item, const Ref<Mesh> &p_mesh) {
_change_notify();
}
-void MeshLibrary::set_item_shape(int p_item, const Ref<Shape> &p_shape) {
+void MeshLibrary::set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes) {
ERR_FAIL_COND(!item_map.has(p_item));
- item_map[p_item].shape = p_shape;
+ item_map[p_item].shapes = p_shapes;
_change_notify();
notify_change_to_owners();
emit_changed();
@@ -156,10 +162,10 @@ Ref<Mesh> MeshLibrary::get_item_mesh(int p_item) const {
return item_map[p_item].mesh;
}
-Ref<Shape> MeshLibrary::get_item_shape(int p_item) const {
+Vector<MeshLibrary::ShapeData> MeshLibrary::get_item_shapes(int p_item) const {
- ERR_FAIL_COND_V(!item_map.has(p_item), Ref<Shape>());
- return item_map[p_item].shape;
+ ERR_FAIL_COND_V(!item_map.has(p_item), Vector<ShapeData>());
+ return item_map[p_item].shapes;
}
Ref<NavigationMesh> MeshLibrary::get_item_navmesh(int p_item) const {
@@ -226,17 +232,48 @@ int MeshLibrary::get_last_unused_item_id() const {
return item_map.back()->key() + 1;
}
+void MeshLibrary::_set_item_shapes(int p_item, const Array &p_shapes) {
+
+ ERR_FAIL_COND(p_shapes.size() & 1);
+ Vector<ShapeData> shapes;
+ for (int i = 0; i < p_shapes.size(); i += 2) {
+ ShapeData sd;
+ sd.shape = p_shapes[i + 0];
+ sd.local_transform = p_shapes[i + 1];
+
+ if (sd.shape.is_valid()) {
+ shapes.push_back(sd);
+ }
+ }
+
+ set_item_shapes(p_item, shapes);
+}
+
+Array MeshLibrary::_get_item_shapes(int p_item) const {
+
+ Vector<ShapeData> shapes = get_item_shapes(p_item);
+ Array ret;
+ for (int i = 0; i < shapes.size(); i++) {
+ ret.push_back(shapes[i].shape);
+ ret.push_back(shapes[i].local_transform);
+ }
+
+ return ret;
+}
+
void MeshLibrary::_bind_methods() {
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"), &MeshLibrary::set_item_mesh);
ClassDB::bind_method(D_METHOD("set_item_navmesh", "id", "navmesh"), &MeshLibrary::set_item_navmesh);
- ClassDB::bind_method(D_METHOD("set_item_shape", "id", "shape"), &MeshLibrary::set_item_shape);
+ ClassDB::bind_method(D_METHOD("set_item_shapes", "id", "shapes"), &MeshLibrary::_set_item_shapes);
+ ClassDB::bind_method(D_METHOD("set_item_preview", "id", "texture"), &MeshLibrary::set_item_preview);
ClassDB::bind_method(D_METHOD("get_item_name", "id"), &MeshLibrary::get_item_name);
ClassDB::bind_method(D_METHOD("get_item_mesh", "id"), &MeshLibrary::get_item_mesh);
ClassDB::bind_method(D_METHOD("get_item_navmesh", "id"), &MeshLibrary::get_item_navmesh);
- ClassDB::bind_method(D_METHOD("get_item_shape", "id"), &MeshLibrary::get_item_shape);
+ ClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes);
+ ClassDB::bind_method(D_METHOD("get_item_preview", "id"), &MeshLibrary::get_item_preview);
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);
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index cc39110a99..99b6b48d61 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -41,16 +41,24 @@ class MeshLibrary : public Resource {
GDCLASS(MeshLibrary, Resource);
RES_BASE_EXTENSION("meshlib");
+public:
+ struct ShapeData {
+ Ref<Shape> shape;
+ Transform local_transform;
+ };
struct Item {
String name;
Ref<Mesh> mesh;
- Ref<Shape> shape;
+ Vector<ShapeData> shapes;
Ref<Texture> preview;
Ref<NavigationMesh> navmesh;
};
Map<int, Item> item_map;
+ void _set_item_shapes(int p_item, const Array &p_shapes);
+ Array _get_item_shapes(int p_item) const;
+
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
@@ -63,12 +71,12 @@ public:
void set_item_name(int p_item, const String &p_name);
void set_item_mesh(int p_item, const Ref<Mesh> &p_mesh);
void set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh);
- void set_item_shape(int p_item, const Ref<Shape> &p_shape);
+ void set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes);
void set_item_preview(int p_item, const Ref<Texture> &p_preview);
String get_item_name(int p_item) const;
Ref<Mesh> get_item_mesh(int p_item) const;
Ref<NavigationMesh> get_item_navmesh(int p_item) const;
- Ref<Shape> get_item_shape(int p_item) const;
+ Vector<ShapeData> get_item_shapes(int p_item) const;
Ref<Texture> get_item_preview(int p_item) const;
void remove_item(int p_item);
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 231e59cdb5..15f1e15542 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -213,11 +213,12 @@ void MultiMesh::_bind_methods() {
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");
- BIND_CONSTANT(TRANSFORM_2D);
- BIND_CONSTANT(TRANSFORM_3D);
- BIND_CONSTANT(COLOR_NONE);
- BIND_CONSTANT(COLOR_8BIT);
- BIND_CONSTANT(COLOR_FLOAT);
+ BIND_ENUM_CONSTANT(TRANSFORM_2D);
+ BIND_ENUM_CONSTANT(TRANSFORM_3D);
+
+ BIND_ENUM_CONSTANT(COLOR_NONE);
+ BIND_ENUM_CONSTANT(COLOR_8BIT);
+ BIND_ENUM_CONSTANT(COLOR_FLOAT);
}
MultiMesh::MultiMesh() {
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 7d6a0ce44f..7ca66b0b46 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index ce1d6f311f..19fab5d587 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "packed_scene.h"
+
#include "core/core_string_names.h"
#include "io/resource_loader.h"
#include "project_settings.h"
@@ -35,6 +36,7 @@
#include "scene/3d/spatial.h"
#include "scene/gui/control.h"
#include "scene/main/instance_placeholder.h"
+
#define PACK_VERSION 2
bool SceneState::can_instance() const {
@@ -151,18 +153,18 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
//print_line("created");
//node belongs to this scene and must be created
Object *obj = ClassDB::instance(snames[n.type]);
- if (!obj || !obj->cast_to<Node>()) {
+ if (!Object::cast_to<Node>(obj)) {
if (obj) {
memdelete(obj);
obj = NULL;
}
WARN_PRINT(String("Warning node of type " + snames[n.type].operator String() + " does not exist.").ascii().get_data());
if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) {
- if (ret_nodes[n.parent]->cast_to<Spatial>()) {
+ if (Object::cast_to<Spatial>(ret_nodes[n.parent])) {
obj = memnew(Spatial);
- } else if (ret_nodes[n.parent]->cast_to<Control>()) {
+ } else if (Object::cast_to<Control>(ret_nodes[n.parent])) {
obj = memnew(Control);
- } else if (ret_nodes[n.parent]->cast_to<Node2D>()) {
+ } else if (Object::cast_to<Node2D>(ret_nodes[n.parent])) {
obj = memnew(Node2D);
}
}
@@ -172,7 +174,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
}
- node = obj->cast_to<Node>();
+ node = Object::cast_to<Node>(obj);
} else {
print_line("wtf class is disabled for: " + itos(n.type));
@@ -242,7 +244,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
value = local_dupe;
}
- res->setup_local_to_scene();
+ //this here may reference nodes not iniialized so this line is commented and used after loading all nodes
+ //res->setup_local_to_scene();
}
//must make a copy, because this res is local to scene
}
@@ -293,6 +296,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
}
+ for (Map<Ref<Resource>, Ref<Resource> >::Element *E = resources_local_to_scene.front(); E; E = E->next()) {
+
+ E->get()->setup_local_to_scene();
+ }
+
//do connections
int cc = connections.size();
@@ -445,60 +453,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
}
-#if 0
-
- Ref<SceneState> base_scene = p_node->get_scene_inherited_state(); //for inheritance
- Ref<SceneState> instance_state;
- int instance_state_node=-1;
-
- if (base_scene.is_valid() && (p_node==p_owner || p_node->get_owner()==p_owner)) {
- //scene inheritance in use, see if this node is actually inherited
- NodePath path = p_owner->get_path_to(p_node);
- instance_state_node = base_scene->find_node_by_path(path);
- if (instance_state_node>=0) {
- instance_state=base_scene;
- }
- }
-
- // check that this is a directly instanced scene from the scene being packed, if so
- // this information must be saved. Of course, if using scene instancing and this node
- // does belong to base scene, ignore.
-
- if (instance_state.is_null() && p_node!=p_owner && p_node->get_owner()==p_owner && p_node->get_filename()!="") {
-
- //instanced, only direct sub-scnes are supported of course
- Ref<PackedScene> instance = ResourceLoader::load(p_node->get_filename());
- if (!instance.is_valid()) {
- return ERR_CANT_OPEN;
- }
-
- nd.instance=_vm_get_variant(instance,variant_map);
-
- } else {
-
- nd.instance=-1;
- }
-
- // finally, if this does not belong to scene inheritance, check
- // if it belongs to scene instancing
-
- if (instance_state.is_null() && p_node!=p_owner) {
- //if not affected by scene inheritance, this may be
- if (p_node->get_owner()==p_owner && p_node->get_filename()!=String()) {
- instance_state=p_node->get_scene_instance_state();
- if (instance_state.is_valid()) {
- instance_state_node=instance_state->find_node_by_path(p_node->get_path_to(p_node));
- }
-
- } else if (p_node->get_owner()!=p_owner && p_owner->is_editable_instance(p_node->get_owner())) {
- instance_state=p_node->get_owner()->get_scene_instance_state();
- if (instance_state.is_valid()) {
- instance_state_node=instance_state->find_node_by_path(p_node->get_owner()->get_path_to(p_node));
- }
- }
- }
-#endif
-
// all setup, we then proceed to check all properties for the node
// and save the ones that are worth saving
@@ -635,27 +589,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
} else {
nd.owner = -1;
-#if 0
- // this is pointless, if this was instanced by something else,
- // the owner will already be set.
-
- if (node_map.has(p_node->get_owner())) {
- //maybe an existing saved node
- nd.owner=node_map[p_node->get_owner()];
- } else {
- //not saved, use nodepath map
- int sidx;
- if (nodepath_map.has(p_node->get_owner())) {
- sidx=nodepath_map[p_node->get_owner()];
- } else {
- sidx=nodepath_map.size();
- nodepath_map[p_node->get_owner()]=sidx;
- }
-
- nd.owner=FLAG_ID_IS_PATH|sidx;
-
- }
-#endif
}
// Save the right type. If this node was created by an instance
@@ -748,7 +681,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
// only connections that originate or end into main saved scene are saved
// everything else is discarded
- Node *target = c.target->cast_to<Node>();
+ Node *target = Object::cast_to<Node>(c.target);
if (!target) {
continue;
@@ -1127,26 +1060,26 @@ bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_
return false;
}
-void SceneState::set_bundled_scene(const Dictionary &d) {
+void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
- ERR_FAIL_COND(!d.has("names"));
- ERR_FAIL_COND(!d.has("variants"));
- ERR_FAIL_COND(!d.has("node_count"));
- 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(!p_dictionary.has("names"));
+ ERR_FAIL_COND(!p_dictionary.has("variants"));
+ ERR_FAIL_COND(!p_dictionary.has("node_count"));
+ ERR_FAIL_COND(!p_dictionary.has("nodes"));
+ ERR_FAIL_COND(!p_dictionary.has("conn_count"));
+ ERR_FAIL_COND(!p_dictionary.has("conns"));
+ //ERR_FAIL_COND( !p_dictionary.has("path"));
int version = 1;
- if (d.has("version"))
- version = d["version"];
+ if (p_dictionary.has("version"))
+ version = p_dictionary["version"];
if (version > PACK_VERSION) {
ERR_EXPLAIN("Save format version too new!");
ERR_FAIL();
}
- PoolVector<String> snames = d["names"];
+ PoolVector<String> snames = p_dictionary["names"];
if (snames.size()) {
int namecount = snames.size();
@@ -1156,7 +1089,7 @@ void SceneState::set_bundled_scene(const Dictionary &d) {
names[i] = r[i];
}
- Array svariants = d["variants"];
+ Array svariants = p_dictionary["variants"];
if (svariants.size()) {
int varcount = svariants.size();
@@ -1170,10 +1103,10 @@ void SceneState::set_bundled_scene(const Dictionary &d) {
variants.clear();
}
- nodes.resize(d["node_count"]);
+ nodes.resize(p_dictionary["node_count"]);
int nc = nodes.size();
if (nc) {
- PoolVector<int> snodes = d["nodes"];
+ PoolVector<int> snodes = p_dictionary["nodes"];
PoolVector<int>::Read r = snodes.read();
int idx = 0;
for (int i = 0; i < nc; i++) {
@@ -1197,12 +1130,12 @@ void SceneState::set_bundled_scene(const Dictionary &d) {
}
}
- connections.resize(d["conn_count"]);
+ connections.resize(p_dictionary["conn_count"]);
int cc = connections.size();
if (cc) {
- PoolVector<int> sconns = d["conns"];
+ PoolVector<int> sconns = p_dictionary["conns"];
PoolVector<int>::Read r = sconns.read();
int idx = 0;
for (int i = 0; i < cc; i++) {
@@ -1222,8 +1155,8 @@ void SceneState::set_bundled_scene(const Dictionary &d) {
}
Array np;
- if (d.has("node_paths")) {
- np = d["node_paths"];
+ if (p_dictionary.has("node_paths")) {
+ np = p_dictionary["node_paths"];
}
node_paths.resize(np.size());
for (int i = 0; i < np.size(); i++) {
@@ -1231,12 +1164,12 @@ void SceneState::set_bundled_scene(const Dictionary &d) {
}
Array ei;
- if (d.has("editable_instances")) {
- ei = d["editable_instances"];
+ if (p_dictionary.has("editable_instances")) {
+ ei = p_dictionary["editable_instances"];
}
- if (d.has("base_scene")) {
- base_scene_idx = d["base_scene"];
+ if (p_dictionary.has("base_scene")) {
+ base_scene_idx = p_dictionary["base_scene"];
}
editable_instances.resize(ei.size());
@@ -1244,7 +1177,7 @@ void SceneState::set_bundled_scene(const Dictionary &d) {
editable_instances[i] = ei[i];
}
- //path=d["path"];
+ //path=p_dictionary["path"];
}
Dictionary SceneState::get_bundled_scene() const {
@@ -1683,9 +1616,9 @@ void SceneState::_bind_methods() {
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);
- BIND_CONSTANT(GEN_EDIT_STATE_MAIN);
+ BIND_ENUM_CONSTANT(GEN_EDIT_STATE_DISABLED);
+ BIND_ENUM_CONSTANT(GEN_EDIT_STATE_INSTANCE);
+ BIND_ENUM_CONSTANT(GEN_EDIT_STATE_MAIN);
}
SceneState::SceneState() {
@@ -1696,9 +1629,9 @@ SceneState::SceneState() {
////////////////
-void PackedScene::_set_bundled_scene(const Dictionary &d) {
+void PackedScene::_set_bundled_scene(const Dictionary &p_scene) {
- state->set_bundled_scene(d);
+ state->set_bundled_scene(p_scene);
}
Dictionary PackedScene::_get_bundled_scene() const {
@@ -1786,9 +1719,9 @@ void PackedScene::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_bundled"), "_set_bundled_scene", "_get_bundled_scene");
- BIND_CONSTANT(GEN_EDIT_STATE_DISABLED);
- BIND_CONSTANT(GEN_EDIT_STATE_INSTANCE);
- BIND_CONSTANT(GEN_EDIT_STATE_MAIN);
+ BIND_ENUM_CONSTANT(GEN_EDIT_STATE_DISABLED);
+ BIND_ENUM_CONSTANT(GEN_EDIT_STATE_INSTANCE);
+ BIND_ENUM_CONSTANT(GEN_EDIT_STATE_MAIN);
}
PackedScene::PackedScene() {
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index 2f18f5c263..20bfb19b1f 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/plane_shape.cpp b/scene/resources/plane_shape.cpp
index d3ad454afc..2b1e890a5d 100644
--- a/scene/resources/plane_shape.cpp
+++ b/scene/resources/plane_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/plane_shape.h b/scene/resources/plane_shape.h
index 2ed297a97e..1384b7521b 100644
--- a/scene/resources/plane_shape.h
+++ b/scene/resources/plane_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 80b413630a..053369e8d8 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h
index 2d2fb1678e..9b760caa2e 100644
--- a/scene/resources/polygon_path_finder.h
+++ b/scene/resources/polygon_path_finder.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 065e7a84dd..cfc1468533 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -618,8 +618,8 @@ Vector3 CubeMesh::get_size() const {
return size;
}
-void CubeMesh::set_subdivide_width(const int p_subdivide) {
- subdivide_w = p_subdivide > 0 ? p_subdivide : 0;
+void CubeMesh::set_subdivide_width(const int p_divisions) {
+ subdivide_w = p_divisions > 0 ? p_divisions : 0;
_request_update();
}
@@ -627,8 +627,8 @@ int CubeMesh::get_subdivide_width() const {
return subdivide_w;
}
-void CubeMesh::set_subdivide_height(const int p_subdivide) {
- subdivide_h = p_subdivide > 0 ? p_subdivide : 0;
+void CubeMesh::set_subdivide_height(const int p_divisions) {
+ subdivide_h = p_divisions > 0 ? p_divisions : 0;
_request_update();
}
@@ -636,8 +636,8 @@ int CubeMesh::get_subdivide_height() const {
return subdivide_h;
}
-void CubeMesh::set_subdivide_depth(const int p_subdivide) {
- subdivide_d = p_subdivide > 0 ? p_subdivide : 0;
+void CubeMesh::set_subdivide_depth(const int p_divisions) {
+ subdivide_d = p_divisions > 0 ? p_divisions : 0;
_request_update();
}
@@ -957,8 +957,8 @@ Size2 PlaneMesh::get_size() const {
return size;
}
-void PlaneMesh::set_subdivide_width(const int p_subdivide) {
- subdivide_w = p_subdivide > 0 ? p_subdivide : 0;
+void PlaneMesh::set_subdivide_width(const int p_divisions) {
+ subdivide_w = p_divisions > 0 ? p_divisions : 0;
_request_update();
}
@@ -966,8 +966,8 @@ int PlaneMesh::get_subdivide_width() const {
return subdivide_w;
}
-void PlaneMesh::set_subdivide_depth(const int p_subdivide) {
- subdivide_d = p_subdivide > 0 ? p_subdivide : 0;
+void PlaneMesh::set_subdivide_depth(const int p_divisions) {
+ subdivide_d = p_divisions > 0 ? p_divisions : 0;
_request_update();
}
@@ -1016,13 +1016,9 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const {
for (j = 0; j <= (subdivide_h + 1); j++) {
float scale = (y - start_pos.y) / size.y;
float scaled_size_x = size.x * scale;
- float start_x = start_pos.x;
- float offset_front = 0.0;
- float offset_back = 0.0;
-
- start_x += (1.0 - scale) * size.x * left_to_right;
- offset_front += (1.0 - scale) * onethird * left_to_right;
- offset_back = (1.0 - scale) * onethird * (1.0 - left_to_right);
+ float start_x = start_pos.x + (1.0 - scale) * size.x * left_to_right;
+ float offset_front = (1.0 - scale) * onethird * left_to_right;
+ float offset_back = (1.0 - scale) * onethird * (1.0 - left_to_right);
x = 0.0;
for (i = 0; i <= (subdivide_w + 1); i++) {
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index bcd5d30dd3..34fb75a196 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape.cpp
index 3abb2a4fa1..ccce7660c6 100644
--- a/scene/resources/ray_shape.cpp
+++ b/scene/resources/ray_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/ray_shape.h b/scene/resources/ray_shape.h
index 5a17e9414e..06b68adbae 100644
--- a/scene/resources/ray_shape.h
+++ b/scene/resources/ray_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp
index bd9ec8cbc4..507dbce861 100644
--- a/scene/resources/rectangle_shape_2d.cpp
+++ b/scene/resources/rectangle_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/rectangle_shape_2d.h b/scene/resources/rectangle_shape_2d.h
index 23db58ba07..81d9cb1f4a 100644
--- a/scene/resources/rectangle_shape_2d.h
+++ b/scene/resources/rectangle_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index c89b7c72c7..487975dd4e 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -31,6 +31,8 @@
#include "servers/visual_server.h"
+// FIXME: Left for reference for reimplementation using Area
+#if 0
RID RoomBounds::get_rid() const {
return area;
@@ -64,3 +66,4 @@ RoomBounds::~RoomBounds() {
VisualServer::get_singleton()->free(area);
}
+#endif
diff --git a/scene/resources/room.h b/scene/resources/room.h
index 1bcdec5eb0..aadee858c2 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -36,6 +36,9 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
+//left for reference but will be removed when portals are reimplemented using Area
+#if 0
+
class RoomBounds : public Resource {
GDCLASS(RoomBounds, Resource);
@@ -50,11 +53,12 @@ protected:
public:
virtual RID get_rid() const;
- void set_geometry_hint(const PoolVector<Face3> &geometry_hint);
+ void set_geometry_hint(const PoolVector<Face3> &p_geometry_hint);
PoolVector<Face3> get_geometry_hint() const;
RoomBounds();
~RoomBounds();
};
+#endif
#endif // ROOM_H
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index 03a862b744..fea5c11dec 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -239,7 +239,7 @@ Error ResourceInteractiveLoaderText::poll() {
return error;
}
- Resource *r = obj->cast_to<Resource>();
+ Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
error_text += "Can't create sub resource of type, because not a resource: " + type;
@@ -305,7 +305,7 @@ Error ResourceInteractiveLoaderText::poll() {
return error;
}
- Resource *r = obj->cast_to<Resource>();
+ Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
error_text += "Can't create sub resource of type, because not a resource: " + res_type;
@@ -621,9 +621,9 @@ ResourceInteractiveLoaderText::~ResourceInteractiveLoaderText() {
memdelete(f);
}
-void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f, List<String> *p_dependencies, bool p_add_types) {
+void ResourceInteractiveLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types) {
- open(f);
+ open(p_f);
ignore_resource_parsing = true;
ERR_FAIL_COND(error != OK);
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index 1ea6465c21..193bcf7112 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index 99062d693b..1171db5c02 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/segment_shape_2d.h b/scene/resources/segment_shape_2d.h
index 22fc1ab6e3..eb9c228c83 100644
--- a/scene/resources/segment_shape_2d.h
+++ b/scene/resources/segment_shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index b72eb9fbef..ec41630258 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -137,9 +137,9 @@ void Shader::_bind_methods() {
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);
- BIND_CONSTANT(MODE_PARTICLES);
+ BIND_ENUM_CONSTANT(MODE_SPATIAL);
+ BIND_ENUM_CONSTANT(MODE_CANVAS_ITEM);
+ BIND_ENUM_CONSTANT(MODE_PARTICLES);
}
Shader::Shader() {
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 0e8e48d82e..5cc70629c7 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index f68aed6af9..2ca9a14562 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,8 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_graph.h"
+
#include "scene/scene_string_names.h"
+// FIXME: Needs to be ported to the new 3.0 shader API
#if 0
Array ShaderGraph::_get_node_list(ShaderType p_type) const {
@@ -272,204 +274,131 @@ void ShaderGraph::_bind_methods() {
//void get_connections(ShaderType p_which,List<Connection> *p_connections) const;
- BIND_CONSTANT( NODE_INPUT ); // all inputs (shader type dependent)
- BIND_CONSTANT( NODE_SCALAR_CONST ); //scalar constant
- BIND_CONSTANT( NODE_VEC_CONST ); //vec3 constant
- BIND_CONSTANT( NODE_RGB_CONST ); //rgb constant (shows a color picker instead)
- BIND_CONSTANT( NODE_XFORM_CONST ); // 4x4 matrix constant
- BIND_CONSTANT( NODE_TIME ); // time in seconds
- BIND_CONSTANT( NODE_SCREEN_TEX ); // screen texture sampler (takes UV) (only usable in fragment shader)
- BIND_CONSTANT( NODE_SCALAR_OP ); // scalar vs scalar op (mul ); add ); div ); etc)
- BIND_CONSTANT( NODE_VEC_OP ); // vec3 vs vec3 op (mul );ad );div );crossprod );etc)
- BIND_CONSTANT( NODE_VEC_SCALAR_OP ); // vec3 vs scalar op (mul ); add ); div ); etc)
- BIND_CONSTANT( NODE_RGB_OP ); // vec3 vs vec3 rgb op (with scalar amount) ); like brighten ); darken ); burn ); dodge ); multiply ); etc.
- BIND_CONSTANT( NODE_XFORM_MULT ); // mat4 x mat4
- BIND_CONSTANT( NODE_XFORM_VEC_MULT ); // mat4 x vec3 mult (with no-translation option)
- BIND_CONSTANT( NODE_XFORM_VEC_INV_MULT ); // mat4 x vec3 inverse mult (with no-translation option)
- BIND_CONSTANT( NODE_SCALAR_FUNC ); // scalar function (sin ); cos ); etc)
- BIND_CONSTANT( NODE_VEC_FUNC ); // vector function (normalize ); negate ); reciprocal ); rgb2hsv ); hsv2rgb ); etc ); etc)
- BIND_CONSTANT( NODE_VEC_LEN ); // vec3 length
- BIND_CONSTANT( NODE_DOT_PROD ); // vec3 . vec3 (dot product -> scalar output)
- BIND_CONSTANT( NODE_VEC_TO_SCALAR ); // 1 vec3 input ); 3 scalar outputs
- BIND_CONSTANT( NODE_SCALAR_TO_VEC ); // 3 scalar input ); 1 vec3 output
- BIND_CONSTANT( NODE_VEC_TO_XFORM ); // 3 vec input ); 1 xform output
- BIND_CONSTANT( NODE_XFORM_TO_VEC ); // 3 vec input ); 1 xform output
- BIND_CONSTANT( NODE_SCALAR_INTERP ); // scalar interpolation (with optional curve)
- BIND_CONSTANT( NODE_VEC_INTERP ); // vec3 interpolation (with optional curve)
- BIND_CONSTANT( NODE_COLOR_RAMP );
- BIND_CONSTANT( NODE_CURVE_MAP );
- BIND_CONSTANT( NODE_SCALAR_INPUT ); // scalar uniform (assignable in material)
- BIND_CONSTANT( NODE_VEC_INPUT ); // vec3 uniform (assignable in material)
- BIND_CONSTANT( NODE_RGB_INPUT ); // color uniform (assignable in material)
- BIND_CONSTANT( NODE_XFORM_INPUT ); // mat4 uniform (assignable in material)
- BIND_CONSTANT( NODE_TEXTURE_INPUT ); // texture input (assignable in material)
- BIND_CONSTANT( NODE_CUBEMAP_INPUT ); // cubemap input (assignable in material)
- BIND_CONSTANT( NODE_DEFAULT_TEXTURE );
- BIND_CONSTANT( NODE_OUTPUT ); // output (shader type dependent)
- BIND_CONSTANT( NODE_COMMENT ); // comment
- BIND_CONSTANT( NODE_TYPE_MAX );
-
- BIND_CONSTANT( SLOT_TYPE_SCALAR );
- BIND_CONSTANT( SLOT_TYPE_VEC );
- BIND_CONSTANT( SLOT_TYPE_XFORM );
- BIND_CONSTANT( SLOT_TYPE_TEXTURE );
- BIND_CONSTANT( SLOT_MAX );
-
- BIND_CONSTANT( SHADER_TYPE_VERTEX );
- BIND_CONSTANT( SHADER_TYPE_FRAGMENT );
- BIND_CONSTANT( SHADER_TYPE_LIGHT );
- BIND_CONSTANT( SHADER_TYPE_MAX );
-
-
- BIND_CONSTANT( SLOT_IN );
- BIND_CONSTANT( SLOT_OUT );
-
- BIND_CONSTANT( GRAPH_OK );
- BIND_CONSTANT( GRAPH_ERROR_CYCLIC );
- BIND_CONSTANT( GRAPH_ERROR_MISSING_CONNECTIONS );
-
- BIND_CONSTANT( SCALAR_OP_ADD );
- BIND_CONSTANT( SCALAR_OP_SUB );
- BIND_CONSTANT( SCALAR_OP_MUL );
- BIND_CONSTANT( SCALAR_OP_DIV );
- BIND_CONSTANT( SCALAR_OP_MOD );
- BIND_CONSTANT( SCALAR_OP_POW );
- BIND_CONSTANT( SCALAR_OP_MAX );
- BIND_CONSTANT( SCALAR_OP_MIN );
- BIND_CONSTANT( SCALAR_OP_ATAN2 );
- BIND_CONSTANT( SCALAR_MAX_OP );
-
- BIND_CONSTANT( VEC_OP_ADD );
- BIND_CONSTANT( VEC_OP_SUB );
- BIND_CONSTANT( VEC_OP_MUL );
- BIND_CONSTANT( VEC_OP_DIV );
- BIND_CONSTANT( VEC_OP_MOD );
- BIND_CONSTANT( VEC_OP_POW );
- BIND_CONSTANT( VEC_OP_MAX );
- BIND_CONSTANT( VEC_OP_MIN );
- BIND_CONSTANT( VEC_OP_CROSS );
- BIND_CONSTANT( VEC_MAX_OP );
-
- BIND_CONSTANT( VEC_SCALAR_OP_MUL );
- BIND_CONSTANT( VEC_SCALAR_OP_DIV );
- BIND_CONSTANT( VEC_SCALAR_OP_POW );
- BIND_CONSTANT( VEC_SCALAR_MAX_OP );
-
- BIND_CONSTANT( RGB_OP_SCREEN );
- BIND_CONSTANT( RGB_OP_DIFFERENCE );
- BIND_CONSTANT( RGB_OP_DARKEN );
- BIND_CONSTANT( RGB_OP_LIGHTEN );
- BIND_CONSTANT( RGB_OP_OVERLAY );
- BIND_CONSTANT( RGB_OP_DODGE );
- BIND_CONSTANT( RGB_OP_BURN );
- BIND_CONSTANT( RGB_OP_SOFT_LIGHT );
- BIND_CONSTANT( RGB_OP_HARD_LIGHT );
- BIND_CONSTANT( RGB_MAX_OP );
-
- BIND_CONSTANT( SCALAR_FUNC_SIN );
- BIND_CONSTANT( SCALAR_FUNC_COS );
- BIND_CONSTANT( SCALAR_FUNC_TAN );
- BIND_CONSTANT( SCALAR_FUNC_ASIN );
- BIND_CONSTANT( SCALAR_FUNC_ACOS );
- BIND_CONSTANT( SCALAR_FUNC_ATAN );
- BIND_CONSTANT( SCALAR_FUNC_SINH );
- BIND_CONSTANT( SCALAR_FUNC_COSH );
- BIND_CONSTANT( SCALAR_FUNC_TANH );
- BIND_CONSTANT( SCALAR_FUNC_LOG );
- BIND_CONSTANT( SCALAR_FUNC_EXP );
- BIND_CONSTANT( SCALAR_FUNC_SQRT );
- BIND_CONSTANT( SCALAR_FUNC_ABS );
- BIND_CONSTANT( SCALAR_FUNC_SIGN );
- BIND_CONSTANT( SCALAR_FUNC_FLOOR );
- BIND_CONSTANT( SCALAR_FUNC_ROUND );
- BIND_CONSTANT( SCALAR_FUNC_CEIL );
- BIND_CONSTANT( SCALAR_FUNC_FRAC );
- BIND_CONSTANT( SCALAR_FUNC_SATURATE );
- BIND_CONSTANT( SCALAR_FUNC_NEGATE );
- BIND_CONSTANT( SCALAR_MAX_FUNC );
-
- BIND_CONSTANT( VEC_FUNC_NORMALIZE );
- BIND_CONSTANT( VEC_FUNC_SATURATE );
- BIND_CONSTANT( VEC_FUNC_NEGATE );
- BIND_CONSTANT( VEC_FUNC_RECIPROCAL );
- BIND_CONSTANT( VEC_FUNC_RGB2HSV );
- BIND_CONSTANT( VEC_FUNC_HSV2RGB );
- BIND_CONSTANT( VEC_MAX_FUNC );
+ BIND_ENUM_CONSTANT( NODE_INPUT ); // all inputs (shader type dependent)
+ BIND_ENUM_CONSTANT( NODE_SCALAR_CONST ); //scalar constant
+ BIND_ENUM_CONSTANT( NODE_VEC_CONST ); //vec3 constant
+ BIND_ENUM_CONSTANT( NODE_RGB_CONST ); //rgb constant (shows a color picker instead)
+ BIND_ENUM_CONSTANT( NODE_XFORM_CONST ); // 4x4 matrix constant
+ BIND_ENUM_CONSTANT( NODE_TIME ); // time in seconds
+ BIND_ENUM_CONSTANT( NODE_SCREEN_TEX ); // screen texture sampler (takes UV) (only usable in fragment shader)
+ BIND_ENUM_CONSTANT( NODE_SCALAR_OP ); // scalar vs scalar op (mul ); add ); div ); etc)
+ BIND_ENUM_CONSTANT( NODE_VEC_OP ); // vec3 vs vec3 op (mul );ad );div );crossprod );etc)
+ BIND_ENUM_CONSTANT( NODE_VEC_SCALAR_OP ); // vec3 vs scalar op (mul ); add ); div ); etc)
+ BIND_ENUM_CONSTANT( NODE_RGB_OP ); // vec3 vs vec3 rgb op (with scalar amount) ); like brighten ); darken ); burn ); dodge ); multiply ); etc.
+ BIND_ENUM_CONSTANT( NODE_XFORM_MULT ); // mat4 x mat4
+ BIND_ENUM_CONSTANT( NODE_XFORM_VEC_MULT ); // mat4 x vec3 mult (with no-translation option)
+ BIND_ENUM_CONSTANT( NODE_XFORM_VEC_INV_MULT ); // mat4 x vec3 inverse mult (with no-translation option)
+ BIND_ENUM_CONSTANT( NODE_SCALAR_FUNC ); // scalar function (sin ); cos ); etc)
+ BIND_ENUM_CONSTANT( NODE_VEC_FUNC ); // vector function (normalize ); negate ); reciprocal ); rgb2hsv ); hsv2rgb ); etc ); etc)
+ BIND_ENUM_CONSTANT( NODE_VEC_LEN ); // vec3 length
+ BIND_ENUM_CONSTANT( NODE_DOT_PROD ); // vec3 . vec3 (dot product -> scalar output)
+ BIND_ENUM_CONSTANT( NODE_VEC_TO_SCALAR ); // 1 vec3 input ); 3 scalar outputs
+ BIND_ENUM_CONSTANT( NODE_SCALAR_TO_VEC ); // 3 scalar input ); 1 vec3 output
+ BIND_ENUM_CONSTANT( NODE_VEC_TO_XFORM ); // 3 vec input ); 1 xform output
+ BIND_ENUM_CONSTANT( NODE_XFORM_TO_VEC ); // 3 vec input ); 1 xform output
+ BIND_ENUM_CONSTANT( NODE_SCALAR_INTERP ); // scalar interpolation (with optional curve)
+ BIND_ENUM_CONSTANT( NODE_VEC_INTERP ); // vec3 interpolation (with optional curve)
+ BIND_ENUM_CONSTANT( NODE_COLOR_RAMP );
+ BIND_ENUM_CONSTANT( NODE_CURVE_MAP );
+ BIND_ENUM_CONSTANT( NODE_SCALAR_INPUT ); // scalar uniform (assignable in material)
+ BIND_ENUM_CONSTANT( NODE_VEC_INPUT ); // vec3 uniform (assignable in material)
+ BIND_ENUM_CONSTANT( NODE_RGB_INPUT ); // color uniform (assignable in material)
+ BIND_ENUM_CONSTANT( NODE_XFORM_INPUT ); // mat4 uniform (assignable in material)
+ BIND_ENUM_CONSTANT( NODE_TEXTURE_INPUT ); // texture input (assignable in material)
+ BIND_ENUM_CONSTANT( NODE_CUBEMAP_INPUT ); // cubemap input (assignable in material)
+ BIND_ENUM_CONSTANT( NODE_DEFAULT_TEXTURE );
+ BIND_ENUM_CONSTANT( NODE_OUTPUT ); // output (shader type dependent)
+ BIND_ENUM_CONSTANT( NODE_COMMENT ); // comment
+ BIND_ENUM_CONSTANT( NODE_TYPE_MAX );
+
+ BIND_ENUM_CONSTANT( SLOT_TYPE_SCALAR );
+ BIND_ENUM_CONSTANT( SLOT_TYPE_VEC );
+ BIND_ENUM_CONSTANT( SLOT_TYPE_XFORM );
+ BIND_ENUM_CONSTANT( SLOT_TYPE_TEXTURE );
+ BIND_ENUM_CONSTANT( SLOT_MAX );
+
+ BIND_ENUM_CONSTANT( SHADER_TYPE_VERTEX );
+ BIND_ENUM_CONSTANT( SHADER_TYPE_FRAGMENT );
+ BIND_ENUM_CONSTANT( SHADER_TYPE_LIGHT );
+ BIND_ENUM_CONSTANT( SHADER_TYPE_MAX );
+
+
+ BIND_ENUM_CONSTANT( SLOT_IN );
+ BIND_ENUM_CONSTANT( SLOT_OUT );
+
+ BIND_ENUM_CONSTANT( GRAPH_OK );
+ BIND_ENUM_CONSTANT( GRAPH_ERROR_CYCLIC );
+ BIND_ENUM_CONSTANT( GRAPH_ERROR_MISSING_CONNECTIONS );
+
+ BIND_ENUM_CONSTANT( SCALAR_OP_ADD );
+ BIND_ENUM_CONSTANT( SCALAR_OP_SUB );
+ BIND_ENUM_CONSTANT( SCALAR_OP_MUL );
+ BIND_ENUM_CONSTANT( SCALAR_OP_DIV );
+ BIND_ENUM_CONSTANT( SCALAR_OP_MOD );
+ BIND_ENUM_CONSTANT( SCALAR_OP_POW );
+ BIND_ENUM_CONSTANT( SCALAR_OP_MAX );
+ BIND_ENUM_CONSTANT( SCALAR_OP_MIN );
+ BIND_ENUM_CONSTANT( SCALAR_OP_ATAN2 );
+ BIND_ENUM_CONSTANT( SCALAR_MAX_OP );
+
+ BIND_ENUM_CONSTANT( VEC_OP_ADD );
+ BIND_ENUM_CONSTANT( VEC_OP_SUB );
+ BIND_ENUM_CONSTANT( VEC_OP_MUL );
+ BIND_ENUM_CONSTANT( VEC_OP_DIV );
+ BIND_ENUM_CONSTANT( VEC_OP_MOD );
+ BIND_ENUM_CONSTANT( VEC_OP_POW );
+ BIND_ENUM_CONSTANT( VEC_OP_MAX );
+ BIND_ENUM_CONSTANT( VEC_OP_MIN );
+ BIND_ENUM_CONSTANT( VEC_OP_CROSS );
+ BIND_ENUM_CONSTANT( VEC_MAX_OP );
+
+ BIND_ENUM_CONSTANT( VEC_SCALAR_OP_MUL );
+ BIND_ENUM_CONSTANT( VEC_SCALAR_OP_DIV );
+ BIND_ENUM_CONSTANT( VEC_SCALAR_OP_POW );
+ BIND_ENUM_CONSTANT( VEC_SCALAR_MAX_OP );
+
+ BIND_ENUM_CONSTANT( RGB_OP_SCREEN );
+ BIND_ENUM_CONSTANT( RGB_OP_DIFFERENCE );
+ BIND_ENUM_CONSTANT( RGB_OP_DARKEN );
+ BIND_ENUM_CONSTANT( RGB_OP_LIGHTEN );
+ BIND_ENUM_CONSTANT( RGB_OP_OVERLAY );
+ BIND_ENUM_CONSTANT( RGB_OP_DODGE );
+ BIND_ENUM_CONSTANT( RGB_OP_BURN );
+ BIND_ENUM_CONSTANT( RGB_OP_SOFT_LIGHT );
+ BIND_ENUM_CONSTANT( RGB_OP_HARD_LIGHT );
+ BIND_ENUM_CONSTANT( RGB_MAX_OP );
+
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_SIN );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_COS );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_TAN );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_ASIN );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_ACOS );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_ATAN );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_SINH );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_COSH );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_TANH );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_LOG );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_EXP );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_SQRT );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_ABS );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_SIGN );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_FLOOR );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_ROUND );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_CEIL );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_FRAC );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_SATURATE );
+ BIND_ENUM_CONSTANT( SCALAR_FUNC_NEGATE );
+ BIND_ENUM_CONSTANT( SCALAR_MAX_FUNC );
+
+ BIND_ENUM_CONSTANT( VEC_FUNC_NORMALIZE );
+ BIND_ENUM_CONSTANT( VEC_FUNC_SATURATE );
+ BIND_ENUM_CONSTANT( VEC_FUNC_NEGATE );
+ BIND_ENUM_CONSTANT( VEC_FUNC_RECIPROCAL );
+ BIND_ENUM_CONSTANT( VEC_FUNC_RGB2HSV );
+ BIND_ENUM_CONSTANT( VEC_FUNC_HSV2RGB );
+ BIND_ENUM_CONSTANT( VEC_MAX_FUNC );
ADD_SIGNAL(MethodInfo("updated"));
-
-#if 0
- 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(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(D_METHOD("connect"),&ShaderGraph::connect );
- ClassDB::bind_method(D_METHOD("disconnect"),&ShaderGraph::disconnect );
-
- ClassDB::bind_method(D_METHOD("get_connections"),&ShaderGraph::_get_connections_helper );
-
- ClassDB::bind_method(D_METHOD("clear"),&ShaderGraph::clear );
-
- BIND_CONSTANT( NODE_IN ); ///< param 0: name
- BIND_CONSTANT( NODE_OUT ); ///< param 0: name
- BIND_CONSTANT( NODE_CONSTANT ); ///< param 0: value
- BIND_CONSTANT( NODE_PARAMETER ); ///< param 0: name
- BIND_CONSTANT( NODE_ADD );
- BIND_CONSTANT( NODE_SUB );
- BIND_CONSTANT( NODE_MUL );
- BIND_CONSTANT( NODE_DIV );
- BIND_CONSTANT( NODE_MOD );
- BIND_CONSTANT( NODE_SIN );
- BIND_CONSTANT( NODE_COS );
- BIND_CONSTANT( NODE_TAN );
- BIND_CONSTANT( NODE_ARCSIN );
- BIND_CONSTANT( NODE_ARCCOS );
- BIND_CONSTANT( NODE_ARCTAN );
- BIND_CONSTANT( NODE_POW );
- BIND_CONSTANT( NODE_LOG );
- BIND_CONSTANT( NODE_MAX );
- BIND_CONSTANT( NODE_MIN );
- BIND_CONSTANT( NODE_COMPARE );
- BIND_CONSTANT( NODE_TEXTURE ); ///< param 0: texture
- BIND_CONSTANT( NODE_TIME ); ///< param 0: interval length
- BIND_CONSTANT( NODE_NOISE );
- BIND_CONSTANT( NODE_PASS );
- BIND_CONSTANT( NODE_VEC_IN ); ///< param 0: name
- BIND_CONSTANT( NODE_VEC_OUT ); ///< param 0: name
- BIND_CONSTANT( NODE_VEC_CONSTANT ); ///< param 0: value
- BIND_CONSTANT( NODE_VEC_PARAMETER ); ///< param 0: name
- BIND_CONSTANT( NODE_VEC_ADD );
- BIND_CONSTANT( NODE_VEC_SUB );
- BIND_CONSTANT( NODE_VEC_MUL );
- BIND_CONSTANT( NODE_VEC_DIV );
- BIND_CONSTANT( NODE_VEC_MOD );
- BIND_CONSTANT( NODE_VEC_CROSS );
- BIND_CONSTANT( NODE_VEC_DOT );
- BIND_CONSTANT( NODE_VEC_POW );
- BIND_CONSTANT( NODE_VEC_NORMALIZE );
- BIND_CONSTANT( NODE_VEC_TRANSFORM3 );
- BIND_CONSTANT( NODE_VEC_TRANSFORM4 );
- BIND_CONSTANT( NODE_VEC_COMPARE );
- BIND_CONSTANT( NODE_VEC_TEXTURE_2D );
- BIND_CONSTANT( NODE_VEC_TEXTURE_CUBE );
- BIND_CONSTANT( NODE_VEC_NOISE );
- BIND_CONSTANT( NODE_VEC_0 );
- BIND_CONSTANT( NODE_VEC_1 );
- BIND_CONSTANT( NODE_VEC_2 );
- BIND_CONSTANT( NODE_VEC_BUILD );
- BIND_CONSTANT( NODE_VEC_PASS );
- BIND_CONSTANT( NODE_COLOR_CONSTANT );
- BIND_CONSTANT( NODE_COLOR_PARAMETER );
- BIND_CONSTANT( NODE_TEXTURE_PARAMETER );
- BIND_CONSTANT( NODE_TEXTURE_2D_PARAMETER );
- BIND_CONSTANT( NODE_TEXTURE_CUBE_PARAMETER );
- BIND_CONSTANT( NODE_TYPE_MAX );
-#endif
}
diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h
index 36578ce1f7..9a74b6c53a 100644
--- a/scene/resources/shader_graph.h
+++ b/scene/resources/shader_graph.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,6 +30,7 @@
#ifndef SHADER_GRAPH_H
#define SHADER_GRAPH_H
+// FIXME: Needs to be ported to the new 3.0 shader API
#if 0
#include "map.h"
#include "scene/resources/shader.h"
diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp
index 6be88374e5..0046ff58a8 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -74,7 +74,7 @@ Ref<ArrayMesh> Shape::get_debug_mesh() {
arr.resize(Mesh::ARRAY_MAX);
arr[Mesh::ARRAY_VERTEX] = array;
- SceneTree *st = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
+ SceneTree *st = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, arr);
diff --git a/scene/resources/shape.h b/scene/resources/shape.h
index c15638aeed..bc75e723e9 100644
--- a/scene/resources/shape.h
+++ b/scene/resources/shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index 818c749e8c..4423c78bbe 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h
index a752b8dbe2..fffc7011f1 100644
--- a/scene/resources/shape_2d.h
+++ b/scene/resources/shape_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -47,10 +47,10 @@ public:
void set_custom_solver_bias(real_t p_bias);
real_t get_custom_solver_bias() const;
- bool collide_with_motion(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_p_shape_motion);
+ bool collide_with_motion(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion);
bool collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform);
- Variant collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_p_shape_motion);
+ Variant collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion);
Variant collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform);
virtual void draw(const RID &p_to_rid, const Color &p_color) {}
diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp
index c38ae04eff..4dcc5ac981 100644
--- a/scene/resources/shape_line_2d.cpp
+++ b/scene/resources/shape_line_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/shape_line_2d.h b/scene/resources/shape_line_2d.h
index 3e59bbc687..68298b63be 100644
--- a/scene/resources/shape_line_2d.h
+++ b/scene/resources/shape_line_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
index 5750960845..9af8c42110 100644
--- a/scene/resources/sky_box.cpp
+++ b/scene/resources/sky_box.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -49,14 +49,14 @@ void Sky::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "radiance_size", PROPERTY_HINT_ENUM, "32,64,128,256,512,1024,2048"), "set_radiance_size", "get_radiance_size");
- BIND_CONSTANT(RADIANCE_SIZE_32);
- BIND_CONSTANT(RADIANCE_SIZE_64);
- BIND_CONSTANT(RADIANCE_SIZE_128);
- BIND_CONSTANT(RADIANCE_SIZE_256);
- BIND_CONSTANT(RADIANCE_SIZE_512);
- BIND_CONSTANT(RADIANCE_SIZE_1024);
- BIND_CONSTANT(RADIANCE_SIZE_2048);
- BIND_CONSTANT(RADIANCE_SIZE_MAX);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_32);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_64);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_128);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_256);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_512);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_1024);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_2048);
+ BIND_ENUM_CONSTANT(RADIANCE_SIZE_MAX);
}
Sky::Sky() {
@@ -128,7 +128,7 @@ void ProceduralSky::_radiance_changed() {
VS::get_singleton()->sky_set_texture(sky, texture, size[get_radiance_size()]);
}
-void ProceduralSky::_update_sky() {
+Ref<Image> ProceduralSky::_generate_sky() {
update_queued = false;
@@ -215,9 +215,7 @@ void ProceduralSky::_update_sky() {
image.instance();
image->create(w, h, false, Image::FORMAT_RGBE9995, imgdata);
- VS::get_singleton()->texture_allocate(texture, w, h, Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
- VS::get_singleton()->texture_set_data(texture, image);
- _radiance_changed();
+ return image;
}
void ProceduralSky::set_sky_top_color(const Color &p_sky_top) {
@@ -385,6 +383,33 @@ RID ProceduralSky::get_rid() const {
return sky;
}
+void ProceduralSky::_update_sky() {
+
+ bool use_thread = true;
+ if (first_time) {
+ use_thread = false;
+ first_time = false;
+ }
+#ifdef NO_THREADS
+ use_thread = false;
+#endif
+ if (use_thread) {
+
+ if (!sky_thread) {
+ sky_thread = Thread::create(_thread_function, this);
+ regen_queued = false;
+ } else {
+ regen_queued = true;
+ }
+
+ } else {
+ Ref<Image> image = _generate_sky();
+ VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
+ VS::get_singleton()->texture_set_data(texture, image);
+ _radiance_changed();
+ }
+}
+
void ProceduralSky::_queue_update() {
if (update_queued)
@@ -394,6 +419,26 @@ void ProceduralSky::_queue_update() {
call_deferred("_update_sky");
}
+void ProceduralSky::_thread_done(const Ref<Image> &image) {
+
+ VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
+ VS::get_singleton()->texture_set_data(texture, image);
+ _radiance_changed();
+ Thread::wait_to_finish(sky_thread);
+ memdelete(sky_thread);
+ sky_thread = NULL;
+ if (regen_queued) {
+ sky_thread = Thread::create(_thread_function, this);
+ regen_queued = false;
+ }
+}
+
+void ProceduralSky::_thread_function(void *p_ud) {
+
+ ProceduralSky *psky = (ProceduralSky *)p_ud;
+ psky->call_deferred("_thread_done", psky->_generate_sky());
+}
+
void ProceduralSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_sky"), &ProceduralSky::_update_sky);
@@ -446,6 +491,8 @@ void ProceduralSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture_size", "size"), &ProceduralSky::set_texture_size);
ClassDB::bind_method(D_METHOD("get_texture_size"), &ProceduralSky::get_texture_size);
+ ClassDB::bind_method(D_METHOD("_thread_done", "image"), &ProceduralSky::_thread_done);
+
ADD_GROUP("Sky", "sky_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_top_color"), "set_sky_top_color", "get_sky_top_color");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_horizon_color"), "set_sky_horizon_color", "get_sky_horizon_color");
@@ -470,12 +517,12 @@ void ProceduralSky::_bind_methods() {
ADD_GROUP("Texture", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_texture_size", "get_texture_size");
- BIND_CONSTANT(TEXTURE_SIZE_256);
- BIND_CONSTANT(TEXTURE_SIZE_512);
- BIND_CONSTANT(TEXTURE_SIZE_1024);
- BIND_CONSTANT(TEXTURE_SIZE_2048);
- BIND_CONSTANT(TEXTURE_SIZE_4096);
- BIND_CONSTANT(TEXTURE_SIZE_MAX);
+ BIND_ENUM_CONSTANT(TEXTURE_SIZE_256);
+ BIND_ENUM_CONSTANT(TEXTURE_SIZE_512);
+ BIND_ENUM_CONSTANT(TEXTURE_SIZE_1024);
+ BIND_ENUM_CONSTANT(TEXTURE_SIZE_2048);
+ BIND_ENUM_CONSTANT(TEXTURE_SIZE_4096);
+ BIND_ENUM_CONSTANT(TEXTURE_SIZE_MAX);
}
ProceduralSky::ProceduralSky() {
@@ -503,12 +550,20 @@ ProceduralSky::ProceduralSky() {
sun_energy = 16;
texture_size = TEXTURE_SIZE_1024;
+ sky_thread = NULL;
+ regen_queued = false;
+ first_time = true;
_queue_update();
}
ProceduralSky::~ProceduralSky() {
+ if (sky_thread) {
+ Thread::wait_to_finish(sky_thread);
+ memdelete(sky_thread);
+ sky_thread = NULL;
+ }
VS::get_singleton()->free(sky);
VS::get_singleton()->free(texture);
}
diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h
index 8298d1b3c0..8934463b6f 100644
--- a/scene/resources/sky_box.h
+++ b/scene/resources/sky_box.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,8 +30,8 @@
#ifndef Sky_H
#define Sky_H
+#include "os/thread.h"
#include "scene/resources/texture.h"
-
class Sky : public Resource {
GDCLASS(Sky, Resource);
@@ -97,6 +97,7 @@ public:
};
private:
+ Thread *sky_thread;
Color sky_top_color;
Color sky_horizon_color;
float sky_curve;
@@ -121,12 +122,20 @@ private:
RID texture;
bool update_queued;
+ bool regen_queued;
+
+ bool first_time;
+
+ void _thread_done(const Ref<Image> &p_image);
+ static void _thread_function(void *p_ud);
protected:
static void _bind_methods();
virtual void _radiance_changed();
+ Ref<Image> _generate_sky();
void _update_sky();
+
void _queue_update();
public:
diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp
index 2a618bb868..4177364de7 100644
--- a/scene/resources/space_2d.cpp
+++ b/scene/resources/space_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h
index 3e08612d99..8ba392f85d 100644
--- a/scene/resources/space_2d.h
+++ b/scene/resources/space_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp
index 960554562f..00203c2b4b 100644
--- a/scene/resources/sphere_shape.cpp
+++ b/scene/resources/sphere_shape.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/sphere_shape.h b/scene/resources/sphere_shape.h
index a3b5d2424b..43d7956246 100644
--- a/scene/resources/sphere_shape.h
+++ b/scene/resources/sphere_shape.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index bdb17c0ea5..f646e3667d 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "style_box.h"
+#include <limits.h>
bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
@@ -161,7 +162,7 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
if (normal_map.is_valid())
normal_rid = normal_map->get_rid();
- VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_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, modulate, normal_rid);
+ VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NinePatchAxisMode(axis_h), VS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid);
}
void StyleBoxTexture::set_draw_center(bool p_draw) {
@@ -190,6 +191,22 @@ void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_siz
emit_changed();
}
+void StyleBoxTexture::set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom) {
+ expand_margin[MARGIN_LEFT] = p_left;
+ expand_margin[MARGIN_TOP] = p_top;
+ expand_margin[MARGIN_RIGHT] = p_right;
+ expand_margin[MARGIN_BOTTOM] = p_bottom;
+ emit_changed();
+}
+
+void StyleBoxTexture::set_expand_margin_size_all(float p_expand_margin_size) {
+ for (int i = 0; i < 4; i++) {
+
+ expand_margin[i] = p_expand_margin_size;
+ }
+ emit_changed();
+}
+
float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const {
ERR_FAIL_INDEX_V(p_expand_margin, 4, 0);
@@ -210,6 +227,28 @@ Rect2 StyleBoxTexture::get_region_rect() const {
return region_rect;
}
+void StyleBoxTexture::set_h_axis_stretch_mode(AxisStretchMode p_mode) {
+
+ axis_h = p_mode;
+ emit_changed();
+}
+
+StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_h_axis_stretch_mode() const {
+
+ return axis_h;
+}
+
+void StyleBoxTexture::set_v_axis_stretch_mode(AxisStretchMode p_mode) {
+
+ axis_v = p_mode;
+ emit_changed();
+}
+
+StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_v_axis_stretch_mode() const {
+
+ return axis_v;
+}
+
void StyleBoxTexture::set_modulate(const Color &p_modulate) {
if (modulate == p_modulate)
return;
@@ -234,6 +273,8 @@ void StyleBoxTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_margin_size", "margin"), &StyleBoxTexture::get_margin_size);
ClassDB::bind_method(D_METHOD("set_expand_margin_size", "margin", "size"), &StyleBoxTexture::set_expand_margin_size);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_all", "size"), &StyleBoxTexture::set_expand_margin_size_all);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_individual", "size_left", "size_top", "size_right", "size_bottom"), &StyleBoxTexture::set_expand_margin_size_individual);
ClassDB::bind_method(D_METHOD("get_expand_margin_size", "margin"), &StyleBoxTexture::get_expand_margin_size);
ClassDB::bind_method(D_METHOD("set_region_rect", "region"), &StyleBoxTexture::set_region_rect);
@@ -245,6 +286,12 @@ void StyleBoxTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_modulate", "color"), &StyleBoxTexture::set_modulate);
ClassDB::bind_method(D_METHOD("get_modulate"), &StyleBoxTexture::get_modulate);
+ ClassDB::bind_method(D_METHOD("set_h_axis_stretch_mode", "mode"), &StyleBoxTexture::set_h_axis_stretch_mode);
+ ClassDB::bind_method(D_METHOD("get_h_axis_stretch_mode"), &StyleBoxTexture::get_h_axis_stretch_mode);
+
+ ClassDB::bind_method(D_METHOD("set_v_axis_stretch_mode", "mode"), &StyleBoxTexture::set_v_axis_stretch_mode);
+ ClassDB::bind_method(D_METHOD("get_v_axis_stretch_mode"), &StyleBoxTexture::get_v_axis_stretch_mode);
+
ADD_SIGNAL(MethodInfo("texture_changed"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
@@ -260,9 +307,16 @@ void StyleBoxTexture::_bind_methods() {
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("Axis Stretch", "axis_stretch_");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "axis_stretch_horizontal", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_h_axis_stretch_mode", "get_h_axis_stretch_mode");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "axis_stretch_vertical", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_v_axis_stretch_mode", "get_v_axis_stretch_mode");
ADD_GROUP("Modulate", "modulate_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate_color"), "set_modulate", "get_modulate");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "get_draw_center");
+
+ BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_STRETCH);
+ BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE);
+ BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT);
}
StyleBoxTexture::StyleBoxTexture() {
@@ -273,6 +327,9 @@ StyleBoxTexture::StyleBoxTexture() {
}
draw_center = true;
modulate = Color(1, 1, 1, 1);
+
+ axis_h = AXIS_STRETCH_MODE_STRETCH;
+ axis_v = AXIS_STRETCH_MODE_STRETCH;
}
StyleBoxTexture::~StyleBoxTexture() {
}
@@ -285,156 +342,528 @@ void StyleBoxFlat::set_bg_color(const Color &p_color) {
emit_changed();
}
-void StyleBoxFlat::set_light_color(const Color &p_color) {
+Color StyleBoxFlat::get_bg_color() const {
+
+ return bg_color;
+}
+
+void StyleBoxFlat::set_border_color_all(const Color &p_color) {
+ for (int i = 0; i < 4; i++) {
- light_color = p_color;
+ border_color.write()[i] = p_color;
+ }
emit_changed();
}
-void StyleBoxFlat::set_dark_color(const Color &p_color) {
+Color StyleBoxFlat::get_border_color_all() const {
+
+ return border_color[MARGIN_TOP];
+}
+void StyleBoxFlat::set_border_color(Margin p_border, const Color &p_color) {
- dark_color = p_color;
+ border_color.write()[p_border] = p_color;
emit_changed();
}
+Color StyleBoxFlat::get_border_color(Margin p_border) const {
-Color StyleBoxFlat::get_bg_color() const {
+ return border_color[p_border];
+}
- return bg_color;
+void StyleBoxFlat::set_border_width_all(int p_size) {
+ border_width[0] = p_size;
+ border_width[1] = p_size;
+ border_width[2] = p_size;
+ border_width[3] = p_size;
+ emit_changed();
}
-Color StyleBoxFlat::get_light_color() const {
+int StyleBoxFlat::get_border_width_min() const {
- return light_color;
+ return MIN(MIN(border_width[0], border_width[1]), MIN(border_width[2], border_width[3]));
}
-Color StyleBoxFlat::get_dark_color() const {
- return dark_color;
+void StyleBoxFlat::set_border_width(Margin p_margin, int p_width) {
+ border_width[p_margin] = p_width;
+ emit_changed();
}
-void StyleBoxFlat::set_border_size(int p_size) {
+int StyleBoxFlat::get_border_width(Margin p_margin) const {
+ return border_width[p_margin];
+}
- border_size = p_size;
+void StyleBoxFlat::set_border_blend(bool p_blend) {
+
+ blend_border = p_blend;
emit_changed();
}
-int StyleBoxFlat::get_border_size() const {
+bool StyleBoxFlat::get_border_blend() const {
- return border_size;
+ return blend_border;
}
-void StyleBoxFlat::_set_additional_border_size(Margin p_margin, int p_size) {
- additional_border_size[p_margin] = p_size;
+void StyleBoxFlat::set_corner_radius_all(int radius) {
+
+ for (int i = 0; i < 4; i++) {
+ corner_radius[i] = radius;
+ }
+
emit_changed();
}
+void StyleBoxFlat::set_corner_radius_individual(const int radius_top_left, const int radius_top_right, const int radius_botton_right, const int radius_bottom_left) {
+ corner_radius[0] = radius_top_left;
+ corner_radius[1] = radius_top_right;
+ corner_radius[2] = radius_botton_right;
+ corner_radius[3] = radius_bottom_left;
-int StyleBoxFlat::_get_additional_border_size(Margin p_margin) const {
- return additional_border_size[p_margin];
+ emit_changed();
+}
+int StyleBoxFlat::get_corner_radius_min() const {
+ int smallest = corner_radius[0];
+ for (int i = 1; i < 4; i++) {
+ if (smallest > corner_radius[i]) {
+ smallest = corner_radius[i];
+ }
+ }
+ return smallest;
}
-void StyleBoxFlat::set_border_blend(bool p_blend) {
+void StyleBoxFlat::set_corner_radius(const Corner p_corner, const int radius) {
- blend = p_blend;
+ corner_radius[p_corner] = radius;
emit_changed();
}
+int StyleBoxFlat::get_corner_radius(const Corner p_corner) const {
+ return corner_radius[p_corner];
+}
-bool StyleBoxFlat::get_border_blend() const {
+void StyleBoxFlat::set_expand_margin_size(Margin p_expand_margin, float p_size) {
- return blend;
+ expand_margin[p_expand_margin] = p_size;
+ emit_changed();
}
-void StyleBoxFlat::set_draw_center(bool p_draw) {
+void StyleBoxFlat::set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom) {
+ expand_margin[MARGIN_LEFT] = p_left;
+ expand_margin[MARGIN_TOP] = p_top;
+ expand_margin[MARGIN_RIGHT] = p_right;
+ expand_margin[MARGIN_BOTTOM] = p_bottom;
+ emit_changed();
+}
- draw_center = p_draw;
+void StyleBoxFlat::set_expand_margin_size_all(float p_expand_margin_size) {
+ for (int i = 0; i < 4; i++) {
+
+ expand_margin[i] = p_expand_margin_size;
+ }
emit_changed();
}
-bool StyleBoxFlat::get_draw_center() const {
- return draw_center;
+float StyleBoxFlat::get_expand_margin_size(Margin p_expand_margin) const {
+
+ return expand_margin[p_expand_margin];
+}
+void StyleBoxFlat::set_filled(bool p_filled) {
+
+ filled = p_filled;
+ emit_changed();
+}
+bool StyleBoxFlat::is_filled() const {
+
+ return filled;
+}
+
+void StyleBoxFlat::set_shadow_color(const Color &p_color) {
+
+ shadow_color = p_color;
+ emit_changed();
+}
+Color StyleBoxFlat::get_shadow_color() const {
+
+ return shadow_color;
+}
+
+void StyleBoxFlat::set_shadow_size(const int &p_size) {
+
+ shadow_size = p_size;
+ emit_changed();
+}
+int StyleBoxFlat::get_shadow_size() const {
+
+ return shadow_size;
+}
+
+void StyleBoxFlat::set_anti_aliased(const bool &p_anti_aliased) {
+ anti_aliased = p_anti_aliased;
+ emit_changed();
+}
+bool StyleBoxFlat::is_anti_aliased() const {
+ return anti_aliased;
+}
+
+void StyleBoxFlat::set_aa_size(const int &p_aa_size) {
+ aa_size = CLAMP(p_aa_size, 1, 5);
+ emit_changed();
+}
+int StyleBoxFlat::get_aa_size() const {
+ return aa_size;
+}
+
+void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) {
+ corner_detail = CLAMP(p_corner_detail, 1, 128);
+ emit_changed();
+}
+int StyleBoxFlat::get_corner_detail() const {
+ return corner_detail;
}
+
Size2 StyleBoxFlat::get_center_size() const {
return Size2();
}
-void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
+inline void set_inner_corner_radius(const Rect2 style_rect, const Rect2 inner_rect, const int corner_radius[4], int *inner_corner_radius) {
+ int border_left = inner_rect.position.x - style_rect.position.x;
+ int border_top = inner_rect.position.y - style_rect.position.y;
+ int border_right = style_rect.size.width - inner_rect.size.width - border_left;
+ int border_bottom = style_rect.size.height - inner_rect.size.height - border_top;
- VisualServer *vs = VisualServer::get_singleton();
- Rect2i r = p_rect;
+ int rad;
+ //tl
+ rad = MIN(border_top, border_left);
+ inner_corner_radius[0] = MAX(corner_radius[0] - rad, 0);
+
+ //tr
+ rad = MIN(border_top, border_bottom);
+ inner_corner_radius[1] = MAX(corner_radius[1] - rad, 0);
+
+ //br
+ rad = MIN(border_bottom, border_right);
+ inner_corner_radius[2] = MAX(corner_radius[2] - rad, 0);
+
+ //bl
+ rad = MIN(border_bottom, border_left);
+ inner_corner_radius[3] = MAX(corner_radius[3] - rad, 0);
+}
- for (int i = 0; i < border_size; i++) {
+inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color> &colors, const Rect2 style_rect, const int corner_radius[4],
+ const Rect2 ring_rect, const int border_width[4], const Color inner_color[4], const Color outer_color[4], const int corner_detail) {
- Color color_upleft = light_color;
- Color color_downright = dark_color;
+ int vert_offset = verts.size();
+ if (!vert_offset) {
+ vert_offset = 0;
+ }
+ int adapted_corner_detail = (corner_radius[0] == 0 && corner_radius[1] == 0 && corner_radius[2] == 0 && corner_radius[3] == 0) ? 1 : corner_detail;
+ int rings = (border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0) ? 1 : 2;
+ rings = 2;
+
+ int ring_corner_radius[4];
+ set_inner_corner_radius(style_rect, ring_rect, corner_radius, ring_corner_radius);
+
+ //corner radius center points
+ Vector<Point2> outer_points;
+ outer_points.push_back(ring_rect.position + Vector2(ring_corner_radius[0], ring_corner_radius[0])); //tl
+ outer_points.push_back(Point2(ring_rect.position.x + ring_rect.size.x - ring_corner_radius[1], ring_rect.position.y + ring_corner_radius[1])); //tr
+ outer_points.push_back(ring_rect.position + ring_rect.size - Vector2(ring_corner_radius[2], ring_corner_radius[2])); //br
+ outer_points.push_back(Point2(ring_rect.position.x + ring_corner_radius[3], ring_rect.position.y + ring_rect.size.y - ring_corner_radius[3])); //bl
+
+ Rect2 inner_rect;
+ inner_rect = ring_rect.grow_individual(-border_width[MARGIN_LEFT], -border_width[MARGIN_TOP], -border_width[MARGIN_RIGHT], -border_width[MARGIN_BOTTOM]);
+ int inner_corner_radius[4];
+
+ Vector<Point2> inner_points;
+ set_inner_corner_radius(style_rect, inner_rect, corner_radius, inner_corner_radius);
+ inner_points.push_back(inner_rect.position + Vector2(inner_corner_radius[0], inner_corner_radius[0])); //tl
+ inner_points.push_back(Point2(inner_rect.position.x + inner_rect.size.x - inner_corner_radius[1], inner_rect.position.y + inner_corner_radius[1])); //tr
+ inner_points.push_back(inner_rect.position + inner_rect.size - Vector2(inner_corner_radius[2], inner_corner_radius[2])); //br
+ inner_points.push_back(Point2(inner_rect.position.x + inner_corner_radius[3], inner_rect.position.y + inner_rect.size.y - inner_corner_radius[3])); //bl
+
+ //calculate the vert array
+ for (int corner_index = 0; corner_index < 4; corner_index++) {
+ for (int detail = 0; detail <= adapted_corner_detail; detail++) {
+ for (int inner_outer = (2 - rings); inner_outer < 2; inner_outer++) {
+ float radius;
+ Color color;
+ Point2 corner_point;
+ if (inner_outer == 0) {
+ radius = inner_corner_radius[corner_index];
+ color = *inner_color;
+ corner_point = inner_points[corner_index];
+ } else {
+ radius = ring_corner_radius[corner_index];
+ color = *outer_color;
+ corner_point = outer_points[corner_index];
+ }
+ float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x;
+ float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y;
+ verts.push_back(Vector2(x, y));
+ colors.push_back(color);
+ }
+ }
+ }
+
+ if (rings == 2) {
+ int vert_count = (adapted_corner_detail + 1) * 4 * rings;
+ //fill the indices and the colors for the border
+ for (int i = 0; i < vert_count; i++) {
+ //poly 1
+ indices.push_back(vert_offset + ((i + 0) % vert_count));
+ indices.push_back(vert_offset + ((i + 2) % vert_count));
+ indices.push_back(vert_offset + ((i + 1) % vert_count));
+ //poly 2
+ indices.push_back(vert_offset + ((i + 1) % vert_count));
+ indices.push_back(vert_offset + ((i + 2) % vert_count));
+ indices.push_back(vert_offset + ((i + 3) % vert_count));
+ }
+ }
+}
- if (blend) {
+inline void adapt_values(int p_index_a, int p_index_b, int *adapted_values, const int *p_values, const real_t p_width, const int p_max_a, const int p_max_b) {
+ if (p_values[p_index_a] + p_values[p_index_b] > p_width) {
+ float factor;
+ int newValue;
- color_upleft.r = (border_size - i) * color_upleft.r / border_size + i * bg_color.r / border_size;
- color_upleft.g = (border_size - i) * color_upleft.g / border_size + i * bg_color.g / border_size;
- color_upleft.b = (border_size - i) * color_upleft.b / border_size + i * bg_color.b / border_size;
+ factor = (float)p_width / (float)(p_values[p_index_a] + p_values[p_index_b]);
- color_downright.r = (border_size - i) * color_downright.r / border_size + i * bg_color.r / border_size;
- color_downright.g = (border_size - i) * color_downright.g / border_size + i * bg_color.g / border_size;
- color_downright.b = (border_size - i) * color_downright.b / border_size + i * bg_color.b / border_size;
+ newValue = (int)(p_values[p_index_a] * factor);
+ if (newValue < adapted_values[p_index_a]) {
+ adapted_values[p_index_a] = newValue;
+ }
+ newValue = (int)(p_values[p_index_b] * factor);
+ if (newValue < adapted_values[p_index_b]) {
+ adapted_values[p_index_b] = newValue;
}
+ } else {
+ adapted_values[p_index_a] = MIN(p_values[p_index_a], adapted_values[p_index_a]);
+ adapted_values[p_index_b] = MIN(p_values[p_index_b], adapted_values[p_index_b]);
+ }
+ adapted_values[p_index_a] = MIN(p_max_a, adapted_values[p_index_a]);
+ adapted_values[p_index_b] = MIN(p_max_b, adapted_values[p_index_b]);
+}
+void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.position.x, r.position.y + r.size.y - 1), Size2(r.size.x, 1)), color_downright);
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.position.x + r.size.x - 1, r.position.y), Size2(1, r.size.y)), color_downright);
+ //PREPARATIONS
- vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, Size2(r.size.x, 1)), color_upleft);
- vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, Size2(1, r.size.y)), color_upleft);
+ bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0);
+ bool aa_on = rounded_corners && anti_aliased;
- r.position.x++;
- r.position.y++;
- r.size.x -= 2;
- r.size.y -= 2;
+ Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
+ if (aa_on) {
+ style_rect = style_rect.grow(-((aa_size + 1) / 2));
}
- if (draw_center)
- vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, r.size), bg_color);
+ //adapt borders (prevent weired overlapping/glitchy drawings)
+ int width = style_rect.size.width;
+ int height = style_rect.size.height;
+ int adapted_border[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
+ adapt_values(MARGIN_TOP, MARGIN_BOTTOM, adapted_border, border_width, height, height, height);
+ adapt_values(MARGIN_LEFT, MARGIN_RIGHT, adapted_border, border_width, width, width, width);
+
+ //adapt corners (prevent weired overlapping/glitchy drawings)
+ int adapted_corner[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX };
+ adapt_values(CORNER_TOP_RIGHT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, height, height - adapted_border[MARGIN_BOTTOM], height - adapted_border[MARGIN_TOP]);
+ adapt_values(CORNER_TOP_LEFT, CORNER_BOTTOM_LEFT, adapted_corner, corner_radius, height, height - adapted_border[MARGIN_BOTTOM], height - adapted_border[MARGIN_TOP]);
+ adapt_values(CORNER_TOP_LEFT, CORNER_TOP_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[MARGIN_RIGHT], width - adapted_border[MARGIN_LEFT]);
+ adapt_values(CORNER_BOTTOM_LEFT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[MARGIN_RIGHT], width - adapted_border[MARGIN_LEFT]);
+
+ Rect2 infill_rect = style_rect.grow_individual(-adapted_border[MARGIN_LEFT], -adapted_border[MARGIN_TOP], -adapted_border[MARGIN_RIGHT], -adapted_border[MARGIN_BOTTOM]);
+
+ Vector<Point2> verts;
+ Vector<int> indices;
+ Vector<Color> colors;
- Rect2i r_add = p_rect;
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y - additional_border_size[MARGIN_TOP]), Size2(r_add.size.width + additional_border_size[MARGIN_LEFT] + additional_border_size[MARGIN_RIGHT], additional_border_size[MARGIN_TOP])), light_color);
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y), Size2(additional_border_size[MARGIN_LEFT], r_add.size.height)), light_color);
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x + r_add.size.width, r_add.position.y), Size2(additional_border_size[MARGIN_RIGHT], r_add.size.height)), dark_color);
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y + r_add.size.height), Size2(r_add.size.width + additional_border_size[MARGIN_LEFT] + additional_border_size[MARGIN_RIGHT], additional_border_size[MARGIN_BOTTOM])), dark_color);
+ //DRAWING
+ VisualServer *vs = VisualServer::get_singleton();
+
+ //DRAW SHADOW
+ if (shadow_size > 0) {
+ int shadow_width[4] = { shadow_size, shadow_size, shadow_size, shadow_size };
+ Color shadow_colors[4] = { shadow_color, shadow_color, shadow_color, shadow_color };
+ Color shadow_colors_transparent[4];
+ for (int i = 0; i < 4; i++) {
+ shadow_colors_transparent[i] = Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
+ }
+ draw_ring(verts, indices, colors, style_rect, adapted_corner,
+ style_rect.grow(shadow_size), shadow_width, shadow_colors, shadow_colors_transparent, corner_detail);
+ }
+
+ //DRAW border
+ Color bg_color_array[4] = { bg_color, bg_color, bg_color, bg_color };
+ const Color *inner_color = ((blend_border) ? bg_color_array : border_color.read().ptr());
+ draw_ring(verts, indices, colors, style_rect, adapted_corner,
+ style_rect, adapted_border, inner_color, border_color.read().ptr(), corner_detail);
+
+ //DRAW INFILL
+ if (filled) {
+ int temp_vert_offset = verts.size();
+ int no_border[4] = { 0, 0, 0, 0 };
+ draw_ring(verts, indices, colors, style_rect, adapted_corner,
+ infill_rect, no_border, &bg_color, &bg_color, corner_detail);
+ int added_vert_count = verts.size() - temp_vert_offset;
+ //fill the indices and the colors for the center
+ for (int index = 0; index <= added_vert_count / 2; index += 2) {
+ int i = index;
+ //poly 1
+ indices.push_back(temp_vert_offset + i);
+ indices.push_back(temp_vert_offset + added_vert_count - 4 - i);
+ indices.push_back(temp_vert_offset + i + 2);
+ //poly 1
+ indices.push_back(temp_vert_offset + i);
+ indices.push_back(temp_vert_offset + added_vert_count - 2 - i);
+ indices.push_back(temp_vert_offset + added_vert_count - 4 - i);
+ }
+ }
+
+ if (aa_on) {
+
+ //HELPER ARRAYS
+ Color border_color_alpha[4];
+ for (int i = 0; i < 4; i++) {
+ Color c = border_color.read().ptr()[i];
+ border_color_alpha[i] = Color(c.r, c.g, c.b, 0);
+ }
+ Color alpha_bg = Color(bg_color.r, bg_color.g, bg_color.b, 0);
+ Color bg_color_array_alpha[4] = { alpha_bg, alpha_bg, alpha_bg, alpha_bg };
+
+ int aa_border_width[4] = { aa_size, aa_size, aa_size, aa_size };
+
+ if (filled) {
+ if (!blend_border) {
+ //INFILL AA
+ draw_ring(verts, indices, colors, style_rect, adapted_corner,
+ infill_rect.grow(aa_size), aa_border_width, bg_color_array, bg_color_array_alpha, corner_detail);
+ }
+ } else if (!(border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0)) {
+ //DRAW INNER BORDER AA
+ draw_ring(verts, indices, colors, style_rect, adapted_corner,
+ infill_rect, aa_border_width, border_color_alpha, border_color.read().ptr(), corner_detail);
+ }
+ //DRAW OUTER BORDER AA
+ if (!(border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0)) {
+ draw_ring(verts, indices, colors, style_rect, adapted_corner,
+ style_rect.grow(aa_size), aa_border_width, border_color.read().ptr(), border_color_alpha, corner_detail);
+ }
+ }
+
+ vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors);
}
float StyleBoxFlat::get_style_margin(Margin p_margin) const {
-
- return border_size;
+ return border_width[p_margin];
}
void StyleBoxFlat::_bind_methods() {
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_color", "color"), &StyleBoxFlat::set_border_color_all);
+ ClassDB::bind_method(D_METHOD("get_border_color"), &StyleBoxFlat::get_border_color_all);
+
+ ClassDB::bind_method(D_METHOD("set_border_width_all", "width"), &StyleBoxFlat::set_border_width_all);
+ ClassDB::bind_method(D_METHOD("get_border_width_min"), &StyleBoxFlat::get_border_width_min);
+
+ ClassDB::bind_method(D_METHOD("set_border_width", "margin", "width"), &StyleBoxFlat::set_border_width);
+ ClassDB::bind_method(D_METHOD("get_border_width", "margin"), &StyleBoxFlat::get_border_width);
+
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);
+
+ ClassDB::bind_method(D_METHOD("set_corner_radius_individual", "radius_top_left", "radius_top_right", "radius_botton_right", "radius_bottom_left"), &StyleBoxFlat::set_corner_radius_individual);
+ ClassDB::bind_method(D_METHOD("set_corner_radius_all", "radius"), &StyleBoxFlat::set_corner_radius_all);
+
+ ClassDB::bind_method(D_METHOD("set_corner_radius", "corner", "radius"), &StyleBoxFlat::set_corner_radius);
+ ClassDB::bind_method(D_METHOD("get_corner_radius", "corner"), &StyleBoxFlat::get_corner_radius);
+
+ ClassDB::bind_method(D_METHOD("set_expand_margin", "margin", "size"), &StyleBoxFlat::set_expand_margin_size);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_all", "size"), &StyleBoxFlat::set_expand_margin_size_all);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_individual", "size_left", "size_top", "size_right", "size_bottom"), &StyleBoxFlat::set_expand_margin_size_individual);
+ ClassDB::bind_method(D_METHOD("get_expand_margin", "margin"), &StyleBoxFlat::get_expand_margin_size);
+
+ ClassDB::bind_method(D_METHOD("set_filled", "filled"), &StyleBoxFlat::set_filled);
+ ClassDB::bind_method(D_METHOD("is_filled"), &StyleBoxFlat::is_filled);
+
+ ClassDB::bind_method(D_METHOD("set_shadow_color", "color"), &StyleBoxFlat::set_shadow_color);
+ ClassDB::bind_method(D_METHOD("get_shadow_color"), &StyleBoxFlat::get_shadow_color);
+
+ ClassDB::bind_method(D_METHOD("set_shadow_size", "size"), &StyleBoxFlat::set_shadow_size);
+ ClassDB::bind_method(D_METHOD("get_shadow_size"), &StyleBoxFlat::get_shadow_size);
+
+ ClassDB::bind_method(D_METHOD("set_anti_aliased", "anti_aliased"), &StyleBoxFlat::set_anti_aliased);
+ ClassDB::bind_method(D_METHOD("is_anti_aliased"), &StyleBoxFlat::is_anti_aliased);
+
+ ClassDB::bind_method(D_METHOD("set_aa_size", "size"), &StyleBoxFlat::set_aa_size);
+ ClassDB::bind_method(D_METHOD("get_aa_size"), &StyleBoxFlat::get_aa_size);
+
+ ClassDB::bind_method(D_METHOD("set_corner_detail", "detail"), &StyleBoxFlat::set_corner_detail);
+ ClassDB::bind_method(D_METHOD("get_corner_detail"), &StyleBoxFlat::get_corner_detail);
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, "filled"), "set_filled", "is_filled");
+
+ ADD_GROUP("Border Width", "border_width_");
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_top", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_bottom", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_BOTTOM);
+
+ ADD_GROUP("Border", "border_");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "border_color"), "set_border_color", "get_border_color");
+
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");
+
+ ADD_GROUP("Corner Radius", "corner_radius_");
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_top_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_TOP_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_top_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_TOP_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_LEFT);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,128,1"), "set_corner_detail", "get_corner_detail");
+
+ ADD_GROUP("Expand Margin", "expand_margin_");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_BOTTOM);
+
+ ADD_GROUP("Shadow", "shadow_");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color"), "set_shadow_color", "get_shadow_color");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_size"), "set_shadow_size", "get_shadow_size");
+
+ ADD_GROUP("Anti Aliasing", "anti_aliasing_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "anti_aliasing"), "set_anti_aliased", "is_anti_aliased");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "anti_aliasing_size", PROPERTY_HINT_RANGE, "1,5,1"), "set_aa_size", "get_aa_size");
}
StyleBoxFlat::StyleBoxFlat() {
bg_color = Color(0.6, 0.6, 0.6);
- light_color = Color(0.8, 0.8, 0.8);
- dark_color = Color(0.8, 0.8, 0.8);
- draw_center = true;
- blend = true;
- border_size = 0;
- additional_border_size[0] = 0;
- additional_border_size[1] = 0;
- additional_border_size[2] = 0;
- additional_border_size[3] = 0;
+ shadow_color = Color(0, 0, 0, 0.6);
+
+ border_color.append(Color(0.8, 0.8, 0.8));
+ border_color.append(Color(0.8, 0.8, 0.8));
+ border_color.append(Color(0.8, 0.8, 0.8));
+ border_color.append(Color(0.8, 0.8, 0.8));
+
+ blend_border = false;
+ filled = true;
+ anti_aliased = true;
+
+ shadow_size = 0;
+ corner_detail = 8;
+ aa_size = 1;
+
+ border_width[0] = 0;
+ border_width[1] = 0;
+ border_width[2] = 0;
+ border_width[3] = 0;
+
+ expand_margin[0] = 0;
+ expand_margin[1] = 0;
+ expand_margin[2] = 0;
+ expand_margin[3] = 0;
+
+ corner_radius[0] = 0;
+ corner_radius[1] = 0;
+ corner_radius[2] = 0;
+ corner_radius[3] = 0;
}
StyleBoxFlat::~StyleBoxFlat() {
}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 64ce3528aa..db41333b7e 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -77,6 +77,14 @@ class StyleBoxTexture : public StyleBox {
GDCLASS(StyleBoxTexture, StyleBox);
+public:
+ enum AxisStretchMode {
+ AXIS_STRETCH_MODE_STRETCH,
+ AXIS_STRETCH_MODE_TILE,
+ AXIS_STRETCH_MODE_TILE_FIT,
+ };
+
+private:
float expand_margin[4];
float margin[4];
Rect2 region_rect;
@@ -84,6 +92,8 @@ class StyleBoxTexture : public StyleBox {
Ref<Texture> normal_map;
bool draw_center;
Color modulate;
+ AxisStretchMode axis_h;
+ AxisStretchMode axis_v;
protected:
virtual float get_style_margin(Margin p_margin) const;
@@ -91,6 +101,8 @@ protected:
public:
void set_expand_margin_size(Margin p_expand_margin, float p_size);
+ void set_expand_margin_size_all(float p_expand_margin_size);
+ void set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom);
float get_expand_margin_size(Margin p_expand_margin) const;
void set_margin_size(Margin p_margin, float p_size);
@@ -109,6 +121,12 @@ public:
bool get_draw_center() const;
virtual Size2 get_center_size() const;
+ void set_h_axis_stretch_mode(AxisStretchMode p_mode);
+ AxisStretchMode get_h_axis_stretch_mode() const;
+
+ void set_v_axis_stretch_mode(AxisStretchMode p_mode);
+ AxisStretchMode get_v_axis_stretch_mode() const;
+
void set_modulate(const Color &p_modulate);
Color get_modulate() const;
@@ -118,44 +136,90 @@ public:
~StyleBoxTexture();
};
+VARIANT_ENUM_CAST(StyleBoxTexture::AxisStretchMode)
+
class StyleBoxFlat : public StyleBox {
GDCLASS(StyleBoxFlat, StyleBox);
Color bg_color;
- Color light_color;
- Color dark_color;
+ Color shadow_color;
+ PoolVector<Color> border_color;
- int border_size;
- int additional_border_size[4];
+ int border_width[4];
+ int expand_margin[4];
+ int corner_radius[4];
- bool draw_center;
- bool blend;
+ bool filled;
+ bool blend_border;
+ bool anti_aliased;
+
+ int corner_detail;
+ int shadow_size;
+ int aa_size;
protected:
virtual float get_style_margin(Margin p_margin) const;
static void _bind_methods();
public:
+ //Color
void set_bg_color(const Color &p_color);
- void set_light_color(const Color &p_color);
- void set_dark_color(const Color &p_color);
-
Color get_bg_color() const;
- Color get_light_color() const;
- Color get_dark_color() const;
- void set_border_size(int p_size);
- int get_border_size() const;
+ //Border Color
+ void set_border_color_all(const Color &p_color);
+ Color get_border_color_all() const;
+ void set_border_color(Margin p_border, const Color &p_color);
+ Color get_border_color(Margin p_border) const;
+
+ //BORDER
+ //width
+ void set_border_width_all(int p_size);
+ int get_border_width_min() const;
- void _set_additional_border_size(Margin p_margin, int p_size);
- int _get_additional_border_size(Margin p_margin) const;
+ void set_border_width(Margin p_margin, int p_size);
+ int get_border_width(Margin p_margin) const;
+ //blend
void set_border_blend(bool p_blend);
bool get_border_blend() const;
- void set_draw_center(bool p_draw);
- bool get_draw_center() const;
+ //CORNER
+ void set_corner_radius_all(int radius);
+ void set_corner_radius_individual(const int radius_top_left, const int radius_top_right, const int radius_botton_right, const int radius_bottom_left);
+ int get_corner_radius_min() const;
+
+ void set_corner_radius(Corner p_corner, const int radius);
+ int get_corner_radius(Corner p_corner) const;
+
+ void set_corner_detail(const int &p_corner_detail);
+ int get_corner_detail() const;
+
+ //EXPANDS
+ void set_expand_margin_size(Margin p_expand_margin, float p_size);
+ void set_expand_margin_size_all(float p_expand_margin_size);
+ void set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom);
+ float get_expand_margin_size(Margin p_expand_margin) const;
+
+ //FILLED
+ void set_filled(bool p_draw);
+ bool is_filled() const;
+
+ //SHADOW
+ void set_shadow_color(const Color &p_color);
+ Color get_shadow_color() const;
+
+ void set_shadow_size(const int &p_size);
+ int get_shadow_size() const;
+
+ //ANTI_ALIASING
+ void set_anti_aliased(const bool &p_anit_aliasing);
+ bool is_anti_aliased() const;
+ //tempAA
+ void set_aa_size(const int &p_aa_size);
+ int get_aa_size() const;
+
virtual Size2 get_center_size() const;
virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index a3c683f857..bf89e704bc 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -33,36 +33,36 @@
#define _VERTEX_SNAP 0.0001
#define EQ_VERTEX_DIST 0.00001
-bool SurfaceTool::Vertex::operator==(const Vertex &p_b) const {
+bool SurfaceTool::Vertex::operator==(const Vertex &p_vertex) const {
- if (vertex != p_b.vertex)
+ if (vertex != p_vertex.vertex)
return false;
- if (uv != p_b.uv)
+ if (uv != p_vertex.uv)
return false;
- if (uv2 != p_b.uv2)
+ if (uv2 != p_vertex.uv2)
return false;
- if (normal != p_b.normal)
+ if (normal != p_vertex.normal)
return false;
- if (binormal != p_b.binormal)
+ if (binormal != p_vertex.binormal)
return false;
- if (color != p_b.color)
+ if (color != p_vertex.color)
return false;
- if (bones.size() != p_b.bones.size())
+ if (bones.size() != p_vertex.bones.size())
return false;
for (int i = 0; i < bones.size(); i++) {
- if (bones[i] != p_b.bones[i])
+ if (bones[i] != p_vertex.bones[i])
return false;
}
for (int i = 0; i < weights.size(); i++) {
- if (weights[i] != p_b.weights[i])
+ if (weights[i] != p_vertex.weights[i])
return false;
}
@@ -691,6 +691,17 @@ void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvT
fvTexcOut[1] = v.y;
//fvTexcOut[1]=1.0-v.y;
}
+
+void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
+ const tbool bIsOrientationPreserving, const int iFace, const int iVert) {
+
+ Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
+ Vertex *vtx = &varr[iFace * 3 + iVert]->get();
+
+ vtx->tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]);
+ vtx->binormal = Vector3(fvBiTangent[0], fvBiTangent[1], fvBiTangent[2]);
+}
+
void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert) {
Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
@@ -715,8 +726,8 @@ void SurfaceTool::generate_tangents() {
mkif.m_getNumVerticesOfFace = mikktGetNumVerticesOfFace;
mkif.m_getPosition = mikktGetPosition;
mkif.m_getTexCoord = mikktGetTexCoord;
- mkif.m_setTSpaceBasic = mikktSetTSpaceBasic;
- mkif.m_setTSpace = NULL;
+ mkif.m_setTSpace = mikktSetTSpaceDefault;
+ mkif.m_setTSpaceBasic = NULL;
SMikkTSpaceContext msc;
msc.m_pInterface = &mkif;
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index d02e170b02..cdaac643de 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -90,6 +90,8 @@ private:
static void mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert);
static void mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert);
static void mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert);
+ static void mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
+ const tbool bIsOrientationPreserving, const int iFace, const int iVert);
protected:
static void _bind_methods();
@@ -102,8 +104,8 @@ public:
void add_normal(const Vector3 &p_normal);
void add_tangent(const Plane &p_tangent);
void add_uv(const Vector2 &p_uv);
- void add_uv2(const Vector2 &p_uv);
- void add_bones(const Vector<int> &p_indices);
+ void add_uv2(const Vector2 &p_uv2);
+ void add_bones(const Vector<int> &p_bones);
void add_weights(const Vector<float> &p_weights);
void add_smooth_group(bool p_smooth);
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 9a251c029d..9751d6e711 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -75,14 +75,14 @@ void Texture::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_data"), &Texture::get_data);
- BIND_CONSTANT(FLAG_MIPMAPS);
- BIND_CONSTANT(FLAG_REPEAT);
- BIND_CONSTANT(FLAG_FILTER);
- BIND_CONSTANT(FLAG_VIDEO_SURFACE);
- BIND_CONSTANT(FLAGS_DEFAULT);
- BIND_CONSTANT(FLAG_ANISOTROPIC_FILTER);
- BIND_CONSTANT(FLAG_CONVERT_TO_LINEAR);
- BIND_CONSTANT(FLAG_MIRRORED_REPEAT);
+ BIND_ENUM_CONSTANT(FLAG_MIPMAPS);
+ BIND_ENUM_CONSTANT(FLAG_REPEAT);
+ BIND_ENUM_CONSTANT(FLAG_FILTER);
+ BIND_ENUM_CONSTANT(FLAG_VIDEO_SURFACE);
+ BIND_ENUM_CONSTANT(FLAGS_DEFAULT);
+ BIND_ENUM_CONSTANT(FLAG_ANISOTROPIC_FILTER);
+ BIND_ENUM_CONSTANT(FLAG_CONVERT_TO_LINEAR);
+ BIND_ENUM_CONSTANT(FLAG_MIRRORED_REPEAT);
}
Texture::Texture() {
@@ -362,9 +362,9 @@ void ImageTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_size_override", "size"), &ImageTexture::set_size_override);
ClassDB::bind_method(D_METHOD("_reload_hook", "rid"), &ImageTexture::_reload_hook);
- BIND_CONSTANT(STORAGE_RAW);
- BIND_CONSTANT(STORAGE_COMPRESS_LOSSY);
- BIND_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
+ BIND_ENUM_CONSTANT(STORAGE_RAW);
+ BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSY);
+ BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
}
ImageTexture::ImageTexture() {
@@ -1335,19 +1335,21 @@ void CubeMap::_bind_methods() {
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);
- BIND_CONSTANT(STORAGE_COMPRESS_LOSSY);
- BIND_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
- BIND_CONSTANT(SIDE_LEFT);
- BIND_CONSTANT(SIDE_RIGHT);
- BIND_CONSTANT(SIDE_BOTTOM);
- BIND_CONSTANT(SIDE_TOP);
- BIND_CONSTANT(SIDE_FRONT);
- BIND_CONSTANT(SIDE_BACK);
- BIND_CONSTANT(FLAG_MIPMAPS);
- BIND_CONSTANT(FLAG_REPEAT);
- BIND_CONSTANT(FLAG_FILTER);
- BIND_CONSTANT(FLAGS_DEFAULT);
+ BIND_ENUM_CONSTANT(STORAGE_RAW);
+ BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSY);
+ BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
+
+ BIND_ENUM_CONSTANT(SIDE_LEFT);
+ BIND_ENUM_CONSTANT(SIDE_RIGHT);
+ BIND_ENUM_CONSTANT(SIDE_BOTTOM);
+ BIND_ENUM_CONSTANT(SIDE_TOP);
+ BIND_ENUM_CONSTANT(SIDE_FRONT);
+ BIND_ENUM_CONSTANT(SIDE_BACK);
+
+ BIND_ENUM_CONSTANT(FLAG_MIPMAPS);
+ BIND_ENUM_CONSTANT(FLAG_REPEAT);
+ BIND_ENUM_CONSTANT(FLAG_FILTER);
+ BIND_ENUM_CONSTANT(FLAGS_DEFAULT);
}
CubeMap::CubeMap() {
@@ -1366,13 +1368,14 @@ CubeMap::~CubeMap() {
VisualServer::get_singleton()->free(cubemap);
}
-/* BIND_CONSTANT( FLAG_CUBEMAP );
- BIND_CONSTANT( CUBEMAP_LEFT );
- BIND_CONSTANT( CUBEMAP_RIGHT );
- BIND_CONSTANT( CUBEMAP_BOTTOM );
- BIND_CONSTANT( CUBEMAP_TOP );
- BIND_CONSTANT( CUBEMAP_FRONT );
- BIND_CONSTANT( CUBEMAP_BACK );
+/* BIND_ENUM(CubeMapSize);
+ BIND_ENUM_CONSTANT( FLAG_CUBEMAP );
+ BIND_ENUM_CONSTANT( CUBEMAP_LEFT );
+ BIND_ENUM_CONSTANT( CUBEMAP_RIGHT );
+ BIND_ENUM_CONSTANT( CUBEMAP_BOTTOM );
+ BIND_ENUM_CONSTANT( CUBEMAP_TOP );
+ BIND_ENUM_CONSTANT( CUBEMAP_FRONT );
+ BIND_ENUM_CONSTANT( CUBEMAP_BACK );
*/
///////////////////////////
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 6c20c71af0..207436e4a7 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 1d5aed0444..e2e29b037b 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -883,7 +883,7 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin
ERR_FAIL_V(RES());
}
- sbflat->set_border_size(params[0].to_int());
+ sbflat->set_border_width_all(params[0].to_int());
if (!params[0].is_valid_integer()) {
@@ -929,8 +929,8 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin
dark = Color::html(params[3]);
}
- sbflat->set_dark_color(dark);
- sbflat->set_light_color(bright);
+ sbflat->set_border_color_all(bright);
+ // sbflat->set_dark_color(dark);
sbflat->set_bg_color(normal);
if (params.size() == ccodes + 5) {
@@ -1030,14 +1030,13 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin
ERR_FAIL_V(RES());
}
- if (res->cast_to<StyleBox>()) {
-
+ if (Object::cast_to<StyleBox>(*res)) {
theme->set_stylebox(item, control, res);
- } else if (res->cast_to<Font>()) {
+ } else if (Object::cast_to<Font>(*res)) {
theme->set_font(item, control, res);
- } else if (res->cast_to<Font>()) {
+ } else if (Object::cast_to<Font>(*res)) {
theme->set_font(item, control, res);
- } else if (res->cast_to<Texture>()) {
+ } else if (Object::cast_to<Texture>(*res)) {
theme->set_icon(item, control, res);
} else {
memdelete(f);
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 1dfea7f421..5b375d5585 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -143,8 +143,8 @@ public:
static void set_default(const Ref<Theme> &p_default);
static void set_default_icon(const Ref<Texture> &p_icon);
- static void set_default_style(const Ref<StyleBox> &p_default_style);
- static void set_default_font(const Ref<Font> &p_default_font);
+ static void set_default_style(const Ref<StyleBox> &p_style);
+ static void set_default_font(const Ref<Font> &p_font);
void set_default_theme_font(const Ref<Font> &p_default_font);
Ref<Font> get_default_theme_font() const;
@@ -159,7 +159,7 @@ public:
Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type) const;
bool has_shader(const StringName &p_name, const StringName &p_type) const;
void clear_shader(const StringName &p_name, const StringName &p_type);
- void get_shader_list(const StringName &p_name, List<StringName> *p_list) const;
+ void get_shader_list(const StringName &p_type, List<StringName> *p_list) const;
void set_stylebox(const StringName &p_name, const StringName &p_type, const Ref<StyleBox> &p_style);
Ref<StyleBox> get_stylebox(const StringName &p_name, const StringName &p_type) const;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 44fe676ddc..50e8c28c22 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 99c506390c..fe782ff987 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -105,7 +105,7 @@ public:
void tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape);
Ref<Shape2D> tile_get_shape(int p_id, int p_shape_id) const;
- void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_transform);
+ void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset);
Transform2D tile_get_shape_transform(int p_id, int p_shape_id) const;
void tile_set_shape_one_way(int p_id, int p_shape_id, bool p_one_way);
@@ -121,7 +121,7 @@ public:
void tile_set_material(int p_id, const Ref<ShaderMaterial> &p_material);
Ref<ShaderMaterial> tile_get_material(int p_id) const;
- void tile_set_modulate(int p_id, const Color &p_color);
+ void tile_set_modulate(int p_id, const Color &p_modulate);
Color tile_get_modulate(int p_id) const;
void tile_set_occluder_offset(int p_id, const Vector2 &p_offset);
diff --git a/scene/resources/video_stream.cpp b/scene/resources/video_stream.cpp
index 1b0e34b8db..2298e2ca9f 100644
--- a/scene/resources/video_stream.cpp
+++ b/scene/resources/video_stream.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h
index 544973f581..e08be02a07 100644
--- a/scene/resources/video_stream.h
+++ b/scene/resources/video_stream.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -30,7 +30,6 @@
#ifndef VIDEO_STREAM_H
#define VIDEO_STREAM_H
-#include "audio_stream_resampled.h"
#include "scene/resources/texture.h"
class VideoStreamPlayback : public Resource {
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index b0d14125a0..af159975ca 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "world.h"
+
#include "camera_matrix.h"
#include "octree.h"
#include "scene/3d/camera.h"
-#include "scene/3d/spatial_indexer.h"
#include "scene/3d/visibility_notifier.h"
#include "scene/scene_string_names.h"
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 158086974c..767d1b5b6e 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 2f43f903ba..a644793bd8 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index f968b08a15..63d32473e0 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index f247e7cde8..6b7168a529 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 0b70cd36ff..8676b8436e 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */