summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/SCsub4
-rw-r--r--scene/2d/animated_sprite.cpp111
-rw-r--r--scene/2d/animated_sprite.h7
-rw-r--r--scene/2d/area_2d.cpp171
-rw-r--r--scene/2d/area_2d.h8
-rw-r--r--scene/2d/back_buffer_copy.cpp10
-rw-r--r--scene/2d/back_buffer_copy.h4
-rw-r--r--scene/2d/camera_2d.cpp144
-rw-r--r--scene/2d/camera_2d.h6
-rw-r--r--scene/2d/canvas_item.cpp417
-rw-r--r--scene/2d/canvas_item.h71
-rw-r--r--scene/2d/canvas_modulate.cpp14
-rw-r--r--scene/2d/canvas_modulate.h4
-rw-r--r--scene/2d/collision_object_2d.cpp57
-rw-r--r--scene/2d/collision_object_2d.h12
-rw-r--r--scene/2d/collision_polygon_2d.cpp32
-rw-r--r--scene/2d/collision_polygon_2d.h4
-rw-r--r--scene/2d/collision_shape_2d.cpp20
-rw-r--r--scene/2d/collision_shape_2d.h4
-rw-r--r--scene/2d/joints_2d.cpp54
-rw-r--r--scene/2d/joints_2d.h10
-rw-r--r--scene/2d/light_2d.cpp176
-rw-r--r--scene/2d/light_2d.h37
-rw-r--r--scene/2d/light_occluder_2d.cpp41
-rw-r--r--scene/2d/light_occluder_2d.h12
-rw-r--r--scene/2d/navigation2d.cpp24
-rw-r--r--scene/2d/navigation2d.h10
-rw-r--r--scene/2d/navigation_polygon.cpp85
-rw-r--r--scene/2d/navigation_polygon.h22
-rw-r--r--scene/2d/node_2d.cpp193
-rw-r--r--scene/2d/node_2d.h38
-rw-r--r--scene/2d/parallax_background.cpp47
-rw-r--r--scene/2d/parallax_background.h6
-rw-r--r--scene/2d/parallax_layer.cpp27
-rw-r--r--scene/2d/parallax_layer.h4
-rw-r--r--scene/2d/particles_2d.cpp152
-rw-r--r--scene/2d/particles_2d.h13
-rw-r--r--scene/2d/path_2d.cpp42
-rw-r--r--scene/2d/path_2d.h6
-rw-r--r--scene/2d/path_texture.cpp2
-rw-r--r--scene/2d/path_texture.h4
-rw-r--r--scene/2d/physics_body_2d.cpp285
-rw-r--r--scene/2d/physics_body_2d.h20
-rw-r--r--scene/2d/polygon_2d.cpp94
-rw-r--r--scene/2d/polygon_2d.h22
-rw-r--r--scene/2d/position_2d.cpp2
-rw-r--r--scene/2d/position_2d.h4
-rw-r--r--scene/2d/ray_cast_2d.cpp94
-rw-r--r--scene/2d/ray_cast_2d.h7
-rw-r--r--scene/2d/remote_transform_2d.cpp8
-rw-r--r--scene/2d/remote_transform_2d.h4
-rw-r--r--scene/2d/sample_player_2d.cpp33
-rw-r--r--scene/2d/sample_player_2d.h4
-rw-r--r--scene/2d/screen_button.cpp38
-rw-r--r--scene/2d/screen_button.h4
-rw-r--r--scene/2d/sound_player_2d.cpp20
-rw-r--r--scene/2d/sound_player_2d.h4
-rw-r--r--scene/2d/sprite.cpp95
-rw-r--r--scene/2d/sprite.h12
-rw-r--r--scene/2d/tile_map.cpp214
-rw-r--r--scene/2d/tile_map.h22
-rw-r--r--scene/2d/visibility_notifier_2d.cpp47
-rw-r--r--scene/2d/visibility_notifier_2d.h6
-rw-r--r--scene/2d/y_sort.cpp9
-rw-r--r--scene/2d/y_sort.h4
-rw-r--r--scene/3d/SCsub10
-rw-r--r--scene/3d/area.cpp171
-rw-r--r--scene/3d/area.h8
-rw-r--r--scene/3d/baked_light_instance.cpp1742
-rw-r--r--scene/3d/baked_light_instance.h133
-rw-r--r--scene/3d/body_shape.cpp42
-rw-r--r--scene/3d/body_shape.h4
-rw-r--r--scene/3d/bone_attachment.cpp7
-rw-r--r--scene/3d/bone_attachment.h6
-rw-r--r--scene/3d/camera.cpp186
-rw-r--r--scene/3d/camera.h10
-rw-r--r--scene/3d/character_camera.cpp62
-rw-r--r--scene/3d/character_camera.h4
-rw-r--r--scene/3d/collision_object.cpp52
-rw-r--r--scene/3d/collision_object.h4
-rw-r--r--scene/3d/collision_polygon.cpp46
-rw-r--r--scene/3d/collision_polygon.h8
-rw-r--r--scene/3d/gi_probe.cpp1407
-rw-r--r--scene/3d/gi_probe.h190
-rw-r--r--scene/3d/immediate_geometry.cpp28
-rw-r--r--scene/3d/immediate_geometry.h10
-rw-r--r--scene/3d/interpolated_camera.cpp16
-rw-r--r--scene/3d/interpolated_camera.h4
-rw-r--r--scene/3d/light.cpp677
-rw-r--r--scene/3d/light.h175
-rw-r--r--scene/3d/listener.cpp9
-rw-r--r--scene/3d/listener.h2
-rw-r--r--scene/3d/mesh_instance.cpp53
-rw-r--r--scene/3d/mesh_instance.h14
-rw-r--r--scene/3d/multimesh_instance.cpp14
-rw-r--r--scene/3d/multimesh_instance.h8
-rw-r--r--scene/3d/navigation.cpp28
-rw-r--r--scene/3d/navigation.h4
-rw-r--r--scene/3d/navigation_mesh.cpp62
-rw-r--r--scene/3d/navigation_mesh.h12
-rw-r--r--scene/3d/particles.cpp94
-rw-r--r--scene/3d/particles.h13
-rw-r--r--scene/3d/path.cpp38
-rw-r--r--scene/3d/path.h6
-rw-r--r--scene/3d/physics_body.cpp256
-rw-r--r--scene/3d/physics_body.h18
-rw-r--r--scene/3d/physics_joint.cpp133
-rw-r--r--scene/3d/physics_joint.h18
-rw-r--r--scene/3d/portal.cpp82
-rw-r--r--scene/3d/portal.h12
-rw-r--r--scene/3d/position_3d.cpp33
-rw-r--r--scene/3d/position_3d.h5
-rw-r--r--scene/3d/proximity_group.cpp17
-rw-r--r--scene/3d/proximity_group.h4
-rw-r--r--scene/3d/quad.cpp64
-rw-r--r--scene/3d/quad.h11
-rw-r--r--scene/3d/ray_cast.cpp88
-rw-r--r--scene/3d/ray_cast.h6
-rw-r--r--scene/3d/reflection_probe.cpp268
-rw-r--r--scene/3d/reflection_probe.h92
-rw-r--r--scene/3d/remote_transform.cpp7
-rw-r--r--scene/3d/remote_transform.h2
-rw-r--r--scene/3d/room_instance.cpp104
-rw-r--r--scene/3d/room_instance.h15
-rw-r--r--scene/3d/scenario_fx.cpp8
-rw-r--r--scene/3d/scenario_fx.h4
-rw-r--r--scene/3d/skeleton.cpp95
-rw-r--r--scene/3d/skeleton.h5
-rw-r--r--scene/3d/spatial.cpp181
-rw-r--r--scene/3d/spatial.h22
-rw-r--r--scene/3d/spatial_indexer.cpp4
-rw-r--r--scene/3d/spatial_indexer.h4
-rw-r--r--scene/3d/spatial_player.cpp163
-rw-r--r--scene/3d/spatial_player.h6
-rw-r--r--scene/3d/spatial_sample_player.cpp26
-rw-r--r--scene/3d/spatial_sample_player.h4
-rw-r--r--scene/3d/spatial_stream_player.cpp86
-rw-r--r--scene/3d/spatial_stream_player.h4
-rw-r--r--scene/3d/sprite_3d.cpp133
-rw-r--r--scene/3d/sprite_3d.h22
-rw-r--r--scene/3d/test_cube.cpp10
-rw-r--r--scene/3d/test_cube.h8
-rw-r--r--scene/3d/vehicle_body.cpp139
-rw-r--r--scene/3d/vehicle_body.h8
-rw-r--r--scene/3d/visibility_notifier.cpp49
-rw-r--r--scene/3d/visibility_notifier.h12
-rw-r--r--scene/3d/visual_instance.cpp229
-rw-r--r--scene/3d/visual_instance.h48
-rw-r--r--scene/SCsub24
-rw-r--r--scene/animation/SCsub4
-rw-r--r--scene/animation/animation_cache.cpp12
-rw-r--r--scene/animation/animation_cache.h4
-rw-r--r--scene/animation/animation_player.cpp127
-rw-r--r--scene/animation/animation_player.h12
-rw-r--r--scene/animation/animation_tree_player.cpp187
-rw-r--r--scene/animation/animation_tree_player.h13
-rw-r--r--scene/animation/tween.cpp261
-rw-r--r--scene/animation/tween.h27
-rw-r--r--scene/animation/tween_interpolaters.cpp2
-rw-r--r--scene/audio/SCsub4
-rw-r--r--scene/audio/event_player.cpp76
-rw-r--r--scene/audio/event_player.h4
-rw-r--r--scene/audio/sample_player.cpp118
-rw-r--r--scene/audio/sample_player.h4
-rw-r--r--scene/audio/sound_room_params.cpp14
-rw-r--r--scene/audio/sound_room_params.h4
-rw-r--r--scene/audio/stream_player.cpp84
-rw-r--r--scene/audio/stream_player.h4
-rw-r--r--scene/gui/SCsub4
-rw-r--r--scene/gui/base_button.cpp183
-rw-r--r--scene/gui/base_button.h46
-rw-r--r--scene/gui/box_container.cpp23
-rw-r--r--scene/gui/box_container.h8
-rw-r--r--scene/gui/button.cpp44
-rw-r--r--scene/gui/button.h8
-rw-r--r--scene/gui/button_array.cpp106
-rw-r--r--scene/gui/button_array.h22
-rw-r--r--scene/gui/button_group.cpp21
-rw-r--r--scene/gui/button_group.h7
-rw-r--r--scene/gui/center_container.cpp8
-rw-r--r--scene/gui/center_container.h4
-rw-r--r--scene/gui/check_box.cpp10
-rw-r--r--scene/gui/check_box.h4
-rw-r--r--scene/gui/check_button.cpp2
-rw-r--r--scene/gui/check_button.h4
-rw-r--r--scene/gui/color_picker.cpp276
-rw-r--r--scene/gui/color_picker.h27
-rw-r--r--scene/gui/color_ramp_edit.cpp12
-rw-r--r--scene/gui/color_ramp_edit.h8
-rw-r--r--scene/gui/color_rect.cpp45
-rw-r--r--scene/gui/color_rect.h40
-rw-r--r--scene/gui/container.cpp12
-rw-r--r--scene/gui/container.h4
-rw-r--r--scene/gui/control.cpp673
-rw-r--r--scene/gui/control.h36
-rw-r--r--scene/gui/dialogs.cpp111
-rw-r--r--scene/gui/dialogs.h21
-rw-r--r--scene/gui/file_dialog.cpp135
-rw-r--r--scene/gui/file_dialog.h6
-rw-r--r--scene/gui/graph_edit.cpp121
-rw-r--r--scene/gui/graph_edit.h10
-rw-r--r--scene/gui/graph_node.cpp87
-rw-r--r--scene/gui/graph_node.h11
-rw-r--r--scene/gui/grid_container.cpp18
-rw-r--r--scene/gui/grid_container.h4
-rw-r--r--scene/gui/input_action.cpp18
-rw-r--r--scene/gui/input_action.h2
-rw-r--r--scene/gui/item_list.cpp170
-rw-r--r--scene/gui/item_list.h6
-rw-r--r--scene/gui/label.cpp103
-rw-r--r--scene/gui/label.h5
-rw-r--r--scene/gui/line_edit.cpp104
-rw-r--r--scene/gui/line_edit.h6
-rw-r--r--scene/gui/link_button.cpp17
-rw-r--r--scene/gui/link_button.h7
-rw-r--r--scene/gui/margin_container.cpp4
-rw-r--r--scene/gui/margin_container.h4
-rw-r--r--scene/gui/menu_button.cpp28
-rw-r--r--scene/gui/menu_button.h6
-rw-r--r--scene/gui/option_button.cpp56
-rw-r--r--scene/gui/option_button.h4
-rw-r--r--scene/gui/panel.cpp4
-rw-r--r--scene/gui/panel.h4
-rw-r--r--scene/gui/panel_container.cpp6
-rw-r--r--scene/gui/panel_container.h4
-rw-r--r--scene/gui/patch_9_rect.cpp (renamed from scene/gui/patch_9_frame.cpp)85
-rw-r--r--scene/gui/patch_9_rect.h (renamed from scene/gui/patch_9_frame.h)16
-rw-r--r--scene/gui/popup.cpp27
-rw-r--r--scene/gui/popup.h8
-rw-r--r--scene/gui/popup_menu.cpp232
-rw-r--r--scene/gui/popup_menu.h29
-rw-r--r--scene/gui/progress_bar.cpp13
-rw-r--r--scene/gui/progress_bar.h4
-rw-r--r--scene/gui/range.cpp109
-rw-r--r--scene/gui/range.h22
-rw-r--r--scene/gui/reference_rect.cpp (renamed from scene/gui/reference_frame.cpp)10
-rw-r--r--scene/gui/reference_rect.h (renamed from scene/gui/reference_frame.h)16
-rw-r--r--scene/gui/rich_text_label.cpp137
-rw-r--r--scene/gui/rich_text_label.h6
-rw-r--r--scene/gui/scroll_bar.cpp110
-rw-r--r--scene/gui/scroll_bar.h10
-rw-r--r--scene/gui/scroll_container.cpp125
-rw-r--r--scene/gui/scroll_container.h9
-rw-r--r--scene/gui/separator.cpp2
-rw-r--r--scene/gui/separator.h8
-rw-r--r--scene/gui/slider.cpp54
-rw-r--r--scene/gui/slider.h10
-rw-r--r--scene/gui/spin_box.cpp75
-rw-r--r--scene/gui/spin_box.h6
-rw-r--r--scene/gui/split_container.cpp26
-rw-r--r--scene/gui/split_container.h10
-rw-r--r--scene/gui/tab_container.cpp42
-rw-r--r--scene/gui/tab_container.h6
-rw-r--r--scene/gui/tabs.cpp30
-rw-r--r--scene/gui/tabs.h6
-rw-r--r--scene/gui/text_edit.cpp303
-rw-r--r--scene/gui/text_edit.h33
-rw-r--r--scene/gui/texture_button.cpp68
-rw-r--r--scene/gui/texture_button.h9
-rw-r--r--scene/gui/texture_progress.cpp58
-rw-r--r--scene/gui/texture_progress.h4
-rw-r--r--scene/gui/texture_rect.cpp (renamed from scene/gui/texture_frame.cpp)73
-rw-r--r--scene/gui/texture_rect.h (renamed from scene/gui/texture_frame.h)17
-rw-r--r--scene/gui/tool_button.cpp2
-rw-r--r--scene/gui/tool_button.h4
-rw-r--r--scene/gui/tree.cpp427
-rw-r--r--scene/gui/tree.h23
-rw-r--r--scene/gui/video_player.cpp69
-rw-r--r--scene/gui/video_player.h4
-rw-r--r--scene/gui/viewport_container.cpp103
-rw-r--r--scene/gui/viewport_container.h25
-rw-r--r--scene/io/SCsub4
-rw-r--r--scene/io/resource_format_image.cpp140
-rw-r--r--scene/io/resource_format_image.h4
-rw-r--r--scene/io/resource_format_wav.cpp10
-rw-r--r--scene/io/resource_format_wav.h2
-rw-r--r--scene/main/SCsub4
-rw-r--r--scene/main/canvas_layer.cpp56
-rw-r--r--scene/main/canvas_layer.h15
-rw-r--r--scene/main/http_request.cpp113
-rw-r--r--scene/main/http_request.h11
-rw-r--r--scene/main/instance_placeholder.cpp25
-rw-r--r--scene/main/instance_placeholder.h6
-rw-r--r--scene/main/node.cpp506
-rw-r--r--scene/main/node.h36
-rw-r--r--scene/main/resource_preloader.cpp26
-rw-r--r--scene/main/resource_preloader.h6
-rw-r--r--scene/main/scene_main_loop.cpp336
-rw-r--r--scene/main/scene_main_loop.h33
-rw-r--r--scene/main/timer.cpp52
-rw-r--r--scene/main/timer.h4
-rw-r--r--scene/main/viewport.cpp749
-rw-r--r--scene/main/viewport.h169
-rw-r--r--scene/register_scene_types.cpp579
-rw-r--r--scene/register_scene_types.h2
-rw-r--r--scene/resources/SCsub8
-rw-r--r--scene/resources/animation.cpp175
-rw-r--r--scene/resources/animation.h24
-rw-r--r--scene/resources/audio_stream.cpp26
-rw-r--r--scene/resources/audio_stream.h6
-rw-r--r--scene/resources/audio_stream_resampled.cpp2
-rw-r--r--scene/resources/audio_stream_resampled.h4
-rw-r--r--scene/resources/baked_light.cpp573
-rw-r--r--scene/resources/baked_light.h164
-rw-r--r--scene/resources/bit_mask.cpp29
-rw-r--r--scene/resources/bit_mask.h4
-rw-r--r--scene/resources/bounds.cpp6
-rw-r--r--scene/resources/bounds.h4
-rw-r--r--scene/resources/box_shape.cpp8
-rw-r--r--scene/resources/box_shape.h4
-rw-r--r--scene/resources/canvas.cpp2
-rw-r--r--scene/resources/canvas.h4
-rw-r--r--scene/resources/capsule_shape.cpp10
-rw-r--r--scene/resources/capsule_shape.h4
-rw-r--r--scene/resources/capsule_shape_2d.cpp10
-rw-r--r--scene/resources/capsule_shape_2d.h4
-rw-r--r--scene/resources/circle_shape_2d.cpp6
-rw-r--r--scene/resources/circle_shape_2d.h4
-rw-r--r--scene/resources/color_ramp.cpp26
-rw-r--r--scene/resources/color_ramp.h4
-rw-r--r--scene/resources/concave_polygon_shape.cpp14
-rw-r--r--scene/resources/concave_polygon_shape.h8
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp20
-rw-r--r--scene/resources/concave_polygon_shape_2d.h8
-rw-r--r--scene/resources/convex_polygon_shape.cpp12
-rw-r--r--scene/resources/convex_polygon_shape.h10
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp10
-rw-r--r--scene/resources/convex_polygon_shape_2d.h4
-rw-r--r--scene/resources/curve.cpp221
-rw-r--r--scene/resources/curve.h28
-rw-r--r--scene/resources/default_theme/SCsub4
-rw-r--r--scene/resources/default_theme/button_pressed.pngbin610 -> 499 bytes
-rw-r--r--scene/resources/default_theme/color_picker_hue.pngbin0 -> 146 bytes
-rw-r--r--scene/resources/default_theme/color_picker_sample.pngbin0 -> 194 bytes
-rw-r--r--scene/resources/default_theme/default_theme.cpp48
-rw-r--r--scene/resources/default_theme/default_theme.h2
-rwxr-xr-x[-rw-r--r--]scene/resources/default_theme/make_header.py83
-rw-r--r--scene/resources/default_theme/theme_data.h46
-rw-r--r--scene/resources/default_theme/uv_editor.gsl19
-rw-r--r--scene/resources/default_theme/w_editor.gsl11
-rw-r--r--scene/resources/dynamic_font.cpp75
-rw-r--r--scene/resources/dynamic_font.h10
-rw-r--r--scene/resources/dynamic_font_stb.cpp24
-rw-r--r--scene/resources/dynamic_font_stb.h14
-rw-r--r--scene/resources/environment.cpp1195
-rw-r--r--scene/resources/environment.h350
-rw-r--r--scene/resources/event_stream.cpp2
-rw-r--r--scene/resources/event_stream.h6
-rw-r--r--scene/resources/font.cpp84
-rw-r--r--scene/resources/font.h14
-rw-r--r--scene/resources/gibberish_stream.cpp18
-rw-r--r--scene/resources/gibberish_stream.h4
-rw-r--r--scene/resources/material.cpp1280
-rw-r--r--scene/resources/material.h428
-rw-r--r--scene/resources/mesh.cpp358
-rw-r--r--scene/resources/mesh.h69
-rw-r--r--scene/resources/mesh_data_tool.cpp154
-rw-r--r--scene/resources/mesh_data_tool.h4
-rw-r--r--scene/resources/mesh_library.cpp28
-rw-r--r--scene/resources/mesh_library.h4
-rw-r--r--scene/resources/multimesh.cpp123
-rw-r--r--scene/resources/multimesh.h46
-rw-r--r--scene/resources/packed_scene.cpp170
-rw-r--r--scene/resources/packed_scene.h27
-rw-r--r--scene/resources/plane_shape.cpp6
-rw-r--r--scene/resources/plane_shape.h4
-rw-r--r--scene/resources/polygon_path_finder.cpp56
-rw-r--r--scene/resources/polygon_path_finder.h4
-rw-r--r--scene/resources/ray_shape.cpp6
-rw-r--r--scene/resources/ray_shape.h4
-rw-r--r--scene/resources/rectangle_shape_2d.cpp6
-rw-r--r--scene/resources/rectangle_shape_2d.h4
-rw-r--r--scene/resources/room.cpp50
-rw-r--r--scene/resources/room.h18
-rw-r--r--scene/resources/sample.cpp42
-rw-r--r--scene/resources/sample.h8
-rw-r--r--scene/resources/sample_library.cpp20
-rw-r--r--scene/resources/sample_library.h4
-rw-r--r--scene/resources/scene_format_text.cpp58
-rw-r--r--scene/resources/scene_format_text.h4
-rw-r--r--scene/resources/scene_preloader.cpp454
-rw-r--r--scene/resources/scene_preloader.h101
-rw-r--r--scene/resources/segment_shape_2d.cpp14
-rw-r--r--scene/resources/segment_shape_2d.h6
-rw-r--r--scene/resources/shader.cpp350
-rw-r--r--scene/resources/shader.h37
-rw-r--r--scene/resources/shader_graph.cpp209
-rw-r--r--scene/resources/shader_graph.h22
-rw-r--r--scene/resources/shape.cpp12
-rw-r--r--scene/resources/shape.h6
-rw-r--r--scene/resources/shape_2d.cpp22
-rw-r--r--scene/resources/shape_2d.h12
-rw-r--r--scene/resources/shape_line_2d.cpp10
-rw-r--r--scene/resources/shape_line_2d.h4
-rw-r--r--scene/resources/sky_box.cpp159
-rw-r--r--scene/resources/sky_box.h71
-rw-r--r--scene/resources/space_2d.cpp6
-rw-r--r--scene/resources/space_2d.h4
-rw-r--r--scene/resources/sphere_shape.cpp6
-rw-r--r--scene/resources/sphere_shape.h4
-rw-r--r--scene/resources/style_box.cpp226
-rw-r--r--scene/resources/style_box.h40
-rw-r--r--scene/resources/surface_tool.cpp160
-rw-r--r--scene/resources/surface_tool.h4
-rw-r--r--scene/resources/texture.cpp137
-rw-r--r--scene/resources/texture.h14
-rw-r--r--scene/resources/theme.cpp74
-rw-r--r--scene/resources/theme.h18
-rw-r--r--scene/resources/tile_set.cpp83
-rw-r--r--scene/resources/tile_set.h11
-rw-r--r--scene/resources/video_stream.cpp2
-rw-r--r--scene/resources/video_stream.h6
-rw-r--r--scene/resources/world.cpp28
-rw-r--r--scene/resources/world.h8
-rw-r--r--scene/resources/world_2d.cpp34
-rw-r--r--scene/resources/world_2d.h5
-rw-r--r--scene/scene_string_names.cpp49
-rw-r--r--scene/scene_string_names.h47
418 files changed, 16749 insertions, 12224 deletions
diff --git a/scene/2d/SCsub b/scene/2d/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/2d/SCsub
+++ b/scene/2d/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 73774e12d9..64d6ef5560 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -222,32 +222,32 @@ void SpriteFrames::_set_animations(const Array& p_animations) {
void SpriteFrames::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_animation","anim"),&SpriteFrames::add_animation);
- ObjectTypeDB::bind_method(_MD("has_animation","anim"),&SpriteFrames::has_animation);
- ObjectTypeDB::bind_method(_MD("remove_animation","anim"),&SpriteFrames::remove_animation);
- ObjectTypeDB::bind_method(_MD("rename_animation","anim","newname"),&SpriteFrames::rename_animation);
+ ClassDB::bind_method(_MD("add_animation","anim"),&SpriteFrames::add_animation);
+ ClassDB::bind_method(_MD("has_animation","anim"),&SpriteFrames::has_animation);
+ ClassDB::bind_method(_MD("remove_animation","anim"),&SpriteFrames::remove_animation);
+ ClassDB::bind_method(_MD("rename_animation","anim","newname"),&SpriteFrames::rename_animation);
- ObjectTypeDB::bind_method(_MD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed);
- ObjectTypeDB::bind_method(_MD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed);
+ ClassDB::bind_method(_MD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed);
+ ClassDB::bind_method(_MD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed);
- ObjectTypeDB::bind_method(_MD("set_animation_loop","anim","loop"),&SpriteFrames::set_animation_loop);
- ObjectTypeDB::bind_method(_MD("get_animation_loop","anim"),&SpriteFrames::get_animation_loop);
+ ClassDB::bind_method(_MD("set_animation_loop","anim","loop"),&SpriteFrames::set_animation_loop);
+ ClassDB::bind_method(_MD("get_animation_loop","anim"),&SpriteFrames::get_animation_loop);
- ObjectTypeDB::bind_method(_MD("add_frame","anim","frame","atpos"),&SpriteFrames::add_frame,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_frame_count","anim"),&SpriteFrames::get_frame_count);
- ObjectTypeDB::bind_method(_MD("get_frame","anim","idx"),&SpriteFrames::get_frame);
- ObjectTypeDB::bind_method(_MD("set_frame","anim","idx","txt"),&SpriteFrames::set_frame);
- ObjectTypeDB::bind_method(_MD("remove_frame","anim","idx"),&SpriteFrames::remove_frame);
- ObjectTypeDB::bind_method(_MD("clear","anim"),&SpriteFrames::clear);
- ObjectTypeDB::bind_method(_MD("clear_all"),&SpriteFrames::clear_all);
+ ClassDB::bind_method(_MD("add_frame","anim","frame","atpos"),&SpriteFrames::add_frame,DEFVAL(-1));
+ ClassDB::bind_method(_MD("get_frame_count","anim"),&SpriteFrames::get_frame_count);
+ ClassDB::bind_method(_MD("get_frame","anim","idx"),&SpriteFrames::get_frame);
+ ClassDB::bind_method(_MD("set_frame","anim","idx","txt"),&SpriteFrames::set_frame);
+ ClassDB::bind_method(_MD("remove_frame","anim","idx"),&SpriteFrames::remove_frame);
+ ClassDB::bind_method(_MD("clear","anim"),&SpriteFrames::clear);
+ ClassDB::bind_method(_MD("clear_all"),&SpriteFrames::clear_all);
- ObjectTypeDB::bind_method(_MD("_set_frames"),&SpriteFrames::_set_frames);
- ObjectTypeDB::bind_method(_MD("_get_frames"),&SpriteFrames::_get_frames);
+ ClassDB::bind_method(_MD("_set_frames"),&SpriteFrames::_set_frames);
+ ClassDB::bind_method(_MD("_get_frames"),&SpriteFrames::_get_frames);
ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"frames",PROPERTY_HINT_NONE,"",0),_SCS("_set_frames"),_SCS("_get_frames")); //compatibility
- ObjectTypeDB::bind_method(_MD("_set_animations"),&SpriteFrames::_set_animations);
- ObjectTypeDB::bind_method(_MD("_get_animations"),&SpriteFrames::_get_animations);
+ ClassDB::bind_method(_MD("_set_animations"),&SpriteFrames::_set_animations);
+ ClassDB::bind_method(_MD("_get_animations"),&SpriteFrames::_get_animations);
ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"animations",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_animations"),_SCS("_get_animations")); //compatibility
@@ -332,7 +332,7 @@ void AnimatedSprite::_validate_property(PropertyInfo& property) const {
void AnimatedSprite::_notification(int p_what) {
switch(p_what) {
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (frames.is_null())
return;
@@ -362,6 +362,9 @@ void AnimatedSprite::_notification(int p_what) {
}
} else {
frame++;
+ if (frame==fc-1) {
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ }
}
update();
@@ -414,7 +417,7 @@ void AnimatedSprite::_notification(int p_what) {
if (centered)
ofs-=s/2;
- if (OS::get_singleton()->get_use_pixel_snap()) {
+ if (Engine::get_singleton()->get_use_pixel_snap()) {
ofs=ofs.floor();
}
Rect2 dst_rect(ofs,s);
@@ -425,8 +428,8 @@ void AnimatedSprite::_notification(int p_what) {
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);
+ texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()));
+ //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
} break;
}
@@ -541,17 +544,6 @@ bool AnimatedSprite::is_flipped_v() const {
}
-void AnimatedSprite::set_modulate(const Color& p_color) {
-
- modulate=p_color;
- update();
-}
-
-Color AnimatedSprite::get_modulate() const{
-
- return modulate;
-}
-
Rect2 AnimatedSprite::get_item_rect() const {
@@ -590,7 +582,7 @@ void AnimatedSprite::_set_playing(bool p_playing) {
return;
playing=p_playing;
_reset_timeout();
- set_process(playing);
+ set_process_internal(playing);
}
bool AnimatedSprite::_is_playing() const {
@@ -661,41 +653,39 @@ String AnimatedSprite::get_configuration_warning() const {
void AnimatedSprite::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames);
- ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames);
+ ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames);
+ ClassDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames);
- ObjectTypeDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite::set_animation);
- ObjectTypeDB::bind_method(_MD("get_animation"),&AnimatedSprite::get_animation);
+ ClassDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite::set_animation);
+ ClassDB::bind_method(_MD("get_animation"),&AnimatedSprite::get_animation);
- ObjectTypeDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite::_set_playing);
- ObjectTypeDB::bind_method(_MD("_is_playing"),&AnimatedSprite::_is_playing);
+ ClassDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite::_set_playing);
+ ClassDB::bind_method(_MD("_is_playing"),&AnimatedSprite::_is_playing);
- ObjectTypeDB::bind_method(_MD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName()));
- ObjectTypeDB::bind_method(_MD("stop"),&AnimatedSprite::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AnimatedSprite::is_playing);
+ ClassDB::bind_method(_MD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName()));
+ ClassDB::bind_method(_MD("stop"),&AnimatedSprite::stop);
+ ClassDB::bind_method(_MD("is_playing"),&AnimatedSprite::is_playing);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&AnimatedSprite::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&AnimatedSprite::is_centered);
+ ClassDB::bind_method(_MD("set_centered","centered"),&AnimatedSprite::set_centered);
+ ClassDB::bind_method(_MD("is_centered"),&AnimatedSprite::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&AnimatedSprite::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&AnimatedSprite::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&AnimatedSprite::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&AnimatedSprite::get_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&AnimatedSprite::is_flipped_h);
+ ClassDB::bind_method(_MD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h);
+ ClassDB::bind_method(_MD("is_flipped_h"),&AnimatedSprite::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&AnimatedSprite::is_flipped_v);
+ ClassDB::bind_method(_MD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v);
+ ClassDB::bind_method(_MD("is_flipped_v"),&AnimatedSprite::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite::get_frame);
+ ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite::set_frame);
+ ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite::get_frame);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&AnimatedSprite::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&AnimatedSprite::get_modulate);
-
- ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
+ ClassDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
+ ADD_SIGNAL(MethodInfo("animation_finished"));
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation"));
@@ -705,7 +695,7 @@ void AnimatedSprite::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
+
}
@@ -718,7 +708,6 @@ AnimatedSprite::AnimatedSprite() {
frame=0;
playing=false;
animation="default";
- modulate=Color(1,1,1,1);
timeout=0;
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index 968cd9aa30..fbeea7f69b 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SpriteFrames : public Resource {
- OBJ_TYPE(SpriteFrames,Resource);
+ GDCLASS(SpriteFrames,Resource);
struct Anim {
@@ -109,7 +109,7 @@ public:
class AnimatedSprite : public Node2D {
- OBJ_TYPE(AnimatedSprite,Node2D);
+ GDCLASS(AnimatedSprite,Node2D);
Ref<SpriteFrames> frames;
bool playing;
@@ -124,7 +124,6 @@ class AnimatedSprite : public Node2D {
bool hflip;
bool vflip;
- Color modulate;
void _res_changed();
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 71728966fd..67c596421f 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -127,10 +127,10 @@ void Area2D::_body_enter_tree(ObjectID p_id) {
ERR_FAIL_COND(E->get().in_tree);
E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
}
}
@@ -144,10 +144,10 @@ void Area2D::_body_exit_tree(ObjectID p_id) {
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
}
}
@@ -173,10 +173,10 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
E->get().rc=0;
E->get().in_tree=node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
}
}
@@ -187,7 +187,7 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,objid,node,p_body_shape,p_area_shape);
}
} else {
@@ -202,10 +202,10 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
if (E->get().rc==0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree);
if (E->get().in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,obj);
}
@@ -213,7 +213,7 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
}
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,objid,obj,p_body_shape,p_area_shape);
}
if (eraseit)
@@ -239,10 +239,10 @@ void Area2D::_area_enter_tree(ObjectID p_id) {
ERR_FAIL_COND(E->get().in_tree);
E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->area_entered,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_entered,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
}
}
@@ -256,10 +256,10 @@ void Area2D::_area_exit_tree(ObjectID p_id) {
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->area_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->area_exited,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_exited,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
}
}
@@ -285,10 +285,10 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a
E->get().rc=0;
E->get().in_tree=node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->area_entered,node);
}
}
@@ -299,7 +299,7 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,objid,node,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_entered,objid,node,p_area_shape,p_self_shape);
}
} else {
@@ -314,10 +314,10 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a
if (E->get().rc==0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree);
if (E->get().in_tree)
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exited,obj);
}
@@ -325,7 +325,7 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a
}
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,objid,obj,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_exited,objid,obj,p_area_shape,p_self_shape);
}
if (eraseit)
@@ -362,13 +362,13 @@ void Area2D::_clear_monitoring() {
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
}
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,obj);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree);
}
}
@@ -393,13 +393,13 @@ void Area2D::_clear_monitoring() {
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_exited,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
}
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exited,obj);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree);
}
}
@@ -418,7 +418,7 @@ void Area2D::_notification(int p_what) {
}
-void Area2D::set_enable_monitoring(bool p_enable) {
+void Area2D::set_monitoring(bool p_enable) {
if (p_enable==monitoring)
@@ -443,7 +443,7 @@ void Area2D::set_enable_monitoring(bool p_enable) {
}
}
-bool Area2D::is_monitoring_enabled() const {
+bool Area2D::is_monitoring() const {
return monitoring;
}
@@ -587,73 +587,73 @@ bool Area2D::get_layer_mask_bit(int p_bit) const{
void Area2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_body_enter_tree","id"),&Area2D::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree","id"),&Area2D::_body_exit_tree);
+ ClassDB::bind_method(_MD("_body_enter_tree","id"),&Area2D::_body_enter_tree);
+ ClassDB::bind_method(_MD("_body_exit_tree","id"),&Area2D::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("_area_enter_tree","id"),&Area2D::_area_enter_tree);
- ObjectTypeDB::bind_method(_MD("_area_exit_tree","id"),&Area2D::_area_exit_tree);
+ ClassDB::bind_method(_MD("_area_enter_tree","id"),&Area2D::_area_enter_tree);
+ ClassDB::bind_method(_MD("_area_exit_tree","id"),&Area2D::_area_exit_tree);
- ObjectTypeDB::bind_method(_MD("set_space_override_mode","enable"),&Area2D::set_space_override_mode);
- ObjectTypeDB::bind_method(_MD("get_space_override_mode"),&Area2D::get_space_override_mode);
+ ClassDB::bind_method(_MD("set_space_override_mode","enable"),&Area2D::set_space_override_mode);
+ ClassDB::bind_method(_MD("get_space_override_mode"),&Area2D::get_space_override_mode);
- ObjectTypeDB::bind_method(_MD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point);
- ObjectTypeDB::bind_method(_MD("is_gravity_a_point"),&Area2D::is_gravity_a_point);
+ ClassDB::bind_method(_MD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point);
+ ClassDB::bind_method(_MD("is_gravity_a_point"),&Area2D::is_gravity_a_point);
- ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale);
+ ClassDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale);
+ ClassDB::bind_method(_MD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("set_gravity_vector","vector"),&Area2D::set_gravity_vector);
- ObjectTypeDB::bind_method(_MD("get_gravity_vector"),&Area2D::get_gravity_vector);
+ ClassDB::bind_method(_MD("set_gravity_vector","vector"),&Area2D::set_gravity_vector);
+ ClassDB::bind_method(_MD("get_gravity_vector"),&Area2D::get_gravity_vector);
- ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&Area2D::set_gravity);
- ObjectTypeDB::bind_method(_MD("get_gravity"),&Area2D::get_gravity);
+ ClassDB::bind_method(_MD("set_gravity","gravity"),&Area2D::set_gravity);
+ ClassDB::bind_method(_MD("get_gravity"),&Area2D::get_gravity);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&Area2D::get_linear_damp);
+ ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp);
+ ClassDB::bind_method(_MD("get_linear_damp"),&Area2D::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&Area2D::get_angular_damp);
+ ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp);
+ ClassDB::bind_method(_MD("get_angular_damp"),&Area2D::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority);
- ObjectTypeDB::bind_method(_MD("get_priority"),&Area2D::get_priority);
+ ClassDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority);
+ ClassDB::bind_method(_MD("get_priority"),&Area2D::get_priority);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask);
+ ClassDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask);
+ ClassDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask);
+ ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask);
+ ClassDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit);
+ ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit);
+ ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit);
+ ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit);
+ ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring);
- ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled);
+ ClassDB::bind_method(_MD("set_monitoring","enable"),&Area2D::set_monitoring);
+ ClassDB::bind_method(_MD("is_monitoring"),&Area2D::is_monitoring);
- ObjectTypeDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable);
- ObjectTypeDB::bind_method(_MD("is_monitorable"),&Area2D::is_monitorable);
+ ClassDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable);
+ ClassDB::bind_method(_MD("is_monitorable"),&Area2D::is_monitorable);
- ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies);
- ObjectTypeDB::bind_method(_MD("get_overlapping_areas"),&Area2D::get_overlapping_areas);
+ ClassDB::bind_method(_MD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies);
+ ClassDB::bind_method(_MD("get_overlapping_areas"),&Area2D::get_overlapping_areas);
- ObjectTypeDB::bind_method(_MD("overlaps_body","body"),&Area2D::overlaps_body);
- ObjectTypeDB::bind_method(_MD("overlaps_area","area"),&Area2D::overlaps_area);
+ ClassDB::bind_method(_MD("overlaps_body","body"),&Area2D::overlaps_body);
+ ClassDB::bind_method(_MD("overlaps_area","area"),&Area2D::overlaps_area);
- ObjectTypeDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout);
- ObjectTypeDB::bind_method(_MD("_area_inout"),&Area2D::_area_inout);
+ ClassDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout);
+ ClassDB::bind_method(_MD("_area_inout"),&Area2D::_area_inout);
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
+ ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("body_entered",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
+ ADD_SIGNAL( MethodInfo("body_exited",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
- ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
+ ADD_SIGNAL( MethodInfo("area_shape_entered",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_shape_exited",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_entered",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
+ ADD_SIGNAL( MethodInfo("area_exited",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
@@ -664,10 +664,11 @@ void Area2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_monitoring"),_SCS("is_monitoring"));
ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_GROUP("Collision","collision_");
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
}
@@ -686,7 +687,7 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea
monitorable=false;
collision_mask=1;
layer_mask=1;
- set_enable_monitoring(true);
+ set_monitoring(true);
set_monitorable(true);
}
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index 7f3f9c93cf..68bada707b 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Area2D : public CollisionObject2D {
- OBJ_TYPE( Area2D, CollisionObject2D );
+ GDCLASS( Area2D, CollisionObject2D );
public:
enum SpaceOverride {
@@ -153,8 +153,8 @@ public:
void set_priority(real_t p_priority);
real_t get_priority() const;
- void set_enable_monitoring(bool p_enable);
- bool is_monitoring_enabled() const;
+ void set_monitoring(bool p_enable);
+ bool is_monitoring() const;
void set_monitorable(bool p_enable);
bool is_monitorable() const;
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index a83a3ce041..bbeed322b1 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -77,11 +77,11 @@ BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const{
void BackBufferCopy::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect);
- ObjectTypeDB::bind_method(_MD("get_rect"),&BackBufferCopy::get_rect);
+ ClassDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect);
+ ClassDB::bind_method(_MD("get_rect"),&BackBufferCopy::get_rect);
- ObjectTypeDB::bind_method(_MD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode);
- ObjectTypeDB::bind_method(_MD("get_copy_mode"),&BackBufferCopy::get_copy_mode);
+ ClassDB::bind_method(_MD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode);
+ ClassDB::bind_method(_MD("get_copy_mode"),&BackBufferCopy::get_copy_mode);
ADD_PROPERTY( PropertyInfo(Variant::INT,"copy_mode",PROPERTY_HINT_ENUM,"Disabled,Rect,Viewport"),_SCS("set_copy_mode"),_SCS("get_copy_mode"));
ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h
index f371dbdef4..22387f3e9d 100644
--- a/scene/2d/back_buffer_copy.h
+++ b/scene/2d/back_buffer_copy.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/2d/node_2d.h"
class BackBufferCopy : public Node2D {
- OBJ_TYPE( BackBufferCopy,Node2D);
+ GDCLASS( BackBufferCopy,Node2D);
public:
enum CopyMode {
COPY_MODE_DISABLED,
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index f33faaabd8..0bafef1b83 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,12 +47,12 @@ void Camera2D::_update_scroll() {
ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) );
- Matrix32 xform = get_camera_transform();
+ Transform2D xform = get_camera_transform();
if (viewport) {
viewport->set_canvas_transform( xform );
}
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform);
};
}
@@ -71,12 +71,12 @@ Vector2 Camera2D::get_zoom() const {
};
-Matrix32 Camera2D::get_camera_transform() {
+Transform2D Camera2D::get_camera_transform() {
if (!get_tree())
- return Matrix32();
+ return Transform2D();
- ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Matrix32() );
+ ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D() );
Size2 screen_size = viewport->get_visible_rect().size;
@@ -145,7 +145,7 @@ Matrix32 Camera2D::get_camera_transform() {
float c = smoothing*get_fixed_process_delta_time();
smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
ret_camera_pos=smoothed_camera_pos;
- // camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
+ //camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
} else {
ret_camera_pos=smoothed_camera_pos=camera_pos;
@@ -201,7 +201,7 @@ Matrix32 Camera2D::get_camera_transform() {
camera_screen_center=screen_rect.pos+screen_rect.size*0.5;
- Matrix32 xform;
+ Transform2D xform;
if(rotating){
xform.set_rotation(angle);
}
@@ -252,7 +252,7 @@ void Camera2D::_notification(int p_what) {
canvas = get_canvas();
- RID vp = viewport->get_viewport();
+ RID vp = viewport->get_viewport_rid();
group_name = "__cameras_"+itos(vp.get_id());
canvas_group_name ="__cameras_c"+itos(canvas.get_id());
@@ -272,7 +272,7 @@ void Camera2D::_notification(int p_what) {
if (is_current()) {
if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
- viewport->set_canvas_transform( Matrix32() );
+ viewport->set_canvas_transform( Transform2D() );
}
}
remove_from_group(group_name);
@@ -290,7 +290,7 @@ void Camera2D::_notification(int p_what) {
if(current)
area_axis_width = 3;
- Matrix32 inv_camera_transform = get_camera_transform().affine_inverse();
+ Transform2D inv_camera_transform = get_camera_transform().affine_inverse();
Size2 screen_size = get_viewport_rect().size;
Vector2 screen_endpoints[4]= {
@@ -300,7 +300,7 @@ void Camera2D::_notification(int p_what) {
inv_camera_transform.xform(Vector2(0, screen_size.height))
};
- Matrix32 inv_transform = get_global_transform().affine_inverse(); // undo global space
+ Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space
for(int i=0;i<4;i++) {
draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i+1)%4]), area_axis_color, area_axis_width);
@@ -375,7 +375,7 @@ void Camera2D::make_current() {
if (!is_inside_tree()) {
current=true;
} else {
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this);
}
}
@@ -383,7 +383,7 @@ void Camera2D::clear_current() {
current=false;
if (is_inside_tree()) {
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL));
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL));
}
}
@@ -573,7 +573,7 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
else
viewport=get_viewport();
- RID vp = viewport->get_viewport();
+ RID vp = viewport->get_viewport_rid();
group_name = "__cameras_"+itos(vp.get_id());
canvas_group_name ="__cameras_c"+itos(canvas.get_id());
add_to_group(group_name);
@@ -590,65 +590,65 @@ Node* Camera2D::get_custom_viewport() const {
void Camera2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Camera2D::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&Camera2D::get_offset);
- ObjectTypeDB::bind_method(_MD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode);
- ObjectTypeDB::bind_method(_MD("get_anchor_mode"),&Camera2D::get_anchor_mode);
+ ClassDB::bind_method(_MD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode);
+ ClassDB::bind_method(_MD("get_anchor_mode"),&Camera2D::get_anchor_mode);
- ObjectTypeDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating);
- ObjectTypeDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating);
+ ClassDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating);
+ ClassDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating);
- ObjectTypeDB::bind_method(_MD("make_current"),&Camera2D::make_current);
- ObjectTypeDB::bind_method(_MD("clear_current"),&Camera2D::clear_current);
- ObjectTypeDB::bind_method(_MD("_make_current"),&Camera2D::_make_current);
+ ClassDB::bind_method(_MD("make_current"),&Camera2D::make_current);
+ ClassDB::bind_method(_MD("clear_current"),&Camera2D::clear_current);
+ ClassDB::bind_method(_MD("_make_current"),&Camera2D::_make_current);
- ObjectTypeDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll);
+ ClassDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll);
- ObjectTypeDB::bind_method(_MD("_set_current","current"),&Camera2D::_set_current);
- ObjectTypeDB::bind_method(_MD("is_current"),&Camera2D::is_current);
+ ClassDB::bind_method(_MD("_set_current","current"),&Camera2D::_set_current);
+ ClassDB::bind_method(_MD("is_current"),&Camera2D::is_current);
- ObjectTypeDB::bind_method(_MD("set_limit","margin","limit"),&Camera2D::set_limit);
- ObjectTypeDB::bind_method(_MD("get_limit","margin"),&Camera2D::get_limit);
+ ClassDB::bind_method(_MD("set_limit","margin","limit"),&Camera2D::set_limit);
+ ClassDB::bind_method(_MD("get_limit","margin"),&Camera2D::get_limit);
- ObjectTypeDB::bind_method(_MD("set_limit_smoothing_enabled","limit_smoothing_enabled"),&Camera2D::set_limit_smoothing_enabled);
- ObjectTypeDB::bind_method(_MD("is_limit_smoothing_enabled"),&Camera2D::is_limit_smoothing_enabled);
+ ClassDB::bind_method(_MD("set_limit_smoothing_enabled","limit_smoothing_enabled"),&Camera2D::set_limit_smoothing_enabled);
+ ClassDB::bind_method(_MD("is_limit_smoothing_enabled"),&Camera2D::is_limit_smoothing_enabled);
- ObjectTypeDB::bind_method(_MD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled);
- ObjectTypeDB::bind_method(_MD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled);
+ ClassDB::bind_method(_MD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled);
+ ClassDB::bind_method(_MD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled);
- ObjectTypeDB::bind_method(_MD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled);
- ObjectTypeDB::bind_method(_MD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled);
+ ClassDB::bind_method(_MD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled);
+ ClassDB::bind_method(_MD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled);
- ObjectTypeDB::bind_method(_MD("set_v_offset","ofs"),&Camera2D::set_v_offset);
- ObjectTypeDB::bind_method(_MD("get_v_offset"),&Camera2D::get_v_offset);
+ ClassDB::bind_method(_MD("set_v_offset","ofs"),&Camera2D::set_v_offset);
+ ClassDB::bind_method(_MD("get_v_offset"),&Camera2D::get_v_offset);
- ObjectTypeDB::bind_method(_MD("set_h_offset","ofs"),&Camera2D::set_h_offset);
- ObjectTypeDB::bind_method(_MD("get_h_offset"),&Camera2D::get_h_offset);
+ ClassDB::bind_method(_MD("set_h_offset","ofs"),&Camera2D::set_h_offset);
+ ClassDB::bind_method(_MD("get_h_offset"),&Camera2D::get_h_offset);
- ObjectTypeDB::bind_method(_MD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin);
- ObjectTypeDB::bind_method(_MD("get_drag_margin","margin"),&Camera2D::get_drag_margin);
+ ClassDB::bind_method(_MD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin);
+ ClassDB::bind_method(_MD("get_drag_margin","margin"),&Camera2D::get_drag_margin);
- ObjectTypeDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos);
- ObjectTypeDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center);
+ ClassDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos);
+ ClassDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center);
- ObjectTypeDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom);
- ObjectTypeDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom);
+ ClassDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom);
+ ClassDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom);
- ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport);
- ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport);
+ ClassDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport);
+ ClassDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport);
- ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
- ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
+ ClassDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
+ ClassDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
- ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
- ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
+ ClassDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
+ ClassDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
- ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
- ObjectTypeDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing);
- ObjectTypeDB::bind_method(_MD("align"),&Camera2D::align);
+ ClassDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
+ ClassDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing);
+ ClassDB::bind_method(_MD("align"),&Camera2D::align);
- ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
+ ClassDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode"));
@@ -656,25 +656,26 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") );
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/top"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/right"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_RIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/bottom"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_BOTTOM);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"limit/smoothed"),_SCS("set_limit_smoothing_enabled"),_SCS("is_limit_smoothing_enabled") );
+ ADD_GROUP("Limit","limit_");
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_top"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_right"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_RIGHT);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_bottom"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_BOTTOM);
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"limit_smoothed"),_SCS("set_limit_smoothing_enabled"),_SCS("is_limit_smoothing_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") );
+ ADD_GROUP("Draw Margin","draw_margin_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
+ ADD_GROUP("Smoothing","smoothing_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing_enabled"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing_speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
- //compatibility
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") );
-
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_BOTTOM);
+ ADD_GROUP("Drag Margin","drag_margin_");
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_BOTTOM);
BIND_CONSTANT( ANCHOR_MODE_DRAG_CENTER );
@@ -712,5 +713,6 @@ Camera2D::Camera2D() {
v_drag_enabled=true;
h_ofs=0;
v_ofs=0;
+ set_notify_transform(true);
}
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index a4d6dc5b96..85d90b225a 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class Camera2D : public Node2D {
- OBJ_TYPE( Camera2D, Node2D );
+ GDCLASS( Camera2D, Node2D );
public:
enum AnchorMode {
@@ -80,7 +80,7 @@ protected:
void _set_old_smoothing(float p_enable);
protected:
- virtual Matrix32 get_camera_transform();
+ virtual Transform2D get_camera_transform();
void _notification(int p_what);
static void _bind_methods();
public:
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index ed1d606ba8..817707f96e 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,9 +42,6 @@ bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value)
if (p_name==SceneStringNames::get_singleton()->shader_shader) {
set_shader(p_value);
return true;
- } else if (p_name==SceneStringNames::get_singleton()->shading_mode) {
- set_shading_mode(ShadingMode(p_value.operator int()));
- return true;
} else {
if (shader.is_valid()) {
@@ -58,7 +55,7 @@ bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value)
}
}
if (pr) {
- VisualServer::get_singleton()->canvas_item_material_set_shader_param(material,pr,p_value);
+ VisualServer::get_singleton()->material_set_param(_get_material(),pr,p_value);
return true;
}
}
@@ -74,18 +71,14 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
r_ret=get_shader();
return true;
- } else if (p_name==SceneStringNames::get_singleton()->shading_mode) {
-
- r_ret=shading_mode;
- return true;
} else {
if (shader.is_valid()) {
StringName pr = shader->remap_param(p_name);
if (pr) {
- r_ret=VisualServer::get_singleton()->canvas_item_material_get_shader_param(material,pr);
+ r_ret=VisualServer::get_singleton()->material_get_param(_get_material(),pr);
return true;
}
}
@@ -100,7 +93,6 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
void CanvasItemMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemShader,CanvasItemShaderGraph" ) );
- p_list->push_back( PropertyInfo( Variant::INT, "shader/shading_mode",PROPERTY_HINT_ENUM,"Normal,Unshaded,Light Only") );
if (!shader.is_null()) {
@@ -119,7 +111,7 @@ void CanvasItemMaterial::set_shader(const Ref<Shader>& p_shader) {
if (shader.is_valid())
rid=shader->get_rid();
- VS::get_singleton()->canvas_item_material_set_shader(material,rid);
+ VS::get_singleton()->material_set_shader(_get_material(),rid);
_change_notify(); //properties for shader exposed
emit_changed();
}
@@ -131,42 +123,23 @@ Ref<Shader> CanvasItemMaterial::get_shader() const{
void CanvasItemMaterial::set_shader_param(const StringName& p_param,const Variant& p_value){
- VS::get_singleton()->canvas_item_material_set_shader_param(material,p_param,p_value);
+ VS::get_singleton()->material_set_param(_get_material(),p_param,p_value);
}
Variant CanvasItemMaterial::get_shader_param(const StringName& p_param) const{
- return VS::get_singleton()->canvas_item_material_get_shader_param(material,p_param);
-}
-
-RID CanvasItemMaterial::get_rid() const {
-
- return material;
-}
-
-void CanvasItemMaterial::set_shading_mode(ShadingMode p_mode) {
-
- shading_mode=p_mode;
- VS::get_singleton()->canvas_item_material_set_shading_mode(material,VS::CanvasItemShadingMode(p_mode));
+ return VS::get_singleton()->material_get_param(_get_material(),p_param);
}
-CanvasItemMaterial::ShadingMode CanvasItemMaterial::get_shading_mode() const {
- return shading_mode;
-}
void CanvasItemMaterial::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader);
- ObjectTypeDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
- ObjectTypeDB::bind_method(_MD("set_shading_mode","mode"),&CanvasItemMaterial::set_shading_mode);
- ObjectTypeDB::bind_method(_MD("get_shading_mode"),&CanvasItemMaterial::get_shading_mode);
+ ClassDB::bind_method(_MD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader);
+ ClassDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
+ ClassDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
+ ClassDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
- BIND_CONSTANT( SHADING_NORMAL );
- BIND_CONSTANT( SHADING_UNSHADED );
- BIND_CONSTANT( SHADING_ONLY_LIGHT );
}
@@ -189,13 +162,13 @@ void CanvasItemMaterial::get_argument_options(const StringName& p_function,int p
CanvasItemMaterial::CanvasItemMaterial() {
- material=VS::get_singleton()->canvas_item_material_create();
- shading_mode=SHADING_NORMAL;
+
+
}
CanvasItemMaterial::~CanvasItemMaterial(){
- VS::get_singleton()->free(material);
+
}
@@ -209,7 +182,7 @@ CanvasItemMaterial::~CanvasItemMaterial(){
-bool CanvasItem::is_visible() const {
+bool CanvasItem::is_visible_in_tree() const {
if (!is_inside_tree())
return false;
@@ -217,7 +190,7 @@ bool CanvasItem::is_visible() const {
const CanvasItem *p=this;
while(p) {
- if (p->hidden)
+ if (!p->visible)
return false;
p=p->get_parent_item();
}
@@ -226,13 +199,6 @@ bool CanvasItem::is_visible() const {
return true;
}
-bool CanvasItem::is_hidden() const {
-
- /*if (!is_inside_scene())
- return false;*/
-
- return hidden;
-}
void CanvasItem::_propagate_visibility_changed(bool p_visible) {
@@ -248,7 +214,7 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
- if (c && !c->hidden) //should the toplevels stop propagation? i think so but..
+ if (c && c->visible) //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
}
@@ -258,50 +224,35 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
void CanvasItem::show() {
- if (!hidden)
+ if (visible)
return;
-
- hidden=false;
+ visible=true;
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,true);
if (!is_inside_tree())
return;
- if (is_visible()) {
- _propagate_visibility_changed(true);
- }
+ _propagate_visibility_changed(true);
_change_notify("visibility/visible");
}
void CanvasItem::hide() {
- if (hidden)
+ if (!visible)
return;
- bool propagate=is_inside_tree() && is_visible();
- hidden=true;
+ visible=false;
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
if (!is_inside_tree())
return;
- if (propagate)
- _propagate_visibility_changed(false);
+ _propagate_visibility_changed(false);
_change_notify("visibility/visible");
}
-void CanvasItem::set_hidden(bool p_hidden) {
-
- if (hidden == p_hidden) {
- return;
- }
-
- _set_visible_(!p_hidden);
-}
-
-
Variant CanvasItem::edit_get_state() const {
@@ -338,7 +289,7 @@ void CanvasItem::_update_callback() {
VisualServer::get_singleton()->canvas_item_clear(get_canvas_item());
//todo updating = true - only allow drawing here
- if (is_visible()) { //todo optimize this!!
+ if (is_visible_in_tree()) { //todo optimize this!!
if (first_draw) {
notification(NOTIFICATION_VISIBILITY_CHANGED);
first_draw=false;
@@ -357,10 +308,10 @@ void CanvasItem::_update_callback() {
pending_update=false; // don't change to false until finished drawing (avoid recursive update)
}
-Matrix32 CanvasItem::get_global_transform_with_canvas() const {
+Transform2D CanvasItem::get_global_transform_with_canvas() const {
const CanvasItem *ci = this;
- Matrix32 xform;
+ Transform2D xform;
const CanvasItem *last_valid=NULL;
while(ci) {
@@ -374,9 +325,11 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const {
return last_valid->canvas_layer->get_transform() * xform;
else if (is_inside_tree())
return get_viewport()->get_canvas_transform() * xform;
+
+ return xform;
}
-Matrix32 CanvasItem::get_global_transform() const {
+Transform2D CanvasItem::get_global_transform() const {
if (global_invalid) {
@@ -394,42 +347,17 @@ Matrix32 CanvasItem::get_global_transform() const {
}
-
-void CanvasItem::_queue_sort_children() {
-
- if (pending_children_sort)
- return;
-
- pending_children_sort=true;
- MessageQueue::get_singleton()->push_call(this,"_sort_children");
-}
-
-void CanvasItem::_sort_children() {
-
- pending_children_sort=false;
+void CanvasItem::_toplevel_raise_self() {
if (!is_inside_tree())
return;
- for(int i=0;i<get_child_count();i++) {
-
- Node *n = get_child(i);
- CanvasItem *ci=n->cast_to<CanvasItem>();
-
- if (ci) {
- if (ci->toplevel || ci->group!="")
- continue;
- VisualServer::get_singleton()->canvas_item_raise(n->cast_to<CanvasItem>()->canvas_item);
- }
- }
-}
-
-void CanvasItem::_raise_self() {
+ if (canvas_layer)
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,canvas_layer->get_sort_index());
+ else
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_viewport()->gui_get_canvas_sort_index());
- if (!is_inside_tree())
- return;
- VisualServer::get_singleton()->canvas_item_raise(canvas_item);
}
@@ -461,14 +389,19 @@ void CanvasItem::_enter_canvas() {
group = "root_canvas"+itos(canvas.get_id());
add_to_group(group);
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
+ if (canvas_layer)
+ canvas_layer->reset_sort_index();
+ else
+ get_viewport()->gui_reset_canvas_sort_index();
+
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
CanvasItem *parent = get_parent_item();
canvas_layer=parent->canvas_layer;
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
- parent->_queue_sort_children();
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_index());
}
pending_update=false;
@@ -495,7 +428,6 @@ void CanvasItem::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
first_draw=true;
- pending_children_sort=false;
if (get_parent()) {
CanvasItem *ci = get_parent()->cast_to<CanvasItem>();
if (ci)
@@ -508,13 +440,15 @@ void CanvasItem::_notification(int p_what) {
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
+ if (!is_inside_tree())
+ break;
if (group!="") {
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
- p->_queue_sort_children();
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_index());
}
@@ -544,16 +478,16 @@ void CanvasItem::_notification(int p_what) {
}
}
-void CanvasItem::_set_visible_(bool p_visible) {
+void CanvasItem::set_visible(bool p_visible) {
if (p_visible)
show();
else
hide();
}
-bool CanvasItem::_is_visible_() const {
+bool CanvasItem::is_visible() const {
- return !is_hidden();
+ return visible;
}
@@ -569,15 +503,15 @@ void CanvasItem::update() {
MessageQueue::get_singleton()->push_call(this,"_update_callback");
}
-void CanvasItem::set_opacity(float p_opacity) {
+void CanvasItem::set_modulate(const Color& p_modulate) {
- opacity=p_opacity;
- VisualServer::get_singleton()->canvas_item_set_opacity(canvas_item,opacity);
+ modulate=p_modulate;
+ VisualServer::get_singleton()->canvas_item_set_modulate(canvas_item,modulate);
}
-float CanvasItem::get_opacity() const {
+Color CanvasItem::get_modulate() const {
- return opacity;
+ return modulate;
}
@@ -614,29 +548,17 @@ CanvasItem *CanvasItem::get_parent_item() const {
}
-void CanvasItem::set_self_opacity(float p_self_opacity) {
-
- self_opacity=p_self_opacity;
- VisualServer::get_singleton()->canvas_item_set_self_opacity(canvas_item,self_opacity);
+void CanvasItem::set_self_modulate(const Color& p_self_modulate) {
-}
-float CanvasItem::get_self_opacity() const {
+ self_modulate=p_self_modulate;
+ VisualServer::get_singleton()->canvas_item_set_self_modulate(canvas_item,self_modulate);
- return self_opacity;
}
+Color CanvasItem::get_self_modulate() const {
-void CanvasItem::set_blend_mode(BlendMode p_blend_mode) {
-
- ERR_FAIL_INDEX(p_blend_mode,5);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->canvas_item_set_blend_mode(canvas_item,VS::MaterialBlendMode(blend_mode));
-
+ return self_modulate;
}
-CanvasItem::BlendMode CanvasItem::get_blend_mode() const {
-
- return blend_mode;
-}
void CanvasItem::set_light_mask(int p_light_mask) {
@@ -752,12 +674,12 @@ void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const S
ERR_FAIL();
}
- Matrix32 xform(p_rot,p_offset);
+ Transform2D xform(p_rot,p_offset);
xform.scale_basis(p_scale);
VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,xform);
}
-void CanvasItem::draw_set_transform_matrix(const Matrix32& p_matrix) {
+void CanvasItem::draw_set_transform_matrix(const Transform2D& p_matrix) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -830,7 +752,7 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) {
p_node->global_invalid=true;
- if (!p_node->xform_change.in_list()) {
+ if (notify_transform && !p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) {
if (p_node->is_inside_tree())
get_tree()->xform_change_list.add(&p_node->xform_change);
@@ -896,7 +818,7 @@ Ref<World2D> CanvasItem::get_world_2d() const {
RID CanvasItem::get_viewport_rid() const {
ERR_FAIL_COND_V(!is_inside_tree(),RID());
- return get_viewport()->get_viewport();
+ return get_viewport()->get_viewport_rid();
}
void CanvasItem::set_block_transform_notify(bool p_enable) {
@@ -913,7 +835,7 @@ void CanvasItem::set_draw_behind_parent(bool p_enable) {
if (behind==p_enable)
return;
behind=p_enable;
- VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,!behind);
+ VisualServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item,behind);
}
@@ -953,7 +875,7 @@ Vector2 CanvasItem::make_canvas_pos_local(const Vector2& screen_point) const {
ERR_FAIL_COND_V(!is_inside_tree(),screen_point);
- Matrix32 local_matrix = (get_canvas_transform() *
+ Transform2D local_matrix = (get_canvas_transform() *
get_global_transform()).affine_inverse();
return local_matrix.xform(screen_point);
@@ -983,101 +905,102 @@ Vector2 CanvasItem::get_local_mouse_pos() const{
void CanvasItem::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children);
- ObjectTypeDB::bind_method(_MD("_raise_self"),&CanvasItem::_raise_self);
- ObjectTypeDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
- ObjectTypeDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_);
- ObjectTypeDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);
-
- ObjectTypeDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
- ObjectTypeDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
- ObjectTypeDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
- ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate);
-
- ObjectTypeDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect);
- ObjectTypeDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect);
- //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
-
- ObjectTypeDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item);
-
- ObjectTypeDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible);
- ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden);
- ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show);
- ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide);
- ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden);
-
- ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update);
-
- ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
- ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);
-
- ObjectTypeDB::bind_method(_MD("set_blend_mode","blend_mode"),&CanvasItem::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&CanvasItem::get_blend_mode);
-
- ObjectTypeDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask);
- ObjectTypeDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask);
-
- ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&CanvasItem::set_opacity);
- ObjectTypeDB::bind_method(_MD("get_opacity"),&CanvasItem::get_opacity);
- ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity);
- ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity);
-
- ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent);
- ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);
-
- ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
- ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
- //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
-
- ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width","antialiased"),&CanvasItem::draw_line,DEFVAL(1.0),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect);
- ObjectTypeDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
- ObjectTypeDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1)));
- ObjectTypeDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
- ObjectTypeDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0));
- ObjectTypeDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1)));
-
- ObjectTypeDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
- ObjectTypeDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix);
- ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
- ObjectTypeDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform);
- ObjectTypeDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas);
- ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
- ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
- ObjectTypeDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
- ObjectTypeDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos);
- ObjectTypeDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos);
- ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
- ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
- //ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
-
- ObjectTypeDB::bind_method(_MD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material);
- ObjectTypeDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material);
-
- ObjectTypeDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
- ObjectTypeDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
-
- ObjectTypeDB::bind_method(_MD("make_canvas_pos_local","screen_point"),
+ ClassDB::bind_method(_MD("_toplevel_raise_self"),&CanvasItem::_toplevel_raise_self);
+ ClassDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
+
+ ClassDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
+ ClassDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
+ ClassDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
+ ClassDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate);
+
+ ClassDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect);
+ ClassDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect);
+ //ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
+
+ ClassDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item);
+
+ ClassDB::bind_method(_MD("set_visible"),&CanvasItem::set_visible);
+ ClassDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible);
+ ClassDB::bind_method(_MD("is_visible_in_tree"),&CanvasItem::is_visible_in_tree);
+ ClassDB::bind_method(_MD("show"),&CanvasItem::show);
+ ClassDB::bind_method(_MD("hide"),&CanvasItem::hide);
+
+ ClassDB::bind_method(_MD("update"),&CanvasItem::update);
+
+ ClassDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
+ ClassDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);
+
+ ClassDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask);
+ ClassDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask);
+
+ ClassDB::bind_method(_MD("set_modulate","modulate"),&CanvasItem::set_modulate);
+ ClassDB::bind_method(_MD("get_modulate"),&CanvasItem::get_modulate);
+ ClassDB::bind_method(_MD("set_self_modulate","self_modulate"),&CanvasItem::set_self_modulate);
+ ClassDB::bind_method(_MD("get_self_modulate"),&CanvasItem::get_self_modulate);
+
+ ClassDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent);
+ ClassDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);
+
+ ClassDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
+ ClassDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
+ //ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
+
+ ClassDB::bind_method(_MD("draw_line","from","to","color","width","antialiased"),&CanvasItem::draw_line,DEFVAL(1.0),DEFVAL(false));
+ ClassDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect);
+ ClassDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
+ ClassDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1)));
+ ClassDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
+ ClassDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0));
+ ClassDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1));
+ ClassDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1)));
+
+ ClassDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
+ ClassDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix);
+ ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
+ ClassDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform);
+ ClassDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas);
+ ClassDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
+ ClassDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
+ ClassDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
+ ClassDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos);
+ ClassDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos);
+ ClassDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
+ ClassDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
+ //ClassDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
+
+ ClassDB::bind_method(_MD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material);
+ ClassDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material);
+
+ ClassDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
+ ClassDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
+
+ ClassDB::bind_method(_MD("set_notify_local_transform","enable"),&CanvasItem::set_notify_local_transform);
+ ClassDB::bind_method(_MD("is_local_transform_notification_enabled"),&CanvasItem::is_local_transform_notification_enabled);
+
+ ClassDB::bind_method(_MD("set_notify_transform","enable"),&CanvasItem::set_notify_transform);
+ ClassDB::bind_method(_MD("is_transform_notification_enabled"),&CanvasItem::is_transform_notification_enabled);
+
+ ClassDB::bind_method(_MD("make_canvas_pos_local","screen_point"),
&CanvasItem::make_canvas_pos_local);
- ObjectTypeDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
+ ClassDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
BIND_VMETHOD(MethodInfo("_draw"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
- ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
- ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
-
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material/material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"material/use_parent"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") );
+ ADD_GROUP("Visibility","");
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("set_visible"),_SCS("is_visible") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"self_modulate"), _SCS("set_self_modulate"),_SCS("get_self_modulate") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"show_behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER), _SCS("set_light_mask"),_SCS("get_light_mask") );
+
+ ADD_GROUP("Material","");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"use_parent_material"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") );
//exporting these two things doesn't really make much sense i think
//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
@@ -1105,9 +1028,9 @@ void CanvasItem::_bind_methods() {
}
-Matrix32 CanvasItem::get_canvas_transform() const {
+Transform2D CanvasItem::get_canvas_transform() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Matrix32());
+ ERR_FAIL_COND_V(!is_inside_tree(),Transform2D());
if (canvas_layer)
return canvas_layer->get_transform();
@@ -1118,9 +1041,9 @@ Matrix32 CanvasItem::get_canvas_transform() const {
}
-Matrix32 CanvasItem::get_viewport_transform() const {
+Transform2D CanvasItem::get_viewport_transform() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Matrix32());
+ ERR_FAIL_COND_V(!is_inside_tree(),Transform2D());
if (canvas_layer) {
@@ -1145,6 +1068,15 @@ bool CanvasItem::is_local_transform_notification_enabled() const {
return notify_local_transform;
}
+
+void CanvasItem::set_notify_transform(bool p_enable) {
+ notify_transform=p_enable;
+}
+
+bool CanvasItem::is_transform_notification_enabled() const {
+ return notify_transform;
+}
+
int CanvasItem::get_canvas_layer() const {
if (canvas_layer)
@@ -1174,22 +1106,21 @@ CanvasItem::CanvasItem() : xform_change(this) {
canvas_item=VisualServer::get_singleton()->canvas_item_create();
- hidden=false;
+ visible=true;
pending_update=false;
- opacity=1;
- self_opacity=1;
+ modulate=Color(1,1,1,1);
+ self_modulate=Color(1,1,1,1);
toplevel=false;
- pending_children_sort=false;
first_draw=false;
- blend_mode=BLEND_MODE_MIX;
drawing=false;
behind=false;
- block_transform_notify=false;
-// viewport=NULL;
+ block_transform_notify=false;
+ //viewport=NULL;
canvas_layer=NULL;
use_parent_material=false;
global_invalid=true;
notify_local_transform=false;
+ notify_transform=false;
light_mask=1;
C=NULL;
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 7849a66185..9688b873c0 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,6 +33,7 @@
#include "scene/resources/texture.h"
#include "scene/main/scene_main_loop.h"
#include "scene/resources/shader.h"
+#include "scene/resources/material.h"
class CanvasLayer;
class Viewport;
@@ -40,22 +41,18 @@ class Font;
class StyleBox;
-class CanvasItemMaterial : public Resource{
+class CanvasItemMaterial : public Material {
- OBJ_TYPE(CanvasItemMaterial,Resource);
- RID material;
+ GDCLASS(CanvasItemMaterial,Material);
Ref<Shader> shader;
public:
- enum ShadingMode {
+ /*enum ShadingMode {
SHADING_NORMAL,
SHADING_UNSHADED,
SHADING_ONLY_LIGHT,
- };
+ };*/
protected:
-
- ShadingMode shading_mode;
-
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;
@@ -72,20 +69,16 @@ public:
void set_shader_param(const StringName& p_param,const Variant& p_value);
Variant get_shader_param(const StringName& p_param) const;
- void set_shading_mode(ShadingMode p_mode);
- ShadingMode get_shading_mode() const;
-
- virtual RID get_rid() const;
CanvasItemMaterial();
~CanvasItemMaterial();
};
-VARIANT_ENUM_CAST( CanvasItemMaterial::ShadingMode );
+
class CanvasItem : public Node {
- OBJ_TYPE( CanvasItem, Node );
+ GDCLASS( CanvasItem, Node );
public:
enum BlendMode {
@@ -107,47 +100,41 @@ private:
CanvasLayer *canvas_layer;
- float opacity;
- float self_opacity;
+ Color modulate;
+ Color self_modulate;
List<CanvasItem*> children_items;
List<CanvasItem*>::Element *C;
- BlendMode blend_mode;
int light_mask;
bool first_draw;
- bool hidden;
+ bool visible;
bool pending_update;
bool toplevel;
- bool pending_children_sort;
bool drawing;
bool block_transform_notify;
bool behind;
bool use_parent_material;
bool notify_local_transform;
+ bool notify_transform;
Ref<CanvasItemMaterial> material;
- mutable Matrix32 global_transform;
+ mutable Transform2D global_transform;
mutable bool global_invalid;
- void _raise_self();
+ void _toplevel_raise_self();
void _propagate_visibility_changed(bool p_visible);
- void _set_visible_(bool p_visible);
- bool _is_visible_() const;
void _update_callback();
void _enter_canvas();
void _exit_canvas();
- void _queue_sort_children();
- void _sort_children();
-
void _notify_transform(CanvasItem *p_node);
void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); }
@@ -185,25 +172,22 @@ public:
/* VISIBILITY */
+ void set_visible(bool p_visible);
bool is_visible() const;
- bool is_hidden() const;
+ bool is_visible_in_tree() const;
void show();
void hide();
- void set_hidden(bool p_hidden);
void update();
- void set_blend_mode(BlendMode p_blend_mode);
- BlendMode get_blend_mode() const;
-
virtual void set_light_mask(int p_light_mask);
int get_light_mask() const;
- void set_opacity(float p_opacity);
- float get_opacity() const;
+ void set_modulate(const Color& p_modulate);
+ Color get_modulate() const;
- void set_self_opacity(float p_self_opacity);
- float get_self_opacity() const;
+ void set_self_modulate(const Color& p_self_modulate);
+ Color get_self_modulate() const;
/* DRAWING API */
@@ -222,7 +206,7 @@ public:
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));
void draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale);
- void draw_set_transform_matrix(const Matrix32& p_matrix);
+ void draw_set_transform_matrix(const Transform2D& p_matrix);
/* RECT / TRANSFORM */
@@ -235,10 +219,10 @@ public:
CanvasItem *get_parent_item() const;
virtual Rect2 get_item_rect() const=0;
- virtual Matrix32 get_transform() const=0;
+ virtual Transform2D get_transform() const=0;
- virtual Matrix32 get_global_transform() const;
- virtual Matrix32 get_global_transform_with_canvas() const;
+ virtual Transform2D get_global_transform() const;
+ virtual Transform2D get_global_transform_with_canvas() const;
Rect2 get_item_and_children_rect() const;
@@ -249,8 +233,8 @@ public:
bool is_block_transform_notify_enabled() const;
- Matrix32 get_canvas_transform() const;
- Matrix32 get_viewport_transform() const;
+ Transform2D get_canvas_transform() const;
+ Transform2D get_viewport_transform() const;
Rect2 get_viewport_rect() const;
RID get_viewport_rid() const;
RID get_canvas() const;
@@ -271,6 +255,9 @@ public:
void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const;
+ void set_notify_transform(bool p_enable);
+ bool is_transform_notification_enabled() const;
+
int get_canvas_layer() const;
CanvasItem();
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index e4a0500123..138589651c 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@ void CanvasModulate::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_CANVAS) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
}
@@ -42,13 +42,13 @@ void CanvasModulate::_notification(int p_what) {
} else if (p_what==NOTIFICATION_EXIT_CANVAS) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id()));
}
} else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
} else {
@@ -62,8 +62,8 @@ void CanvasModulate::_notification(int p_what) {
void CanvasModulate::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_color","color"),&CanvasModulate::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&CanvasModulate::get_color);
+ ClassDB::bind_method(_MD("set_color","color"),&CanvasModulate::set_color);
+ ClassDB::bind_method(_MD("get_color"),&CanvasModulate::get_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
}
@@ -83,7 +83,7 @@ Color CanvasModulate::get_color() const {
String CanvasModulate::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
List<Node*> nodes;
diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h
index ed642c788d..a0bb27b1c5 100644
--- a/scene/2d/canvas_modulate.h
+++ b/scene/2d/canvas_modulate.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class CanvasModulate : public Node2D {
- OBJ_TYPE(CanvasModulate,Node2D);
+ GDCLASS(CanvasModulate,Node2D);
Color color;
protected:
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index b5a6cc435f..3668963251 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -196,7 +196,7 @@ void CollisionObject2D::_mouse_enter() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
}
- emit_signal(SceneStringNames::get_singleton()->mouse_enter);
+ emit_signal(SceneStringNames::get_singleton()->mouse_entered);
}
@@ -205,14 +205,14 @@ void CollisionObject2D::_mouse_exit() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
}
- emit_signal(SceneStringNames::get_singleton()->mouse_exit);
+ emit_signal(SceneStringNames::get_singleton()->mouse_exited);
}
void CollisionObject2D::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = this->pickable && is_inside_tree() && is_visible();
+ bool pickable = this->pickable && is_inside_tree() && is_visible_in_tree();
if (area)
Physics2DServer::get_singleton()->area_set_pickable(rid,pickable);
else
@@ -221,33 +221,35 @@ void CollisionObject2D::_update_pickable() {
void CollisionObject2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Matrix32()));
- ObjectTypeDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count);
- ObjectTypeDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape);
- ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform);
- ObjectTypeDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger);
- ObjectTypeDB::bind_method(_MD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape);
- ObjectTypeDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform);
- ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger);
- ObjectTypeDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape);
- ObjectTypeDB::bind_method(_MD("clear_shapes"),&CollisionObject2D::clear_shapes);
- ObjectTypeDB::bind_method(_MD("get_rid"),&CollisionObject2D::get_rid);
-
- ObjectTypeDB::bind_method(_MD("set_pickable","enabled"),&CollisionObject2D::set_pickable);
- ObjectTypeDB::bind_method(_MD("is_pickable"),&CollisionObject2D::is_pickable);
+ ClassDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Transform2D()));
+ ClassDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count);
+ ClassDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape);
+ ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform);
+ ClassDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger);
+ ClassDB::bind_method(_MD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape);
+ ClassDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform);
+ ClassDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger);
+ ClassDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape);
+ ClassDB::bind_method(_MD("clear_shapes"),&CollisionObject2D::clear_shapes);
+ ClassDB::bind_method(_MD("get_rid"),&CollisionObject2D::get_rid);
+
+ ClassDB::bind_method(_MD("set_pickable","enabled"),&CollisionObject2D::set_pickable);
+ ClassDB::bind_method(_MD("is_pickable"),&CollisionObject2D::is_pickable);
BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
- ADD_SIGNAL( MethodInfo("mouse_enter"));
- ADD_SIGNAL( MethodInfo("mouse_exit"));
+ ADD_SIGNAL( MethodInfo("mouse_entered"));
+ ADD_SIGNAL( MethodInfo("mouse_exited"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input/pickable"),_SCS("set_pickable"),_SCS("is_pickable"));
+ ADD_GROUP("Pickable","input_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_pickable"),_SCS("set_pickable"),_SCS("is_pickable"));
+ ADD_GROUP("","");
}
-void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform) {
+void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Transform2D& p_transform) {
ERR_FAIL_COND(p_shape.is_null());
@@ -280,10 +282,10 @@ void CollisionObject2D::set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape)
else
Physics2DServer::get_singleton()->body_set_shape(get_rid(),p_shape_idx,p_shape->get_rid());
-// _update_shapes();
+ //_update_shapes();
}
-void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_transform) {
+void CollisionObject2D::set_shape_transform(int p_shape_idx, const Transform2D& p_transform) {
ERR_FAIL_INDEX(p_shape_idx,shapes.size());
shapes[p_shape_idx].xform=p_transform;
@@ -293,7 +295,7 @@ void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_t
else
Physics2DServer::get_singleton()->body_set_shape_transform(get_rid(),p_shape_idx,p_transform);
-// _update_shapes();
+ //_update_shapes();
}
Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const {
@@ -302,9 +304,9 @@ Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const {
return shapes[p_shape_idx].shape;
}
-Matrix32 CollisionObject2D::get_shape_transform(int p_shape_idx) const {
+Transform2D CollisionObject2D::get_shape_transform(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Matrix32());
+ ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Transform2D());
return shapes[p_shape_idx].xform;
}
@@ -361,6 +363,7 @@ CollisionObject2D::CollisionObject2D() {
//owner=
+ set_notify_transform(true);
}
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index fc50c5c7cd..429b4fafe6 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,14 +34,14 @@
class CollisionObject2D : public Node2D {
- OBJ_TYPE( CollisionObject2D, Node2D );
+ GDCLASS( CollisionObject2D, Node2D );
bool area;
RID rid;
bool pickable;
struct ShapeData {
- Matrix32 xform;
+ Transform2D xform;
Ref<Shape2D> shape;
bool trigger;
@@ -78,12 +78,12 @@ public:
- void add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform=Matrix32());
+ void add_shape(const Ref<Shape2D>& p_shape, const Transform2D& p_transform=Transform2D());
int get_shape_count() const;
void set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape);
- void set_shape_transform(int p_shape_idx, const Matrix32& p_transform);
+ void set_shape_transform(int p_shape_idx, const Transform2D& p_transform);
Ref<Shape2D> get_shape(int p_shape_idx) const;
- Matrix32 get_shape_transform(int p_shape_idx) const;
+ Transform2D get_shape_transform(int p_shape_idx) const;
void set_shape_as_trigger(int p_shape_idx, bool p_trigger);
bool is_shape_set_as_trigger(int p_shape_idx) const;
void remove_shape(int p_shape_idx);
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 544f0e2088..04f096f229 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -68,16 +68,16 @@ void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {
Ref<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D );
- DVector<Vector2> segments;
+ PoolVector<Vector2> segments;
segments.resize(polygon.size()*2);
- DVector<Vector2>::Write w=segments.write();
+ PoolVector<Vector2>::Write w=segments.write();
for(int i=0;i<polygon.size();i++) {
w[(i<<1)+0]=polygon[i];
w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
}
- w=DVector<Vector2>::Write();
+ w=PoolVector<Vector2>::Write();
concave->set_segments(segments);
co->add_shape(concave,get_transform());
@@ -313,24 +313,24 @@ String CollisionPolygon2D::get_configuration_warning() const {
void CollisionPolygon2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon);
+ ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object);
+ ClassDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon);
+ ClassDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon);
- ObjectTypeDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode);
- ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode);
+ ClassDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode);
+ ClassDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode);
- ObjectTypeDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger);
- ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger);
+ ClassDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger);
+ ClassDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger);
- ObjectTypeDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range);
- ObjectTypeDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range);
+ ClassDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range);
+ ClassDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range);
- ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape);
+ ClassDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape);
+ ClassDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape);
ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),_SCS("set_build_mode"),_SCS("get_build_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index 9c0e4e0c01..dda850b41d 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
class CollisionPolygon2D : public Node2D {
- OBJ_TYPE(CollisionPolygon2D,Node2D);
+ GDCLASS(CollisionPolygon2D,Node2D);
public:
enum BuildMode {
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index c737cf0faf..a92065d6fb 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -217,17 +217,17 @@ String CollisionShape2D::get_configuration_warning() const {
void CollisionShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shape","shape"),&CollisionShape2D::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&CollisionShape2D::get_shape);
- ObjectTypeDB::bind_method(_MD("_shape_changed"),&CollisionShape2D::_shape_changed);
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_trigger","enable"),&CollisionShape2D::set_trigger);
- ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionShape2D::is_trigger);
+ ClassDB::bind_method(_MD("set_shape","shape"),&CollisionShape2D::set_shape);
+ ClassDB::bind_method(_MD("get_shape"),&CollisionShape2D::get_shape);
+ ClassDB::bind_method(_MD("_shape_changed"),&CollisionShape2D::_shape_changed);
+ ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object);
+ ClassDB::bind_method(_MD("set_trigger","enable"),&CollisionShape2D::set_trigger);
+ ClassDB::bind_method(_MD("is_trigger"),&CollisionShape2D::is_trigger);
- ObjectTypeDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index);
- ObjectTypeDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index);
+ ClassDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index);
+ ClassDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index);
- ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index);
+ ClassDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index);
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),_SCS("set_shape"),_SCS("get_shape"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 6f3f17d412..b5cc789416 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class CollisionShape2D : public Node2D {
- OBJ_TYPE(CollisionShape2D,Node2D);
+ GDCLASS(CollisionShape2D,Node2D);
Ref<Shape2D> shape;
Rect2 rect;
bool trigger;
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 053fc2c9c2..987672df38 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -128,22 +128,22 @@ bool Joint2D::get_exclude_nodes_from_collision() const{
void Joint2D::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("set_node_a","node"), &Joint2D::set_node_a );
- ObjectTypeDB::bind_method( _MD("get_node_a"), &Joint2D::get_node_a );
+ ClassDB::bind_method( _MD("set_node_a","node"), &Joint2D::set_node_a );
+ ClassDB::bind_method( _MD("get_node_a"), &Joint2D::get_node_a );
- ObjectTypeDB::bind_method( _MD("set_node_b","node"), &Joint2D::set_node_b );
- ObjectTypeDB::bind_method( _MD("get_node_b"), &Joint2D::get_node_b );
+ ClassDB::bind_method( _MD("set_node_b","node"), &Joint2D::set_node_b );
+ ClassDB::bind_method( _MD("get_node_b"), &Joint2D::get_node_b );
- ObjectTypeDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias );
- ObjectTypeDB::bind_method( _MD("get_bias"), &Joint2D::get_bias );
+ ClassDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias );
+ ClassDB::bind_method( _MD("get_bias"), &Joint2D::get_bias );
- ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
- ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
+ ClassDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
+ ClassDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disable_collision"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
}
@@ -225,8 +225,8 @@ real_t PinJoint2D::get_softness() const {
void PinJoint2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness);
- ObjectTypeDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness);
+ ClassDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness);
+ ClassDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness);
ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), _SCS("set_softness"), _SCS("get_softness"));
}
@@ -283,7 +283,7 @@ RID GrooveJoint2D::_configure_joint(){
else
Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
- Matrix32 gt = get_global_transform();
+ Transform2D gt = get_global_transform();
Vector2 groove_A1 = gt.get_origin();
Vector2 groove_A2 = gt.xform( Vector2(0,length) );
Vector2 anchor_B = gt.xform( Vector2(0,initial_offset) );
@@ -321,10 +321,10 @@ real_t GrooveJoint2D::get_initial_offset() const {
void GrooveJoint2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_length","length"),&GrooveJoint2D::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&GrooveJoint2D::get_length);
- ObjectTypeDB::bind_method(_MD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset);
- ObjectTypeDB::bind_method(_MD("get_initial_offset"),&GrooveJoint2D::get_initial_offset);
+ ClassDB::bind_method(_MD("set_length","length"),&GrooveJoint2D::set_length);
+ ClassDB::bind_method(_MD("get_length"),&GrooveJoint2D::get_length);
+ ClassDB::bind_method(_MD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset);
+ ClassDB::bind_method(_MD("get_initial_offset"),&GrooveJoint2D::get_initial_offset);
ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length"));
ADD_PROPERTY( PropertyInfo( Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_initial_offset"),_SCS("get_initial_offset"));
@@ -384,7 +384,7 @@ RID DampedSpringJoint2D::_configure_joint(){
else
Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
- Matrix32 gt = get_global_transform();
+ Transform2D gt = get_global_transform();
Vector2 anchor_A = gt.get_origin();
Vector2 anchor_B = gt.xform( Vector2(0,length) );
@@ -453,14 +453,14 @@ real_t DampedSpringJoint2D::get_damping() const {
void DampedSpringJoint2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_length","length"),&DampedSpringJoint2D::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&DampedSpringJoint2D::get_length);
- ObjectTypeDB::bind_method(_MD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length);
- ObjectTypeDB::bind_method(_MD("get_rest_length"),&DampedSpringJoint2D::get_rest_length);
- ObjectTypeDB::bind_method(_MD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness);
- ObjectTypeDB::bind_method(_MD("get_stiffness"),&DampedSpringJoint2D::get_stiffness);
- ObjectTypeDB::bind_method(_MD("set_damping","damping"),&DampedSpringJoint2D::set_damping);
- ObjectTypeDB::bind_method(_MD("get_damping"),&DampedSpringJoint2D::get_damping);
+ ClassDB::bind_method(_MD("set_length","length"),&DampedSpringJoint2D::set_length);
+ ClassDB::bind_method(_MD("get_length"),&DampedSpringJoint2D::get_length);
+ ClassDB::bind_method(_MD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length);
+ ClassDB::bind_method(_MD("get_rest_length"),&DampedSpringJoint2D::get_rest_length);
+ ClassDB::bind_method(_MD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness);
+ ClassDB::bind_method(_MD("get_stiffness"),&DampedSpringJoint2D::get_stiffness);
+ ClassDB::bind_method(_MD("set_damping","damping"),&DampedSpringJoint2D::set_damping);
+ ClassDB::bind_method(_MD("get_damping"),&DampedSpringJoint2D::get_damping);
ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length"));
ADD_PROPERTY( PropertyInfo( Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE,"0,65535,1"), _SCS("set_rest_length"),_SCS("get_rest_length"));
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index 52ffd86e7c..3b3eec6bd6 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Joint2D : public Node2D {
- OBJ_TYPE(Joint2D,Node2D);
+ GDCLASS(Joint2D,Node2D);
RID joint;
@@ -75,7 +75,7 @@ public:
class PinJoint2D : public Joint2D {
- OBJ_TYPE(PinJoint2D,Joint2D);
+ GDCLASS(PinJoint2D,Joint2D);
real_t softness;
@@ -94,7 +94,7 @@ public:
class GrooveJoint2D : public Joint2D {
- OBJ_TYPE(GrooveJoint2D,Joint2D);
+ GDCLASS(GrooveJoint2D,Joint2D);
real_t length;
real_t initial_offset;
@@ -117,7 +117,7 @@ public:
class DampedSpringJoint2D : public Joint2D {
- OBJ_TYPE(DampedSpringJoint2D,Joint2D);
+ GDCLASS(DampedSpringJoint2D,Joint2D);
real_t stiffness;
real_t damping;
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index f37cef673d..2935f6b9f7 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -67,7 +67,23 @@ void Light2D::_update_light_visibility() {
if (!is_inside_tree())
return;
- VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible());
+ bool editor_ok=true;
+
+#ifdef TOOLS_ENABLED
+ if (editor_only) {
+ if (!get_tree()->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()));
+ }
+ }
+#else
+ if (editor_only) {
+ editor_ok=false;
+ }
+#endif
+
+ VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible_in_tree() && editor_ok);
}
void Light2D::set_enabled( bool p_enabled) {
@@ -82,6 +98,17 @@ bool Light2D::is_enabled() const {
return enabled;
}
+void Light2D::set_editor_only(bool p_editor_only) {
+
+ editor_only=p_editor_only;
+ _update_light_visibility();
+}
+
+bool Light2D::is_editor_only() const{
+
+ return editor_only;
+}
+
void Light2D::set_texture( const Ref<Texture>& p_texture) {
texture=p_texture;
@@ -208,26 +235,26 @@ int Light2D::get_layer_range_max() const {
return layer_max;
}
-void Light2D::set_item_mask( int p_mask) {
+void Light2D::set_item_cull_mask( int p_mask) {
item_mask=p_mask;
- VS::get_singleton()->canvas_light_set_item_mask(canvas_light,item_mask);
+ VS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light,item_mask);
}
-int Light2D::get_item_mask() const {
+int Light2D::get_item_cull_mask() const {
return item_mask;
}
-void Light2D::set_item_shadow_mask( int p_mask) {
+void Light2D::set_item_shadow_cull_mask( int p_mask) {
item_shadow_mask=p_mask;
- VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light,item_shadow_mask);
+ VS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light,item_shadow_mask);
}
-int Light2D::get_item_shadow_mask() const {
+int Light2D::get_item_shadow_cull_mask() const {
return item_shadow_mask;
}
@@ -265,17 +292,30 @@ int Light2D::get_shadow_buffer_size() const {
return shadow_buffer_size;
}
-void Light2D::set_shadow_esm_multiplier( float p_multiplier) {
+void Light2D::set_shadow_gradient_length( float p_multiplier) {
- shadow_esm_multiplier=p_multiplier;
- VS::get_singleton()->canvas_light_set_shadow_esm_multiplier(canvas_light,p_multiplier);
+ shadow_gradient_length=p_multiplier;
+ VS::get_singleton()->canvas_light_set_shadow_gradient_length(canvas_light,p_multiplier);
}
-float Light2D::get_shadow_esm_multiplier() const{
+float Light2D::get_shadow_gradient_length() const{
- return shadow_esm_multiplier;
+ return shadow_gradient_length;
}
+
+void Light2D::set_shadow_filter( ShadowFilter p_filter) {
+ shadow_filter=p_filter;
+ VS::get_singleton()->canvas_light_set_shadow_filter(canvas_light,VS::CanvasLightShadowFilter(p_filter ));
+}
+
+Light2D::ShadowFilter Light2D::get_shadow_filter() const {
+
+ return shadow_filter;
+}
+
+
+
void Light2D::set_shadow_color( const Color& p_shadow_color) {
shadow_color=p_shadow_color;
VS::get_singleton()->canvas_light_set_shadow_color(canvas_light,shadow_color);
@@ -325,81 +365,92 @@ String Light2D::get_configuration_warning() const {
void Light2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled);
+
+ ClassDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only );
+ ClassDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only );
+
+ ClassDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture);
+ ClassDB::bind_method(_MD("get_texture"),&Light2D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture"),&Light2D::get_texture);
+ ClassDB::bind_method(_MD("set_texture_offset","texture_offset"),&Light2D::set_texture_offset);
+ ClassDB::bind_method(_MD("get_texture_offset"),&Light2D::get_texture_offset);
- ObjectTypeDB::bind_method(_MD("set_texture_offset","texture_offset"),&Light2D::set_texture_offset);
- ObjectTypeDB::bind_method(_MD("get_texture_offset"),&Light2D::get_texture_offset);
+ ClassDB::bind_method(_MD("set_color","color"),&Light2D::set_color);
+ ClassDB::bind_method(_MD("get_color"),&Light2D::get_color);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&Light2D::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&Light2D::get_color);
+ ClassDB::bind_method(_MD("set_height","height"),&Light2D::set_height);
+ ClassDB::bind_method(_MD("get_height"),&Light2D::get_height);
- ObjectTypeDB::bind_method(_MD("set_height","height"),&Light2D::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&Light2D::get_height);
+ ClassDB::bind_method(_MD("set_energy","energy"),&Light2D::set_energy);
+ ClassDB::bind_method(_MD("get_energy"),&Light2D::get_energy);
- ObjectTypeDB::bind_method(_MD("set_energy","energy"),&Light2D::set_energy);
- ObjectTypeDB::bind_method(_MD("get_energy"),&Light2D::get_energy);
+ ClassDB::bind_method(_MD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale);
+ ClassDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_scale);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_scale);
+ ClassDB::bind_method(_MD("set_z_range_min","z"),&Light2D::set_z_range_min);
+ ClassDB::bind_method(_MD("get_z_range_min"),&Light2D::get_z_range_min);
- ObjectTypeDB::bind_method(_MD("set_z_range_min","z"),&Light2D::set_z_range_min);
- ObjectTypeDB::bind_method(_MD("get_z_range_min"),&Light2D::get_z_range_min);
+ ClassDB::bind_method(_MD("set_z_range_max","z"),&Light2D::set_z_range_max);
+ ClassDB::bind_method(_MD("get_z_range_max"),&Light2D::get_z_range_max);
- ObjectTypeDB::bind_method(_MD("set_z_range_max","z"),&Light2D::set_z_range_max);
- ObjectTypeDB::bind_method(_MD("get_z_range_max"),&Light2D::get_z_range_max);
+ ClassDB::bind_method(_MD("set_layer_range_min","layer"),&Light2D::set_layer_range_min);
+ ClassDB::bind_method(_MD("get_layer_range_min"),&Light2D::get_layer_range_min);
- ObjectTypeDB::bind_method(_MD("set_layer_range_min","layer"),&Light2D::set_layer_range_min);
- ObjectTypeDB::bind_method(_MD("get_layer_range_min"),&Light2D::get_layer_range_min);
+ ClassDB::bind_method(_MD("set_layer_range_max","layer"),&Light2D::set_layer_range_max);
+ ClassDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max);
- ObjectTypeDB::bind_method(_MD("set_layer_range_max","layer"),&Light2D::set_layer_range_max);
- ObjectTypeDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max);
+ ClassDB::bind_method(_MD("set_item_cull_mask","item_cull_mask"),&Light2D::set_item_cull_mask);
+ ClassDB::bind_method(_MD("get_item_cull_mask"),&Light2D::get_item_cull_mask);
- ObjectTypeDB::bind_method(_MD("set_item_mask","item_mask"),&Light2D::set_item_mask);
- ObjectTypeDB::bind_method(_MD("get_item_mask"),&Light2D::get_item_mask);
+ ClassDB::bind_method(_MD("set_item_shadow_cull_mask","item_shadow_cull_mask"),&Light2D::set_item_shadow_cull_mask);
+ ClassDB::bind_method(_MD("get_item_shadow_cull_mask"),&Light2D::get_item_shadow_cull_mask);
- ObjectTypeDB::bind_method(_MD("set_item_shadow_mask","item_shadow_mask"),&Light2D::set_item_shadow_mask);
- ObjectTypeDB::bind_method(_MD("get_item_shadow_mask"),&Light2D::get_item_shadow_mask);
+ ClassDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode);
+ ClassDB::bind_method(_MD("get_mode"),&Light2D::get_mode);
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&Light2D::get_mode);
+ ClassDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled);
+ ClassDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled);
- ObjectTypeDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled);
- ObjectTypeDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled);
+ ClassDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
+ ClassDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
- ObjectTypeDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
- ObjectTypeDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
+ ClassDB::bind_method(_MD("set_shadow_gradient_length","multiplier"),&Light2D::set_shadow_gradient_length);
+ ClassDB::bind_method(_MD("get_shadow_gradient_length"),&Light2D::get_shadow_gradient_length);
- ObjectTypeDB::bind_method(_MD("set_shadow_esm_multiplier","multiplier"),&Light2D::set_shadow_esm_multiplier);
- ObjectTypeDB::bind_method(_MD("get_shadow_esm_multiplier"),&Light2D::get_shadow_esm_multiplier);
+ ClassDB::bind_method(_MD("set_shadow_filter","filter"),&Light2D::set_shadow_filter);
+ ClassDB::bind_method(_MD("get_shadow_filter"),&Light2D::get_shadow_filter);
- ObjectTypeDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color);
- ObjectTypeDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color);
+ ClassDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color);
+ ClassDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color);
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "editor_only"),_SCS("set_editor_only"),_SCS("is_editor_only"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),_SCS("set_energy"),_SCS("get_energy"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_mask"),_SCS("get_item_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow/enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow/color"),_SCS("set_shadow_color"),_SCS("get_shadow_color"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/esm_multiplier",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_esm_multiplier"),_SCS("get_shadow_esm_multiplier"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_shadow_mask"),_SCS("get_item_shadow_mask"));
+ ADD_GROUP("Range","range_");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"range_height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_item_cull_mask"),_SCS("get_item_cull_mask"));
+
+ ADD_GROUP("Shadow","shadow_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow_enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow_color"),_SCS("set_shadow_color"),_SCS("get_shadow_color"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_gradient_length",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_gradient_length"),_SCS("get_shadow_gradient_length"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_filter",PROPERTY_HINT_ENUM,"None,PCF3,PCF5,PCF9,PCF13"),_SCS("set_shadow_filter"),_SCS("get_shadow_filter"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_item_shadow_cull_mask"),_SCS("get_item_shadow_cull_mask"));
BIND_CONSTANT( MODE_ADD );
BIND_CONSTANT( MODE_SUB );
@@ -413,6 +464,7 @@ Light2D::Light2D() {
canvas_light=VisualServer::get_singleton()->canvas_light_create();
enabled=true;
+ editor_only=false;
shadow=false;
color=Color(1,1,1);
height=0;
@@ -425,10 +477,12 @@ Light2D::Light2D() {
item_shadow_mask=1;
mode=MODE_ADD;
shadow_buffer_size=2048;
- shadow_esm_multiplier=80;
+ shadow_gradient_length=0;
energy=1.0;
shadow_color=Color(0,0,0,0);
+ shadow_filter=SHADOW_FILTER_NONE;
+ set_notify_transform(true);
}
Light2D::~Light2D() {
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index c03ef96eff..2bdcca5d01 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Light2D : public Node2D {
- OBJ_TYPE(Light2D,Node2D);
+ GDCLASS(Light2D,Node2D);
public:
enum Mode {
MODE_ADD,
@@ -42,9 +42,18 @@ public:
MODE_MASK,
};
+ enum ShadowFilter {
+ SHADOW_FILTER_NONE,
+ SHADOW_FILTER_PCF3,
+ SHADOW_FILTER_PCF5,
+ SHADOW_FILTER_PCF9,
+ SHADOW_FILTER_PCF13,
+ };
+
private:
RID canvas_light;
bool enabled;
+ bool editor_only;
bool shadow;
Color color;
Color shadow_color;
@@ -58,10 +67,12 @@ private:
int item_mask;
int item_shadow_mask;
int shadow_buffer_size;
- float shadow_esm_multiplier;
+ float shadow_gradient_length;
Mode mode;
Ref<Texture> texture;
Vector2 texture_offset;
+ ShadowFilter shadow_filter;
+
void _update_light_visibility();
protected:
@@ -78,6 +89,9 @@ public:
void set_enabled( bool p_enabled);
bool is_enabled() const;
+ void set_editor_only(bool p_editor_only);
+ bool is_editor_only() const;
+
void set_texture( const Ref<Texture>& p_texture);
Ref<Texture> get_texture() const;
@@ -108,11 +122,11 @@ public:
void set_layer_range_max( int p_max_layer);
int get_layer_range_max() const;
- void set_item_mask( int p_mask);
- int get_item_mask() const;
+ void set_item_cull_mask( int p_mask);
+ int get_item_cull_mask() const;
- void set_item_shadow_mask( int p_mask);
- int get_item_shadow_mask() const;
+ void set_item_shadow_cull_mask( int p_mask);
+ int get_item_shadow_cull_mask() const;
void set_mode( Mode p_mode );
Mode get_mode() const;
@@ -123,8 +137,11 @@ public:
void set_shadow_buffer_size( int p_size );
int get_shadow_buffer_size() const;
- void set_shadow_esm_multiplier( float p_multiplier);
- float get_shadow_esm_multiplier() const;
+ void set_shadow_gradient_length( float p_multiplier);
+ float get_shadow_gradient_length() const;
+
+ void set_shadow_filter( ShadowFilter p_filter);
+ ShadowFilter get_shadow_filter() const;
void set_shadow_color( const Color& p_shadow_color);
Color get_shadow_color() const;
@@ -139,5 +156,7 @@ public:
};
VARIANT_ENUM_CAST(Light2D::Mode);
+VARIANT_ENUM_CAST(Light2D::ShadowFilter);
+
#endif // LIGHT_2D_H
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index 58c3e2191e..77c9b8184a 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,14 +29,14 @@
#include "light_occluder_2d.h"
-void OccluderPolygon2D::set_polygon(const DVector<Vector2>& p_polygon) {
+void OccluderPolygon2D::set_polygon(const PoolVector<Vector2>& p_polygon) {
polygon=p_polygon;
VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,p_polygon,closed);
emit_changed();
}
-DVector<Vector2> OccluderPolygon2D::get_polygon() const{
+PoolVector<Vector2> OccluderPolygon2D::get_polygon() const{
return polygon;
}
@@ -78,18 +78,18 @@ RID OccluderPolygon2D::get_rid() const {
void OccluderPolygon2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed);
- ObjectTypeDB::bind_method(_MD("is_closed"),&OccluderPolygon2D::is_closed);
+ ClassDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed);
+ ClassDB::bind_method(_MD("is_closed"),&OccluderPolygon2D::is_closed);
- ObjectTypeDB::bind_method(_MD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode);
- ObjectTypeDB::bind_method(_MD("get_cull_mode"),&OccluderPolygon2D::get_cull_mode);
+ ClassDB::bind_method(_MD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode);
+ ClassDB::bind_method(_MD("get_cull_mode"),&OccluderPolygon2D::get_cull_mode);
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&OccluderPolygon2D::get_polygon);
+ ClassDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon);
+ ClassDB::bind_method(_MD("get_polygon"),&OccluderPolygon2D::get_polygon);
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),_SCS("set_closed"),_SCS("is_closed"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
BIND_CONSTANT(CULL_DISABLED);
BIND_CONSTANT(CULL_CLOCKWISE);
@@ -123,7 +123,7 @@ void LightOccluder2D::_notification(int p_what) {
VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas());
VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree());
}
if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
@@ -132,7 +132,7 @@ void LightOccluder2D::_notification(int p_what) {
}
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree());
}
if (p_what==NOTIFICATION_DRAW) {
@@ -141,7 +141,7 @@ void LightOccluder2D::_notification(int p_what) {
if (occluder_polygon.is_valid()) {
- DVector<Vector2> poly = occluder_polygon->get_polygon();
+ PoolVector<Vector2> poly = occluder_polygon->get_polygon();
if (poly.size()) {
if (occluder_polygon->is_closed()) {
@@ -151,7 +151,7 @@ void LightOccluder2D::_notification(int p_what) {
} else {
int ps=poly.size();
- DVector<Vector2>::Read r = poly.read();
+ PoolVector<Vector2>::Read r = poly.read();
for(int i=0;i<ps-1;i++) {
draw_line(r[i],r[i+1],Color(0,0,0,0.6),3);
@@ -224,24 +224,25 @@ String LightOccluder2D::get_configuration_warning() const {
void LightOccluder2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon);
- ObjectTypeDB::bind_method(_MD("get_occluder_polygon:OccluderPolygon2D"),&LightOccluder2D::get_occluder_polygon);
+ ClassDB::bind_method(_MD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon);
+ ClassDB::bind_method(_MD("get_occluder_polygon:OccluderPolygon2D"),&LightOccluder2D::get_occluder_polygon);
- ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask);
- ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask);
+ ClassDB::bind_method(_MD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask);
+ ClassDB::bind_method(_MD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask);
#ifdef DEBUG_ENABLED
- ObjectTypeDB::bind_method("_poly_changed",&LightOccluder2D::_poly_changed);
+ ClassDB::bind_method("_poly_changed",&LightOccluder2D::_poly_changed);
#endif
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"),_SCS("set_occluder_polygon"),_SCS("get_occluder_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
}
LightOccluder2D::LightOccluder2D() {
occluder=VS::get_singleton()->canvas_light_occluder_create();
mask=1;
+ set_notify_transform(true);
}
LightOccluder2D::~LightOccluder2D() {
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
index 69ed860a84..777785cd1d 100644
--- a/scene/2d/light_occluder_2d.h
+++ b/scene/2d/light_occluder_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class OccluderPolygon2D : public Resource {
- OBJ_TYPE(OccluderPolygon2D,Resource);
+ GDCLASS(OccluderPolygon2D,Resource);
public:
enum CullMode {
@@ -45,7 +45,7 @@ private:
RID occ_polygon;
- DVector<Vector2> polygon;
+ PoolVector<Vector2> polygon;
bool closed;
CullMode cull;
@@ -54,8 +54,8 @@ protected:
static void _bind_methods();
public:
- void set_polygon(const DVector<Vector2>& p_polygon);
- DVector<Vector2> get_polygon() const;
+ void set_polygon(const PoolVector<Vector2>& p_polygon);
+ PoolVector<Vector2> get_polygon() const;
void set_closed(bool p_closed);
bool is_closed() const;
@@ -72,7 +72,7 @@ public:
VARIANT_ENUM_CAST(OccluderPolygon2D::CullMode);
class LightOccluder2D : public Node2D {
- OBJ_TYPE(LightOccluder2D,Node2D);
+ GDCLASS(LightOccluder2D,Node2D);
RID occluder;
bool enabled;
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index 82c1327a8f..03c2c698eb 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,12 +36,12 @@ void Navigation2D::_navpoly_link(int p_id) {
NavMesh &nm=navpoly_map[p_id];
ERR_FAIL_COND(nm.linked);
- DVector<Vector2> vertices=nm.navpoly->get_vertices();
+ PoolVector<Vector2> vertices=nm.navpoly->get_vertices();
int len = vertices.size();
if (len==0)
return;
- DVector<Vector2>::Read r=vertices.read();
+ PoolVector<Vector2>::Read r=vertices.read();
for(int i=0;i<nm.navpoly->get_polygon_count();i++) {
@@ -212,7 +212,7 @@ void Navigation2D::_navpoly_unlink(int p_id) {
}
-int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Matrix32& p_xform, Object *p_owner) {
+int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Transform2D& p_xform, Object *p_owner) {
int id = last_id++;
NavMesh nm;
@@ -227,7 +227,7 @@ int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Mat
return id;
}
-void Navigation2D::navpoly_set_transform(int p_id, const Matrix32& p_xform){
+void Navigation2D::navpoly_set_transform(int p_id, const Transform2D& p_xform){
ERR_FAIL_COND(!navpoly_map.has(p_id));
NavMesh &nm=navpoly_map[p_id];
@@ -432,7 +432,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
while(!found_route) {
if (open_list.size()==0) {
- // print_line("NOU OPEN LIST");
+ //print_line("NOU OPEN LIST");
break;
}
//check open list
@@ -804,13 +804,13 @@ Object* Navigation2D::get_closest_point_owner(const Vector2& p_point) {
void Navigation2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform);
- ObjectTypeDB::bind_method(_MD("navpoly_remove","id"),&Navigation2D::navpoly_remove);
+ ClassDB::bind_method(_MD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform);
+ ClassDB::bind_method(_MD("navpoly_remove","id"),&Navigation2D::navpoly_remove);
- ObjectTypeDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("get_closest_point","to_point"),&Navigation2D::get_closest_point);
- ObjectTypeDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner);
+ ClassDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true));
+ ClassDB::bind_method(_MD("get_closest_point","to_point"),&Navigation2D::get_closest_point);
+ ClassDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner);
}
diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h
index 415470295b..63827ebb6d 100644
--- a/scene/2d/navigation2d.h
+++ b/scene/2d/navigation2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Navigation2D : public Node2D {
- OBJ_TYPE( Navigation2D, Node2D);
+ GDCLASS( Navigation2D, Node2D);
union Point {
@@ -119,7 +119,7 @@ class Navigation2D : public Node2D {
struct NavMesh {
Object *owner;
- Matrix32 xform;
+ Transform2D xform;
bool linked;
Ref<NavigationPolygon> navpoly;
List<Polygon> polygons;
@@ -164,8 +164,8 @@ protected:
public:
//API should be as dynamic as possible
- int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Matrix32& p_xform,Object* p_owner=NULL);
- void navpoly_set_transform(int p_id, const Matrix32& p_xform);
+ int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Transform2D& p_xform,Object* p_owner=NULL);
+ void navpoly_set_transform(int p_id, const Transform2D& p_xform);
void navpoly_remove(int p_id);
Vector<Vector2> get_simple_path(const Vector2& p_start, const Vector2& p_end,bool p_optimize=true);
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 95f71104d0..012120d023 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,12 +31,12 @@
#include "triangulator.h"
#include "core_string_names.h"
-void NavigationPolygon::set_vertices(const DVector<Vector2>& p_vertices) {
+void NavigationPolygon::set_vertices(const PoolVector<Vector2>& p_vertices) {
vertices=p_vertices;
}
-DVector<Vector2> NavigationPolygon::get_vertices() const{
+PoolVector<Vector2> NavigationPolygon::get_vertices() const{
return vertices;
}
@@ -89,7 +89,7 @@ void NavigationPolygon::add_polygon(const Vector<int>& p_polygon){
}
-void NavigationPolygon::add_outline_at_index(const DVector<Vector2>& p_outline,int p_index) {
+void NavigationPolygon::add_outline_at_index(const PoolVector<Vector2>& p_outline,int p_index) {
outlines.insert(p_index,p_outline);
}
@@ -108,7 +108,7 @@ void NavigationPolygon::clear_polygons(){
polygons.clear();
}
-void NavigationPolygon::add_outline(const DVector<Vector2>& p_outline) {
+void NavigationPolygon::add_outline(const PoolVector<Vector2>& p_outline) {
outlines.push_back(p_outline);
}
@@ -118,7 +118,7 @@ int NavigationPolygon::get_outline_count() const{
return outlines.size();
}
-void NavigationPolygon::set_outline(int p_idx,const DVector<Vector2>& p_outline) {
+void NavigationPolygon::set_outline(int p_idx,const PoolVector<Vector2>& p_outline) {
ERR_FAIL_INDEX(p_idx,outlines.size());
outlines[p_idx]=p_outline;
}
@@ -130,8 +130,8 @@ void NavigationPolygon::remove_outline(int p_idx) {
}
-DVector<Vector2> NavigationPolygon::get_outline(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,outlines.size(),DVector<Vector2>());
+PoolVector<Vector2> NavigationPolygon::get_outline(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx,outlines.size(),PoolVector<Vector2>());
return outlines[p_idx];
}
@@ -147,11 +147,11 @@ void NavigationPolygon::make_polygons_from_outlines(){
for(int i=0;i<outlines.size();i++) {
- DVector<Vector2> ol = outlines[i];
+ PoolVector<Vector2> ol = outlines[i];
int olsize = ol.size();
if (olsize<3)
continue;
- DVector<Vector2>::Read r=ol.read();
+ PoolVector<Vector2>::Read r=ol.read();
for(int j=0;j<olsize;j++) {
outside_point.x = MAX( r[j].x, outside_point.x );
outside_point.y = MAX( r[j].y, outside_point.y );
@@ -165,11 +165,11 @@ void NavigationPolygon::make_polygons_from_outlines(){
for(int i=0;i<outlines.size();i++) {
- DVector<Vector2> ol = outlines[i];
+ PoolVector<Vector2> ol = outlines[i];
int olsize = ol.size();
if (olsize<3)
continue;
- DVector<Vector2>::Read r=ol.read();
+ PoolVector<Vector2>::Read r=ol.read();
int interscount=0;
//test if this is an outer outline
@@ -178,11 +178,11 @@ void NavigationPolygon::make_polygons_from_outlines(){
if (i==k)
continue; //no self intersect
- DVector<Vector2> ol2 = outlines[k];
+ PoolVector<Vector2> ol2 = outlines[k];
int olsize2 = ol2.size();
if (olsize2<3)
continue;
- DVector<Vector2>::Read r2=ol2.read();
+ PoolVector<Vector2>::Read r2=ol2.read();
for(int l=0;l<olsize2;l++) {
@@ -247,30 +247,30 @@ void NavigationPolygon::make_polygons_from_outlines(){
void NavigationPolygon::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_vertices","vertices"),&NavigationPolygon::set_vertices);
- ObjectTypeDB::bind_method(_MD("get_vertices"),&NavigationPolygon::get_vertices);
+ ClassDB::bind_method(_MD("set_vertices","vertices"),&NavigationPolygon::set_vertices);
+ ClassDB::bind_method(_MD("get_vertices"),&NavigationPolygon::get_vertices);
- ObjectTypeDB::bind_method(_MD("add_polygon","polygon"),&NavigationPolygon::add_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon_count"),&NavigationPolygon::get_polygon_count);
- ObjectTypeDB::bind_method(_MD("get_polygon","idx"),&NavigationPolygon::get_polygon);
- ObjectTypeDB::bind_method(_MD("clear_polygons"),&NavigationPolygon::clear_polygons);
+ ClassDB::bind_method(_MD("add_polygon","polygon"),&NavigationPolygon::add_polygon);
+ ClassDB::bind_method(_MD("get_polygon_count"),&NavigationPolygon::get_polygon_count);
+ ClassDB::bind_method(_MD("get_polygon","idx"),&NavigationPolygon::get_polygon);
+ ClassDB::bind_method(_MD("clear_polygons"),&NavigationPolygon::clear_polygons);
- ObjectTypeDB::bind_method(_MD("add_outline","outline"),&NavigationPolygon::add_outline);
- ObjectTypeDB::bind_method(_MD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index);
- ObjectTypeDB::bind_method(_MD("get_outline_count"),&NavigationPolygon::get_outline_count);
- ObjectTypeDB::bind_method(_MD("set_outline","idx","outline"),&NavigationPolygon::set_outline);
- ObjectTypeDB::bind_method(_MD("get_outline","idx"),&NavigationPolygon::get_outline);
- ObjectTypeDB::bind_method(_MD("remove_outline","idx"),&NavigationPolygon::remove_outline);
- ObjectTypeDB::bind_method(_MD("clear_outlines"),&NavigationPolygon::clear_outlines);
- ObjectTypeDB::bind_method(_MD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines);
+ ClassDB::bind_method(_MD("add_outline","outline"),&NavigationPolygon::add_outline);
+ ClassDB::bind_method(_MD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index);
+ ClassDB::bind_method(_MD("get_outline_count"),&NavigationPolygon::get_outline_count);
+ ClassDB::bind_method(_MD("set_outline","idx","outline"),&NavigationPolygon::set_outline);
+ ClassDB::bind_method(_MD("get_outline","idx"),&NavigationPolygon::get_outline);
+ ClassDB::bind_method(_MD("remove_outline","idx"),&NavigationPolygon::remove_outline);
+ ClassDB::bind_method(_MD("clear_outlines"),&NavigationPolygon::clear_outlines);
+ ClassDB::bind_method(_MD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines);
- ObjectTypeDB::bind_method(_MD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons);
- ObjectTypeDB::bind_method(_MD("_get_polygons"),&NavigationPolygon::_get_polygons);
+ ClassDB::bind_method(_MD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons);
+ ClassDB::bind_method(_MD("_get_polygons"),&NavigationPolygon::_get_polygons);
- ObjectTypeDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines);
- ObjectTypeDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines);
+ ClassDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines);
+ ClassDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons"));
ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"outlines",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_outlines"),_SCS("_get_outlines"));
}
@@ -310,7 +310,7 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
update();
-// update_gizmo();
+ //update_gizmo();
}
bool NavigationPolygonInstance::is_enabled() const {
@@ -368,7 +368,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
- DVector<Vector2> verts=navpoly->get_vertices();
+ PoolVector<Vector2> verts=navpoly->get_vertices();
int vsize = verts.size();
if (vsize<3)
return;
@@ -385,7 +385,7 @@ void NavigationPolygonInstance::_notification(int p_what) {
vertices.resize(vsize);
colors.resize(vsize);
{
- DVector<Vector2>::Read vr = verts.read();
+ PoolVector<Vector2>::Read vr = verts.read();
for(int i=0;i<vsize;i++) {
vertices[i]=vr[i];
colors[i]=color;
@@ -459,7 +459,7 @@ void NavigationPolygonInstance::_navpoly_changed() {
String NavigationPolygonInstance::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!navpoly.is_valid()) {
@@ -480,13 +480,13 @@ String NavigationPolygonInstance::get_configuration_warning() const {
void NavigationPolygonInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon);
+ ClassDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon);
+ ClassDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled);
- ObjectTypeDB::bind_method(_MD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed);
+ ClassDB::bind_method(_MD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navpoly",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"),_SCS("set_navigation_polygon"),_SCS("get_navigation_polygon"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
@@ -497,5 +497,6 @@ NavigationPolygonInstance::NavigationPolygonInstance() {
navigation=NULL;
nav_id=-1;
enabled=true;
+ set_notify_transform(true);
}
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h
index c40933cf7a..7f1762b6f5 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_polygon.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,14 +34,14 @@
class NavigationPolygon : public Resource {
- OBJ_TYPE( NavigationPolygon, Resource );
+ GDCLASS( NavigationPolygon, Resource );
- DVector<Vector2> vertices;
+ PoolVector<Vector2> vertices;
struct Polygon {
Vector<int> indices;
};
Vector<Polygon> polygons;
- Vector< DVector<Vector2> > outlines;
+ Vector< PoolVector<Vector2> > outlines;
protected:
@@ -57,16 +57,16 @@ public:
- void set_vertices(const DVector<Vector2>& p_vertices);
- DVector<Vector2> get_vertices() const;
+ void set_vertices(const PoolVector<Vector2>& p_vertices);
+ PoolVector<Vector2> get_vertices() const;
void add_polygon(const Vector<int>& p_polygon);
int get_polygon_count() const;
- void add_outline(const DVector<Vector2>& p_outline);
- void add_outline_at_index(const DVector<Vector2>& p_outline,int p_index);
- void set_outline(int p_idx,const DVector<Vector2>& p_outline);
- DVector<Vector2> get_outline(int p_idx) const;
+ void add_outline(const PoolVector<Vector2>& p_outline);
+ void add_outline_at_index(const PoolVector<Vector2>& p_outline,int p_index);
+ void set_outline(int p_idx,const PoolVector<Vector2>& p_outline);
+ PoolVector<Vector2> get_outline(int p_idx) const;
void remove_outline(int p_idx);
int get_outline_count() const;
@@ -84,7 +84,7 @@ class Navigation2D;
class NavigationPolygonInstance : public Node2D {
- OBJ_TYPE(NavigationPolygonInstance,Node2D);
+ GDCLASS(NavigationPolygonInstance,Node2D);
bool enabled;
int nav_id;
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index b3f925cb14..fb71a5b536 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -51,8 +51,8 @@ bool Node2D::edit_has_pivot() const {
Variant Node2D::edit_get_state() const {
Array state;
- state.push_back(get_pos());
- state.push_back(get_rot());
+ state.push_back(get_position());
+ state.push_back(get_rotation());
state.push_back(get_scale());
return state;
@@ -92,7 +92,7 @@ void Node2D::edit_set_rect(const Rect2& p_edit_rect) {
Point2 new_pos = p_edit_rect.pos + p_edit_rect.size*zero_offset;//p_edit_rect.pos - r.pos;
- Matrix32 postxf;
+ Transform2D postxf;
postxf.set_rotation_and_scale(angle,_scale);
new_pos = postxf.xform(new_pos);
@@ -124,7 +124,7 @@ void Node2D::_update_xform_values() {
void Node2D::_update_transform() {
- Matrix32 mat(angle,pos);
+ Transform2D mat(angle,pos);
_mat.set_rotation_and_scale(angle,_scale);
_mat.elements[2]=pos;
@@ -137,7 +137,7 @@ void Node2D::_update_transform() {
_notify_transform();
}
-void Node2D::set_pos(const Point2& p_pos) {
+void Node2D::set_position(const Point2& p_pos) {
if (_xform_dirty)
((Node2D*)this)->_update_xform_values();
@@ -148,7 +148,7 @@ void Node2D::set_pos(const Point2& p_pos) {
}
-void Node2D::set_rot(float p_radians) {
+void Node2D::set_rotation(float p_radians) {
if (_xform_dirty)
((Node2D*)this)->_update_xform_values();
@@ -157,9 +157,9 @@ void Node2D::set_rot(float p_radians) {
_change_notify("transform/rot");
}
-void Node2D::set_rotd(float p_degrees) {
+void Node2D::set_rotation_in_degrees(float p_degrees) {
- set_rot(Math::deg2rad(p_degrees));
+ set_rotation(Math::deg2rad(p_degrees));
}
// Kept for compatibility after rename to set_rotd.
@@ -167,7 +167,7 @@ void Node2D::set_rotd(float p_degrees) {
void Node2D::_set_rotd(float p_degrees) {
WARN_PRINT("Deprecated method Node2D._set_rotd(): This method was renamed to set_rotd. Please adapt your code accordingly, as the old method will be obsoleted.");
- set_rotd(p_degrees);
+ set_rotation_in_degrees(p_degrees);
}
void Node2D::set_scale(const Size2& p_scale) {
@@ -184,28 +184,28 @@ void Node2D::set_scale(const Size2& p_scale) {
}
-Point2 Node2D::get_pos() const {
+Point2 Node2D::get_position() const {
if (_xform_dirty)
((Node2D*)this)->_update_xform_values();
return pos;
}
-float Node2D::get_rot() const {
+float Node2D::get_rotation() const {
if (_xform_dirty)
((Node2D*)this)->_update_xform_values();
return angle;
}
-float Node2D::get_rotd() const {
+float Node2D::get_rotation_in_degrees() const {
- return Math::rad2deg(get_rot());
+ return Math::rad2deg(get_rotation());
}
// Kept for compatibility after rename to get_rotd.
// Could be removed after a couple releases.
float Node2D::_get_rotd() const {
WARN_PRINT("Deprecated method Node2D._get_rotd(): This method was renamed to get_rotd. Please adapt your code accordingly, as the old method will be obsoleted.");
- return get_rotd();
+ return get_rotation_in_degrees();
}
Size2 Node2D::get_scale() const {
if (_xform_dirty)
@@ -222,7 +222,7 @@ void Node2D::_notification(int p_what) {
}
}
-Matrix32 Node2D::get_transform() const {
+Transform2D Node2D::get_transform() const {
return _mat;
}
@@ -240,17 +240,17 @@ Rect2 Node2D::get_item_rect() const {
void Node2D::rotate(float p_radians) {
- set_rot( get_rot() + p_radians);
+ set_rotation( get_rotation() + p_radians);
}
void Node2D::translate(const Vector2& p_amount) {
- set_pos( get_pos() + p_amount );
+ set_position( get_position() + p_amount );
}
void Node2D::global_translate(const Vector2& p_amount) {
- set_global_pos( get_global_pos() + p_amount );
+ set_global_position( get_global_position() + p_amount );
}
void Node2D::scale(const Size2& p_amount) {
@@ -261,66 +261,66 @@ void Node2D::scale(const Size2& p_amount) {
void Node2D::move_x(float p_delta,bool p_scaled){
- Matrix32 t = get_transform();
+ Transform2D t = get_transform();
Vector2 m = t[0];
if (!p_scaled)
m.normalize();
- set_pos(t[2]+m*p_delta);
+ set_position(t[2]+m*p_delta);
}
void Node2D::move_y(float p_delta,bool p_scaled){
- Matrix32 t = get_transform();
+ Transform2D t = get_transform();
Vector2 m = t[1];
if (!p_scaled)
m.normalize();
- set_pos(t[2]+m*p_delta);
+ set_position(t[2]+m*p_delta);
}
-Point2 Node2D::get_global_pos() const {
+Point2 Node2D::get_global_position() const {
return get_global_transform().get_origin();
}
-void Node2D::set_global_pos(const Point2& p_pos) {
+void Node2D::set_global_position(const Point2& p_pos) {
- Matrix32 inv;
+ Transform2D inv;
CanvasItem *pi = get_parent_item();
if (pi) {
inv = pi->get_global_transform().affine_inverse();
- set_pos(inv.xform(p_pos));
+ set_position(inv.xform(p_pos));
} else {
- set_pos(p_pos);
+ set_position(p_pos);
}
}
-float Node2D::get_global_rot() const {
+float Node2D::get_global_rotation() const {
return get_global_transform().get_rotation();
}
-void Node2D::set_global_rot(float p_radians) {
+void Node2D::set_global_rotation(float p_radians) {
CanvasItem *pi = get_parent_item();
if (pi) {
const float parent_global_rot = pi->get_global_transform().get_rotation();
- set_rot(p_radians - parent_global_rot);
+ set_rotation(p_radians - parent_global_rot);
} else {
- set_rot(p_radians);
+ set_rotation(p_radians);
}
}
-float Node2D::get_global_rotd() const {
+float Node2D::get_global_rotation_in_degrees() const {
- return Math::rad2deg(get_global_rot());
+ return Math::rad2deg(get_global_rotation());
}
-void Node2D::set_global_rotd(float p_degrees) {
+void Node2D::set_global_rotation_in_degrees(float p_degrees) {
- set_global_rot(Math::deg2rad(p_degrees));
+ set_global_rotation(Math::deg2rad(p_degrees));
}
@@ -342,7 +342,7 @@ void Node2D::set_global_scale(const Size2& p_scale) {
}
-void Node2D::set_transform(const Matrix32& p_transform) {
+void Node2D::set_transform(const Transform2D& p_transform) {
_mat=p_transform;
_xform_dirty=true;
@@ -355,7 +355,7 @@ void Node2D::set_transform(const Matrix32& p_transform) {
_notify_transform();
}
-void Node2D::set_global_transform(const Matrix32& p_transform) {
+void Node2D::set_global_transform(const Transform2D& p_transform) {
CanvasItem *pi = get_parent_item();
if (pi)
@@ -394,14 +394,14 @@ int Node2D::get_z() const{
return z;
}
-Matrix32 Node2D::get_relative_transform_to_parent(const Node *p_parent) const {
+Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const {
if (p_parent==this)
- return Matrix32();
+ return Transform2D();
Node2D *parent_2d = get_parent()->cast_to<Node2D>();
- ERR_FAIL_COND_V(!parent_2d,Matrix32());
+ ERR_FAIL_COND_V(!parent_2d,Transform2D());
if (p_parent==parent_2d)
return get_transform();
else
@@ -423,56 +423,67 @@ void Node2D::_bind_methods() {
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_get_rotd"),&Node2D::_get_rotd);
- ObjectTypeDB::bind_method(_MD("_set_rotd","degrees"),&Node2D::_set_rotd);
-
- ObjectTypeDB::bind_method(_MD("set_pos","pos"),&Node2D::set_pos);
- ObjectTypeDB::bind_method(_MD("set_rot","radians"),&Node2D::set_rot);
- ObjectTypeDB::bind_method(_MD("set_rotd","degrees"),&Node2D::set_rotd);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Node2D::set_scale);
-
- ObjectTypeDB::bind_method(_MD("get_pos"),&Node2D::get_pos);
- ObjectTypeDB::bind_method(_MD("get_rot"),&Node2D::get_rot);
- ObjectTypeDB::bind_method(_MD("get_rotd"),&Node2D::get_rotd);
- ObjectTypeDB::bind_method(_MD("get_scale"),&Node2D::get_scale);
-
- ObjectTypeDB::bind_method(_MD("rotate","radians"),&Node2D::rotate);
- ObjectTypeDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("translate","offset"),&Node2D::translate);
- ObjectTypeDB::bind_method(_MD("global_translate","offset"),&Node2D::global_translate);
- ObjectTypeDB::bind_method(_MD("scale","ratio"),&Node2D::scale);
-
- ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Node2D::set_global_pos);
- ObjectTypeDB::bind_method(_MD("get_global_pos"),&Node2D::get_global_pos);
- ObjectTypeDB::bind_method(_MD("set_global_rot","radians"),&Node2D::set_global_rot);
- ObjectTypeDB::bind_method(_MD("get_global_rot"),&Node2D::get_global_rot);
- ObjectTypeDB::bind_method(_MD("set_global_rotd","degrees"),&Node2D::set_global_rotd);
- ObjectTypeDB::bind_method(_MD("get_global_rotd"),&Node2D::get_global_rotd);
- ObjectTypeDB::bind_method(_MD("set_global_scale","scale"),&Node2D::set_global_scale);
- ObjectTypeDB::bind_method(_MD("get_global_scale"),&Node2D::get_global_scale);
-
- ObjectTypeDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform);
- ObjectTypeDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform);
-
- ObjectTypeDB::bind_method(_MD("look_at","point"),&Node2D::look_at);
- ObjectTypeDB::bind_method(_MD("get_angle_to","point"),&Node2D::get_angle_to);
-
- ObjectTypeDB::bind_method(_MD("set_z","z"),&Node2D::set_z);
- ObjectTypeDB::bind_method(_MD("get_z"),&Node2D::get_z);
-
- ObjectTypeDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
- ObjectTypeDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative);
-
- ObjectTypeDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot);
-
- ObjectTypeDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent);
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("set_rotd"),_SCS("get_rotd"));
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"transform/scale"),_SCS("set_scale"),_SCS("get_scale"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z/z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z"));
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z/relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative"));
+ ClassDB::bind_method(_MD("_get_rotd"),&Node2D::_get_rotd);
+ ClassDB::bind_method(_MD("_set_rotd","degrees"),&Node2D::_set_rotd);
+
+ ClassDB::bind_method(_MD("set_position","pos"),&Node2D::set_position);
+ ClassDB::bind_method(_MD("set_rotation","radians"),&Node2D::set_rotation);
+ ClassDB::bind_method(_MD("set_rotation_in_degrees","degrees"),&Node2D::set_rotation_in_degrees);
+ ClassDB::bind_method(_MD("set_scale","scale"),&Node2D::set_scale);
+
+ ClassDB::bind_method(_MD("get_position"),&Node2D::get_position);
+ ClassDB::bind_method(_MD("get_rotation"),&Node2D::get_rotation);
+ ClassDB::bind_method(_MD("get_rotation_in_degrees"),&Node2D::get_rotation_in_degrees);
+ ClassDB::bind_method(_MD("get_scale"),&Node2D::get_scale);
+
+ ClassDB::bind_method(_MD("rotate","radians"),&Node2D::rotate);
+ ClassDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
+ ClassDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
+ ClassDB::bind_method(_MD("translate","offset"),&Node2D::translate);
+ ClassDB::bind_method(_MD("global_translate","offset"),&Node2D::global_translate);
+ ClassDB::bind_method(_MD("scale","ratio"),&Node2D::scale);
+
+ ClassDB::bind_method(_MD("set_global_position","pos"),&Node2D::set_global_position);
+ ClassDB::bind_method(_MD("get_global_position"),&Node2D::get_global_position);
+ ClassDB::bind_method(_MD("set_global_rotation","radians"),&Node2D::set_global_rotation);
+ ClassDB::bind_method(_MD("get_global_rotation"),&Node2D::get_global_rotation);
+ ClassDB::bind_method(_MD("set_global_rotation_in_degrees","degrees"),&Node2D::set_global_rotation_in_degrees);
+ ClassDB::bind_method(_MD("get_global_rotation_in_degrees"),&Node2D::get_global_rotation_in_degrees);
+ ClassDB::bind_method(_MD("set_global_scale","scale"),&Node2D::set_global_scale);
+ ClassDB::bind_method(_MD("get_global_scale"),&Node2D::get_global_scale);
+
+ ClassDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform);
+ ClassDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform);
+
+ ClassDB::bind_method(_MD("look_at","point"),&Node2D::look_at);
+ ClassDB::bind_method(_MD("get_angle_to","point"),&Node2D::get_angle_to);
+
+ ClassDB::bind_method(_MD("set_z","z"),&Node2D::set_z);
+ ClassDB::bind_method(_MD("get_z"),&Node2D::get_z);
+
+ ClassDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
+ ClassDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative);
+
+ ClassDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot);
+
+ ClassDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent);
+
+ ADD_GROUP("Transform","");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"position"),_SCS("set_position"),_SCS("get_position"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_rotation"),_SCS("get_rotation"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation_deg",PROPERTY_HINT_RANGE,"-1440,1440,0.1",PROPERTY_USAGE_EDITOR),_SCS("set_rotation_in_degrees"),_SCS("get_rotation_in_degrees"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"transform",PROPERTY_HINT_NONE,"",0),_SCS("set_transform"),_SCS("get_transform"));
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_position",PROPERTY_HINT_NONE,"",0),_SCS("set_global_position"),_SCS("get_global_position"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation"),_SCS("get_global_rotation"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation_deg",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation_in_degrees"),_SCS("get_global_rotation_in_degrees"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_scale",PROPERTY_HINT_NONE,"",0),_SCS("set_global_scale"),_SCS("get_global_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"global_transform",PROPERTY_HINT_NONE,"",0),_SCS("set_global_transform"),_SCS("get_global_transform"));
+
+ ADD_GROUP("Z","");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z_as_relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative"));
}
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index b31ee08af6..2cceef0f06 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Node2D : public CanvasItem {
- OBJ_TYPE(Node2D, CanvasItem );
+ GDCLASS(Node2D, CanvasItem );
Point2 pos;
float angle;
@@ -41,7 +41,7 @@ class Node2D : public CanvasItem {
int z;
bool z_relative;
- Matrix32 _mat;
+ Transform2D _mat;
bool _xform_dirty;
@@ -69,9 +69,9 @@ public:
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
- void set_pos(const Point2& p_pos);
- void set_rot(float p_radians);
- void set_rotd(float p_degrees);
+ void set_position(const Point2& p_pos);
+ void set_rotation(float p_radians);
+ void set_rotation_in_degrees(float p_degrees);
void set_scale(const Size2& p_scale);
void rotate(float p_radians);
@@ -81,22 +81,22 @@ public:
void global_translate(const Vector2& p_amount);
void scale(const Size2& p_amount);
- Point2 get_pos() const;
- float get_rot() const;
- float get_rotd() const;
+ Point2 get_position() const;
+ float get_rotation() const;
+ float get_rotation_in_degrees() const;
Size2 get_scale() const;
- Point2 get_global_pos() const;
- float get_global_rot() const;
- float get_global_rotd() const;
+ Point2 get_global_position() const;
+ float get_global_rotation() const;
+ float get_global_rotation_in_degrees() const;
Size2 get_global_scale() const;
virtual Rect2 get_item_rect() const;
- void set_transform(const Matrix32& p_transform);
- void set_global_transform(const Matrix32& p_transform);
- void set_global_pos(const Point2& p_pos);
- void set_global_rot(float p_radians);
- void set_global_rotd(float p_degrees);
+ void set_transform(const Transform2D& p_transform);
+ void set_global_transform(const Transform2D& p_transform);
+ void set_global_position(const Point2& p_pos);
+ void set_global_rotation(float p_radians);
+ void set_global_rotation_in_degrees(float p_degrees);
void set_global_scale(const Size2& p_scale);
void set_z(int p_z);
@@ -108,9 +108,9 @@ public:
void set_z_as_relative(bool p_enabled);
bool is_z_relative() const;
- Matrix32 get_relative_transform_to_parent(const Node *p_parent) const;
+ Transform2D get_relative_transform_to_parent(const Node *p_parent) const;
- Matrix32 get_transform() const;
+ Transform2D get_transform() const;
Node2D();
};
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 1b6ab66fcc..1e6a449fce 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -50,7 +50,7 @@ void ParallaxBackground::_notification(int p_what) {
}
-void ParallaxBackground::_camera_moved(const Matrix32& p_transform) {
+void ParallaxBackground::_camera_moved(const Transform2D& p_transform) {
set_scroll_offset(p_transform.get_origin());
@@ -189,27 +189,28 @@ Vector2 ParallaxBackground::get_final_offset() const {
void ParallaxBackground::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
- ObjectTypeDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset);
- ObjectTypeDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset);
- ObjectTypeDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset);
- ObjectTypeDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset);
- ObjectTypeDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale);
- ObjectTypeDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale);
- ObjectTypeDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin);
- ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
- ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
- ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
- ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
- ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
-
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
+ ClassDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
+ ClassDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset);
+ ClassDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset);
+ ClassDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset);
+ ClassDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset);
+ ClassDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale);
+ ClassDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale);
+ ClassDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin);
+ ClassDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
+ ClassDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
+ ClassDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
+ ClassDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
+ ClassDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
+
+
+ ADD_GROUP("Scroll","scroll_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll_ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
}
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index c00cd52f26..caef4962e8 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class ParallaxBackground : public CanvasLayer {
- OBJ_TYPE( ParallaxBackground, CanvasLayer );
+ GDCLASS( ParallaxBackground, CanvasLayer );
Point2 offset;
float scale;
@@ -50,7 +50,7 @@ class ParallaxBackground : public CanvasLayer {
void _update_scroll();
protected:
- void _camera_moved(const Matrix32& p_transform);
+ void _camera_moved(const Transform2D& p_transform);
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 05136de5d6..9aa6640727 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -107,7 +107,7 @@ void ParallaxLayer::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- orig_offset=get_pos();
+ orig_offset=get_position();
orig_scale=get_scale();
_update_mirroring();
} break;
@@ -132,7 +132,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2& p_offset,float p_sca
new_ofs.y -= den*ceil(new_ofs.y/den);
}
- set_pos(new_ofs);
+ set_position(new_ofs);
set_scale(Vector2(1,1)*p_scale);
@@ -150,16 +150,17 @@ String ParallaxLayer::get_configuration_warning() const {
void ParallaxLayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
- ObjectTypeDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
- ObjectTypeDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
- ObjectTypeDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
- ObjectTypeDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
- ObjectTypeDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring);
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring"));
+ ClassDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
+ ClassDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
+ ClassDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
+ ClassDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
+ ClassDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
+ ClassDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring);
+
+ ADD_GROUP("Motion","motion_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring"));
}
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index 6b1d73ea66..1b3d67af5e 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ParallaxLayer : public Node2D {
- OBJ_TYPE( ParallaxLayer, Node2D );
+ GDCLASS( ParallaxLayer, Node2D );
Point2 orig_offset;
Point2 orig_scale;
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 29dad630d6..cd99f30f6d 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -98,7 +98,7 @@ void ParticleAttractor2D::_set_owner(Particles2D* p_owner) {
return;
if (owner) {
- owner->disconnect("exit_tree",this,"_owner_exited");
+ owner->disconnect("tree_exited",this,"_owner_exited");
owner->attractors.erase(this);
owner=NULL;
}
@@ -106,30 +106,30 @@ void ParticleAttractor2D::_set_owner(Particles2D* p_owner) {
if (owner) {
- owner->connect("exit_tree",this,"_owner_exited",varray(),CONNECT_ONESHOT);
+ owner->connect("tree_exited",this,"_owner_exited",varray(),CONNECT_ONESHOT);
owner->attractors.insert(this);
}
}
void ParticleAttractor2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&ParticleAttractor2D::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&ParticleAttractor2D::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&ParticleAttractor2D::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&ParticleAttractor2D::get_radius);
+ ClassDB::bind_method(_MD("set_radius","radius"),&ParticleAttractor2D::set_radius);
+ ClassDB::bind_method(_MD("get_radius"),&ParticleAttractor2D::get_radius);
- ObjectTypeDB::bind_method(_MD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius);
- ObjectTypeDB::bind_method(_MD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius);
+ ClassDB::bind_method(_MD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius);
+ ClassDB::bind_method(_MD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius);
- ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity);
- ObjectTypeDB::bind_method(_MD("get_gravity"),&ParticleAttractor2D::get_gravity);
+ ClassDB::bind_method(_MD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity);
+ ClassDB::bind_method(_MD("get_gravity"),&ParticleAttractor2D::get_gravity);
- ObjectTypeDB::bind_method(_MD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption);
- ObjectTypeDB::bind_method(_MD("get_absorption"),&ParticleAttractor2D::get_absorption);
+ ClassDB::bind_method(_MD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption);
+ ClassDB::bind_method(_MD("get_absorption"),&ParticleAttractor2D::get_absorption);
- ObjectTypeDB::bind_method(_MD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path);
- ObjectTypeDB::bind_method(_MD("get_particles_path"),&ParticleAttractor2D::get_particles_path);
+ ClassDB::bind_method(_MD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path);
+ ClassDB::bind_method(_MD("get_particles_path"),&ParticleAttractor2D::get_particles_path);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),_SCS("set_radius"),_SCS("get_radius"));
@@ -270,13 +270,13 @@ void Particles2D::_process_particles(float p_delta) {
Particle *pdata=&particles[0];
int particle_count=particles.size();
- Matrix32 xform;
+ Transform2D xform;
if (!local_space)
xform=get_global_transform();
active_count=0;
- DVector<Point2>::Read r;
+ PoolVector<Point2>::Read r;
int emission_point_count=0;
if (emission_points.size()) {
@@ -293,13 +293,13 @@ void Particles2D::_process_particles(float p_delta) {
}
int idx=0;
- Matrix32 m;
+ Transform2D m;
if (local_space) {
m= get_global_transform().affine_inverse();
}
for (Set<ParticleAttractor2D*>::Element *E=attractors.front();E;E=E->next()) {
- attractor_cache[idx].pos=m.xform( E->get()->get_global_pos() );
+ attractor_cache[idx].pos=m.xform( E->get()->get_global_position() );
attractor_cache[idx].attractor=E->get();
idx++;
}
@@ -391,7 +391,7 @@ void Particles2D::_process_particles(float p_delta) {
float orbitvel = (param[PARAM_ORBIT_VELOCITY]+param[PARAM_ORBIT_VELOCITY]*randomness[PARAM_ORBIT_VELOCITY]*_rand_from_seed(&rand_seed));
if (orbitvel!=0) {
Vector2 rel = p.pos - xform.elements[2];
- Matrix32 rot(orbitvel*frame_time,Vector2());
+ Transform2D rot(orbitvel*frame_time,Vector2());
p.pos = rot.xform(rel) + xform.elements[2];
}
@@ -507,7 +507,7 @@ void Particles2D::_notification(int p_what) {
if (texture.is_valid())
texrid = texture->get_rid();
- Matrix32 invxform;
+ Transform2D invxform;
if (!local_space)
invxform=get_global_transform().affine_inverse();
@@ -563,7 +563,7 @@ void Particles2D::_notification(int p_what) {
}
}
- float initial_size = param[PARAM_INITIAL_SIZE]+param[PARAM_INITIAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_FINAL_SIZE];
+ float initial_size = param[PARAM_INITIAL_SIZE]+param[PARAM_INITIAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_INITIAL_SIZE];
float final_size = param[PARAM_FINAL_SIZE]+param[PARAM_FINAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_FINAL_SIZE];
float size_mult=initial_size*(1.0-ptime) + final_size*ptime;
@@ -573,7 +573,7 @@ void Particles2D::_notification(int p_what) {
//Rect2 r = Rect2(Vecto,rectsize);
- Matrix32 xform;
+ Transform2D xform;
if (p.rot) {
@@ -992,12 +992,12 @@ int Particles2D::get_v_frames() const{
-void Particles2D::set_emission_points(const DVector<Vector2>& p_points) {
+void Particles2D::set_emission_points(const PoolVector<Vector2>& p_points) {
emission_points=p_points;
}
-DVector<Vector2> Particles2D::get_emission_points() const{
+PoolVector<Vector2> Particles2D::get_emission_points() const{
return emission_points;
}
@@ -1013,80 +1013,80 @@ void Particles2D::reset() {
void Particles2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting);
- ObjectTypeDB::bind_method(_MD("is_emitting"),&Particles2D::is_emitting);
+ ClassDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting);
+ ClassDB::bind_method(_MD("is_emitting"),&Particles2D::is_emitting);
- ObjectTypeDB::bind_method(_MD("set_amount","amount"),&Particles2D::set_amount);
- ObjectTypeDB::bind_method(_MD("get_amount"),&Particles2D::get_amount);
+ ClassDB::bind_method(_MD("set_amount","amount"),&Particles2D::set_amount);
+ ClassDB::bind_method(_MD("get_amount"),&Particles2D::get_amount);
- ObjectTypeDB::bind_method(_MD("set_lifetime","lifetime"),&Particles2D::set_lifetime);
- ObjectTypeDB::bind_method(_MD("get_lifetime"),&Particles2D::get_lifetime);
+ ClassDB::bind_method(_MD("set_lifetime","lifetime"),&Particles2D::set_lifetime);
+ ClassDB::bind_method(_MD("get_lifetime"),&Particles2D::get_lifetime);
- ObjectTypeDB::bind_method(_MD("set_time_scale","time_scale"),&Particles2D::set_time_scale);
- ObjectTypeDB::bind_method(_MD("get_time_scale"),&Particles2D::get_time_scale);
+ ClassDB::bind_method(_MD("set_time_scale","time_scale"),&Particles2D::set_time_scale);
+ ClassDB::bind_method(_MD("get_time_scale"),&Particles2D::get_time_scale);
- ObjectTypeDB::bind_method(_MD("set_pre_process_time","time"),&Particles2D::set_pre_process_time);
- ObjectTypeDB::bind_method(_MD("get_pre_process_time"),&Particles2D::get_pre_process_time);
+ ClassDB::bind_method(_MD("set_pre_process_time","time"),&Particles2D::set_pre_process_time);
+ ClassDB::bind_method(_MD("get_pre_process_time"),&Particles2D::get_pre_process_time);
- ObjectTypeDB::bind_method(_MD("set_emit_timeout","value"),&Particles2D::set_emit_timeout);
- ObjectTypeDB::bind_method(_MD("get_emit_timeout"),&Particles2D::get_emit_timeout);
+ ClassDB::bind_method(_MD("set_emit_timeout","value"),&Particles2D::set_emit_timeout);
+ ClassDB::bind_method(_MD("get_emit_timeout"),&Particles2D::get_emit_timeout);
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&Particles2D::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&Particles2D::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&Particles2D::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&Particles2D::get_param);
- ObjectTypeDB::bind_method(_MD("set_randomness","param","value"),&Particles2D::set_randomness);
- ObjectTypeDB::bind_method(_MD("get_randomness","param"),&Particles2D::get_randomness);
+ ClassDB::bind_method(_MD("set_randomness","param","value"),&Particles2D::set_randomness);
+ ClassDB::bind_method(_MD("get_randomness","param"),&Particles2D::get_randomness);
- ObjectTypeDB::bind_method(_MD("set_texture:Texture","texture"),&Particles2D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Particles2D::get_texture);
+ ClassDB::bind_method(_MD("set_texture:Texture","texture"),&Particles2D::set_texture);
+ ClassDB::bind_method(_MD("get_texture:Texture"),&Particles2D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&Particles2D::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&Particles2D::get_color);
+ ClassDB::bind_method(_MD("set_color","color"),&Particles2D::set_color);
+ ClassDB::bind_method(_MD("get_color"),&Particles2D::get_color);
- ObjectTypeDB::bind_method(_MD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp);
- ObjectTypeDB::bind_method(_MD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp);
+ ClassDB::bind_method(_MD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp);
+ ClassDB::bind_method(_MD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp);
- ObjectTypeDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset);
- ObjectTypeDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset);
+ ClassDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset);
+ ClassDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h);
+ ClassDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h);
+ ClassDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v);
+ ClassDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v);
+ ClassDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_h_frames","enable"),&Particles2D::set_h_frames);
- ObjectTypeDB::bind_method(_MD("get_h_frames"),&Particles2D::get_h_frames);
+ ClassDB::bind_method(_MD("set_h_frames","enable"),&Particles2D::set_h_frames);
+ ClassDB::bind_method(_MD("get_h_frames"),&Particles2D::get_h_frames);
- ObjectTypeDB::bind_method(_MD("set_v_frames","enable"),&Particles2D::set_v_frames);
- ObjectTypeDB::bind_method(_MD("get_v_frames"),&Particles2D::get_v_frames);
+ ClassDB::bind_method(_MD("set_v_frames","enable"),&Particles2D::set_v_frames);
+ ClassDB::bind_method(_MD("get_v_frames"),&Particles2D::get_v_frames);
- ObjectTypeDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents);
+ ClassDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents);
+ ClassDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("set_color_phases","phases"),&Particles2D::set_color_phases);
- ObjectTypeDB::bind_method(_MD("get_color_phases"),&Particles2D::get_color_phases);
+ ClassDB::bind_method(_MD("set_color_phases","phases"),&Particles2D::set_color_phases);
+ ClassDB::bind_method(_MD("get_color_phases"),&Particles2D::get_color_phases);
- ObjectTypeDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color);
- ObjectTypeDB::bind_method(_MD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color);
+ ClassDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color);
+ ClassDB::bind_method(_MD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color);
- ObjectTypeDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos);
+ ClassDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos);
+ ClassDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process);
- ObjectTypeDB::bind_method(_MD("reset"),&Particles2D::reset);
+ ClassDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process);
+ ClassDB::bind_method(_MD("reset"),&Particles2D::reset);
- ObjectTypeDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space);
- ObjectTypeDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space);
+ ClassDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space);
+ ClassDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space);
- ObjectTypeDB::bind_method(_MD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity);
- ObjectTypeDB::bind_method(_MD("get_initial_velocity"),&Particles2D::get_initial_velocity);
+ ClassDB::bind_method(_MD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity);
+ ClassDB::bind_method(_MD("get_initial_velocity"),&Particles2D::get_initial_velocity);
- ObjectTypeDB::bind_method(_MD("set_explosiveness","amount"),&Particles2D::set_explosiveness);
- ObjectTypeDB::bind_method(_MD("get_explosiveness"),&Particles2D::get_explosiveness);
+ ClassDB::bind_method(_MD("set_explosiveness","amount"),&Particles2D::set_explosiveness);
+ ClassDB::bind_method(_MD("get_explosiveness"),&Particles2D::get_explosiveness);
- ObjectTypeDB::bind_method(_MD("set_emission_points","points"),&Particles2D::set_emission_points);
- ObjectTypeDB::bind_method(_MD("get_emission_points"),&Particles2D::get_emission_points);
+ ClassDB::bind_method(_MD("set_emission_points","points"),&Particles2D::set_emission_points);
+ ClassDB::bind_method(_MD("get_emission_points"),&Particles2D::get_emission_points);
ADD_PROPERTY(PropertyInfo(Variant::INT,"config/amount",PROPERTY_HINT_EXP_RANGE,"1,1024"),_SCS("set_amount"),_SCS("get_amount") );
ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/lifetime",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_lifetime"),_SCS("get_lifetime") );
@@ -1125,7 +1125,7 @@ void Particles2D::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"),_SCS("set_color"),_SCS("get_color"));
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"color/color_ramp",PROPERTY_HINT_RESOURCE_TYPE,"ColorRamp"),_SCS("set_color_ramp"),_SCS("get_color_ramp"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points"));
BIND_CONSTANT( PARAM_DIRECTION );
BIND_CONSTANT( PARAM_SPREAD );
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index b1ae1f5bc1..91f42c5222 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
class Particles2D;
class ParticleAttractor2D : public Node2D {
- OBJ_TYPE(ParticleAttractor2D,Node2D);
+ GDCLASS(ParticleAttractor2D,Node2D);
friend class Particles2D;
@@ -84,7 +84,7 @@ public:
class Particles2D : public Node2D {
- OBJ_TYPE(Particles2D, Node2D);
+ GDCLASS(Particles2D, Node2D);
public:
enum Parameter {
@@ -117,7 +117,6 @@ private:
float randomness[PARAM_MAX];
struct Particle {
-
bool active;
Point2 pos;
Vector2 velocity;
@@ -152,7 +151,7 @@ private:
Point2 emissor_offset;
Vector2 initial_velocity;
Vector2 extents;
- DVector<Vector2> emission_points;
+ PoolVector<Vector2> emission_points;
float time;
int active_count;
@@ -246,8 +245,8 @@ public:
void set_initial_velocity(const Vector2& p_velocity);
Vector2 get_initial_velocity() const;
- void set_emission_points(const DVector<Vector2>& p_points);
- DVector<Vector2> get_emission_points() const;
+ void set_emission_points(const PoolVector<Vector2>& p_points);
+ PoolVector<Vector2> get_emission_points() const;
void pre_process(float p_delta);
void reset();
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 41ca7b1d0f..e1d1920cc5 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -85,9 +85,9 @@ Ref<Curve2D> Path2D::get_curve() const{
void Path2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve2D"),&Path2D::set_curve);
- ObjectTypeDB::bind_method(_MD("get_curve:Curve2D","curve"),&Path2D::get_curve);
- ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path2D::_curve_changed);
+ ClassDB::bind_method(_MD("set_curve","curve:Curve2D"),&Path2D::set_curve);
+ ClassDB::bind_method(_MD("get_curve:Curve2D","curve"),&Path2D::get_curve);
+ ClassDB::bind_method(_MD("_curve_changed"),&Path2D::_curve_changed);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), _SCS("set_curve"),_SCS("get_curve"));
}
@@ -124,7 +124,7 @@ void PathFollow2D::_update_transform() {
pos+=n*h_offset;
pos+=t*v_offset;
- set_rot(t.angle());
+ set_rotation(t.angle());
} else {
@@ -132,7 +132,7 @@ void PathFollow2D::_update_transform() {
pos.y+=v_offset;
}
- set_pos(pos);
+ set_position(pos);
}
@@ -239,7 +239,7 @@ void PathFollow2D::_get_property_list( List<PropertyInfo> *p_list) const{
String PathFollow2D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!get_parent() || !get_parent()->cast_to<Path2D>()) {
@@ -252,26 +252,26 @@ String PathFollow2D::get_configuration_warning() const {
void PathFollow2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow2D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow2D::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&PathFollow2D::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&PathFollow2D::get_offset);
- ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset);
- ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow2D::get_h_offset);
+ ClassDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset);
+ ClassDB::bind_method(_MD("get_h_offset"),&PathFollow2D::get_h_offset);
- ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset);
- ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow2D::get_v_offset);
+ ClassDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset);
+ ClassDB::bind_method(_MD("get_v_offset"),&PathFollow2D::get_v_offset);
- ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset);
- ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow2D::get_unit_offset);
+ ClassDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset);
+ ClassDB::bind_method(_MD("get_unit_offset"),&PathFollow2D::get_unit_offset);
- ObjectTypeDB::bind_method(_MD("set_rotate","enable"),&PathFollow2D::set_rotate);
- ObjectTypeDB::bind_method(_MD("is_rotating"),&PathFollow2D::is_rotating);
+ ClassDB::bind_method(_MD("set_rotate","enable"),&PathFollow2D::set_rotate);
+ ClassDB::bind_method(_MD("is_rotating"),&PathFollow2D::is_rotating);
- ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation);
- ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation);
+ ClassDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation);
+ ClassDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation);
- ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow2D::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow2D::has_loop);
+ ClassDB::bind_method(_MD("set_loop","loop"),&PathFollow2D::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&PathFollow2D::has_loop);
}
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index 84725e7123..4fc26dbf9b 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Path2D : public Node2D {
- OBJ_TYPE( Path2D, Node2D );
+ GDCLASS( Path2D, Node2D );
Ref<Curve2D> curve;
@@ -58,7 +58,7 @@ public:
class PathFollow2D : public Node2D {
- OBJ_TYPE(PathFollow2D,Node2D);
+ GDCLASS(PathFollow2D,Node2D);
public:
diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp
index 3f7c514317..626928a244 100644
--- a/scene/2d/path_texture.cpp
+++ b/scene/2d/path_texture.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h
index 11a60b1390..cc502a2fa4 100644
--- a/scene/2d/path_texture.h
+++ b/scene/2d/path_texture.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/2d/node_2d.h"
class PathTexture : public Node2D {
- OBJ_TYPE( PathTexture, Node2D );
+ GDCLASS( PathTexture, Node2D );
Ref<Texture> begin;
Ref<Texture> repeat;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 0c5c353766..feecbd9e20 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -70,51 +70,54 @@ float PhysicsBody2D::get_one_way_collision_max_depth() const{
void PhysicsBody2D::_set_layers(uint32_t p_mask) {
- set_layer_mask(p_mask);
+ set_collision_layer(p_mask);
set_collision_mask(p_mask);
}
uint32_t PhysicsBody2D::_get_layers() const{
- return get_layer_mask();
+ return get_collision_layer();
}
void PhysicsBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask);
-
-
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit);
-
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody2D::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody2D::get_layer_mask_bit);
-
- ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers);
- ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers);
- ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
- ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
- ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
- ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
- ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
- ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ClassDB::bind_method(_MD("set_collision_layer","mask"),&PhysicsBody2D::set_collision_layer);
+ ClassDB::bind_method(_MD("get_collision_layer"),&PhysicsBody2D::get_collision_layer);
+ ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask);
+ ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask);
+
+
+ ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit);
+ ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit);
+
+ ClassDB::bind_method(_MD("set_collision_layer_bit","bit","value"),&PhysicsBody2D::set_collision_layer_bit);
+ ClassDB::bind_method(_MD("get_collision_layer_bit","bit"),&PhysicsBody2D::get_collision_layer_bit);
+
+ ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers);
+ ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers);
+ ClassDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
+ ClassDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
+ ClassDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
+ ClassDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
+ ClassDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
+ ClassDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_LAYERS_2D_PHYSICS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat
+
+ ADD_GROUP("Collision","collision_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layer",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_GROUP("","");
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction"));
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth"));
}
-void PhysicsBody2D::set_layer_mask(uint32_t p_mask) {
+void PhysicsBody2D::set_collision_layer(uint32_t p_mask) {
mask=p_mask;
Physics2DServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask);
}
-uint32_t PhysicsBody2D::get_layer_mask() const {
+uint32_t PhysicsBody2D::get_collision_layer() const {
return mask;
}
@@ -146,20 +149,20 @@ bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const{
}
-void PhysicsBody2D::set_layer_mask_bit(int p_bit, bool p_value) {
+void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) {
- uint32_t mask = get_layer_mask();
+ uint32_t mask = get_collision_layer();
if (p_value)
mask|=1<<p_bit;
else
mask&=~(1<<p_bit);
- set_layer_mask(mask);
+ set_collision_layer(mask);
}
-bool PhysicsBody2D::get_layer_mask_bit(int p_bit) const{
+bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const{
- return get_layer_mask()&(1<<p_bit);
+ return get_collision_layer()&(1<<p_bit);
}
PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) {
@@ -224,7 +227,7 @@ void StaticBody2D::_update_xform() {
setting=true;
- Matrix32 new_xform = get_global_transform(); //obtain the new one
+ 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!
@@ -268,15 +271,15 @@ real_t StaticBody2D::get_bounce() const{
void StaticBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&StaticBody2D::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&StaticBody2D::get_friction);
+ ClassDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity);
+ ClassDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity);
+ ClassDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity);
+ ClassDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity);
+ ClassDB::bind_method(_MD("set_friction","friction"),&StaticBody2D::set_friction);
+ ClassDB::bind_method(_MD("get_friction"),&StaticBody2D::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&StaticBody2D::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&StaticBody2D::get_bounce);
+ ClassDB::bind_method(_MD("set_bounce","bounce"),&StaticBody2D::set_bounce);
+ ClassDB::bind_method(_MD("get_bounce"),&StaticBody2D::get_bounce);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"constant_linear_velocity"),_SCS("set_constant_linear_velocity"),_SCS("get_constant_linear_velocity"));
ADD_PROPERTY(PropertyInfo(Variant::REAL,"constant_angular_velocity"),_SCS("set_constant_angular_velocity"),_SCS("get_constant_angular_velocity"));
@@ -313,12 +316,12 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
contact_monitor->locked=true;
E->get().in_scene=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
}
contact_monitor->locked=false;
@@ -338,11 +341,11 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
contact_monitor->locked=true;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
}
contact_monitor->locked=false;
@@ -372,13 +375,13 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (!E) {
E = contact_monitor->body_map.insert(objid,BodyState());
-// E->get().rc=0;
+ //E->get().rc=0;
E->get().in_scene=node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
if (E->get().in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
}
}
@@ -390,7 +393,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (E->get().in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,objid,node,p_body_shape,p_local_shape);
}
} else {
@@ -405,17 +408,17 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (E->get().shapes.empty()) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree);
if (in_scene)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,obj);
}
contact_monitor->body_map.erase(E);
}
if (node && in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,objid,obj,p_body_shape,p_local_shape);
}
}
@@ -491,7 +494,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
-// bool found=false;
+ //bool found=false;
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
if (!E) {
@@ -879,75 +882,75 @@ bool RigidBody2D::is_contact_monitor_enabled() const {
void RigidBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&RigidBody2D::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&RigidBody2D::get_mode);
+ ClassDB::bind_method(_MD("set_mode","mode"),&RigidBody2D::set_mode);
+ ClassDB::bind_method(_MD("get_mode"),&RigidBody2D::get_mode);
- ObjectTypeDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass);
- ObjectTypeDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass);
+ ClassDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass);
+ ClassDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass);
- ObjectTypeDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia);
- ObjectTypeDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia);
+ ClassDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia);
+ ClassDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia);
- ObjectTypeDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight);
- ObjectTypeDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight);
+ ClassDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight);
+ ClassDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&RigidBody2D::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&RigidBody2D::get_friction);
+ ClassDB::bind_method(_MD("set_friction","friction"),&RigidBody2D::set_friction);
+ ClassDB::bind_method(_MD("get_friction"),&RigidBody2D::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&RigidBody2D::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&RigidBody2D::get_bounce);
+ ClassDB::bind_method(_MD("set_bounce","bounce"),&RigidBody2D::set_bounce);
+ ClassDB::bind_method(_MD("get_bounce"),&RigidBody2D::get_bounce);
- ObjectTypeDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_scale"),&RigidBody2D::get_gravity_scale);
+ ClassDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale);
+ ClassDB::bind_method(_MD("get_gravity_scale"),&RigidBody2D::get_gravity_scale);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&RigidBody2D::get_linear_damp);
+ ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp);
+ ClassDB::bind_method(_MD("get_linear_damp"),&RigidBody2D::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&RigidBody2D::get_angular_damp);
+ ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp);
+ ClassDB::bind_method(_MD("get_angular_damp"),&RigidBody2D::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&RigidBody2D::get_linear_velocity);
+ ClassDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity);
+ ClassDB::bind_method(_MD("get_linear_velocity"),&RigidBody2D::get_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&RigidBody2D::get_angular_velocity);
+ ClassDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity);
+ ClassDB::bind_method(_MD("get_angular_velocity"),&RigidBody2D::get_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported);
+ ClassDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported);
+ ClassDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator);
- ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator);
+ ClassDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator);
+ ClassDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator);
- ObjectTypeDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor);
- ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled);
+ ClassDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor);
+ ClassDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled);
- ObjectTypeDB::bind_method(_MD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode);
- ObjectTypeDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode);
+ ClassDB::bind_method(_MD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode);
+ ClassDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode);
- ObjectTypeDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity);
- ObjectTypeDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse);
+ ClassDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity);
+ ClassDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse);
- ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
- ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
+ ClassDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
+ ClassDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
- ObjectTypeDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque);
- ObjectTypeDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque);
+ ClassDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque);
+ ClassDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque);
- ObjectTypeDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force);
+ ClassDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force);
- ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
- ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping);
+ ClassDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
+ ClassDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping);
- ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
- ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
+ ClassDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
+ ClassDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
- ObjectTypeDB::bind_method(_MD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&RigidBody2D::_direct_state_changed);
- ObjectTypeDB::bind_method(_MD("_body_enter_tree"),&RigidBody2D::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree"),&RigidBody2D::_body_exit_tree);
+ ClassDB::bind_method(_MD("_direct_state_changed"),&RigidBody2D::_direct_state_changed);
+ ClassDB::bind_method(_MD("_body_enter_tree"),&RigidBody2D::_body_enter_tree);
+ ClassDB::bind_method(_MD("_body_exit_tree"),&RigidBody2D::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies);
+ ClassDB::bind_method(_MD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies);
BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:Physics2DDirectBodyState")));
@@ -963,15 +966,17 @@ void RigidBody2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/linear",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/angular",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
-
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
+ ADD_GROUP("Linear","linear_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"linear_velocity"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
+ ADD_GROUP("Angular","angular_");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_velocity"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+
+ ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
+ ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
+ ADD_SIGNAL( MethodInfo("body_entered",PropertyInfo(Variant::OBJECT,"body")));
+ ADD_SIGNAL( MethodInfo("body_exited",PropertyInfo(Variant::OBJECT,"body")));
ADD_SIGNAL( MethodInfo("sleeping_state_changed"));
BIND_CONSTANT( MODE_STATIC );
@@ -1042,7 +1047,7 @@ Variant KinematicBody2D::_get_collider() const {
void KinematicBody2D::revert_motion() {
- Matrix32 gt = get_global_transform();
+ Transform2D gt = get_global_transform();
gt.elements[2]-=travel;
travel=Vector2();
set_global_transform(gt);
@@ -1058,7 +1063,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
#if 1
- Matrix32 gt = get_global_transform();
+ Transform2D gt = get_global_transform();
Physics2DServer::MotionResult result;
colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(),gt,p_motion,margin,&result);
@@ -1136,8 +1141,10 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
float d = a.distance_to(b);
- //if (d<margin)
- /// continue;
+ /*
+ if (d<margin)
+ continue;
+ */
recover_motion+=(b-a)*0.4;
}
@@ -1148,7 +1155,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
- Matrix32 gt = get_global_transform();
+ Transform2D gt = get_global_transform();
gt.elements[2]+=recover_motion;
set_global_transform(gt);
@@ -1199,7 +1206,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
} else {
//it collided, let's get the rest info in unsafe advance
- Matrix32 ugt = get_global_transform();
+ Transform2D ugt = get_global_transform();
ugt.elements[2]+=p_motion*unsafe;
Physics2DDirectSpaceState::ShapeRestInfo rest_info;
bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask);
@@ -1223,7 +1230,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
}
Vector2 motion=p_motion*safe;
- Matrix32 gt = get_global_transform();
+ Transform2D gt = get_global_transform();
gt.elements[2]+=motion;
set_global_transform(gt);
@@ -1311,10 +1318,10 @@ Array KinematicBody2D::get_move_and_slide_colliders() const{
Vector2 KinematicBody2D::move_to(const Vector2& p_position) {
- return move(p_position-get_global_pos());
+ return move(p_position-get_global_position());
}
-bool KinematicBody2D::test_move(const Matrix32& p_from,const Vector2& p_motion) {
+bool KinematicBody2D::test_move(const Transform2D& p_from,const Vector2& p_motion) {
ERR_FAIL_COND_V(!is_inside_tree(),false);
@@ -1381,29 +1388,29 @@ float KinematicBody2D::get_collision_margin() const{
void KinematicBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("move","rel_vec"),&KinematicBody2D::move);
- ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to);
- ObjectTypeDB::bind_method(_MD("move_and_slide","linear_velocity","floor_normal","slope_stop_min_velocity","max_bounces"),&KinematicBody2D::move_and_slide,DEFVAL(Vector2(0,0)),DEFVAL(5),DEFVAL(4));
+ ClassDB::bind_method(_MD("move","rel_vec"),&KinematicBody2D::move);
+ ClassDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to);
+ ClassDB::bind_method(_MD("move_and_slide","linear_velocity","floor_normal","slope_stop_min_velocity","max_bounces"),&KinematicBody2D::move_and_slide,DEFVAL(Vector2(0,0)),DEFVAL(5),DEFVAL(4));
- ObjectTypeDB::bind_method(_MD("test_move","from","rel_vec"),&KinematicBody2D::test_move);
- ObjectTypeDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel);
- ObjectTypeDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion);
+ ClassDB::bind_method(_MD("test_move","from","rel_vec"),&KinematicBody2D::test_move);
+ ClassDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel);
+ ClassDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding);
+ ClassDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding);
- ObjectTypeDB::bind_method(_MD("get_collision_pos"),&KinematicBody2D::get_collision_pos);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&KinematicBody2D::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity);
- ObjectTypeDB::bind_method(_MD("get_collider:Object"),&KinematicBody2D::_get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata);
- ObjectTypeDB::bind_method(_MD("get_move_and_slide_colliders"),&KinematicBody2D::get_move_and_slide_colliders);
- ObjectTypeDB::bind_method(_MD("is_move_and_slide_on_floor"),&KinematicBody2D::is_move_and_slide_on_floor);
- ObjectTypeDB::bind_method(_MD("is_move_and_slide_on_ceiling"),&KinematicBody2D::is_move_and_slide_on_ceiling);
- ObjectTypeDB::bind_method(_MD("is_move_and_slide_on_wall"),&KinematicBody2D::is_move_and_slide_on_wall);
+ ClassDB::bind_method(_MD("get_collision_pos"),&KinematicBody2D::get_collision_pos);
+ ClassDB::bind_method(_MD("get_collision_normal"),&KinematicBody2D::get_collision_normal);
+ ClassDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity);
+ ClassDB::bind_method(_MD("get_collider:Variant"),&KinematicBody2D::_get_collider);
+ ClassDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape);
+ ClassDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata);
+ ClassDB::bind_method(_MD("get_move_and_slide_colliders"),&KinematicBody2D::get_move_and_slide_colliders);
+ ClassDB::bind_method(_MD("is_move_and_slide_on_floor"),&KinematicBody2D::is_move_and_slide_on_floor);
+ ClassDB::bind_method(_MD("is_move_and_slide_on_ceiling"),&KinematicBody2D::is_move_and_slide_on_ceiling);
+ ClassDB::bind_method(_MD("is_move_and_slide_on_wall"),&KinematicBody2D::is_move_and_slide_on_wall);
- ObjectTypeDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin);
- ObjectTypeDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin);
+ ClassDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin);
+ ClassDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),_SCS("set_collision_margin"),_SCS("get_collision_margin"));
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index ea29d873bd..5b7db35fe8 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
class PhysicsBody2D : public CollisionObject2D {
- OBJ_TYPE(PhysicsBody2D,CollisionObject2D);
+ GDCLASS(PhysicsBody2D,CollisionObject2D);
uint32_t mask;
uint32_t collision_mask;
@@ -55,8 +55,8 @@ protected:
static void _bind_methods();
public:
- void set_layer_mask(uint32_t p_mask);
- uint32_t get_layer_mask() const;
+ void set_collision_layer(uint32_t p_mask);
+ uint32_t get_collision_layer() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
@@ -65,8 +65,8 @@ public:
void set_collision_mask_bit(int p_bit, bool p_value);
bool get_collision_mask_bit(int p_bit) const;
- void set_layer_mask_bit(int p_bit, bool p_value);
- bool get_layer_mask_bit(int p_bit) const;
+ void set_collision_layer_bit(int p_bit, bool p_value);
+ bool get_collision_layer_bit(int p_bit) const;
void add_collision_exception_with(Node* p_node); //must be physicsbody
void remove_collision_exception_with(Node* p_node);
@@ -83,7 +83,7 @@ public:
class StaticBody2D : public PhysicsBody2D {
- OBJ_TYPE(StaticBody2D,PhysicsBody2D);
+ GDCLASS(StaticBody2D,PhysicsBody2D);
Vector2 constant_linear_velocity;
real_t constant_angular_velocity;
@@ -118,7 +118,7 @@ public:
class RigidBody2D : public PhysicsBody2D {
- OBJ_TYPE(RigidBody2D,PhysicsBody2D);
+ GDCLASS(RigidBody2D,PhysicsBody2D);
public:
enum Mode {
@@ -290,7 +290,7 @@ VARIANT_ENUM_CAST(RigidBody2D::CCDMode);
class KinematicBody2D : public PhysicsBody2D {
- OBJ_TYPE(KinematicBody2D,PhysicsBody2D);
+ GDCLASS(KinematicBody2D,PhysicsBody2D);
float margin;
bool colliding;
@@ -319,7 +319,7 @@ public:
Vector2 move(const Vector2& p_motion);
Vector2 move_to(const Vector2& p_position);
- bool test_move(const Matrix32 &p_from, const Vector2& p_motion);
+ bool test_move(const Transform2D &p_from, const Vector2& p_motion);
bool is_colliding() const;
Vector2 get_travel() const;
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 12893524d1..30e22a8437 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@ Rect2 Polygon2D::get_item_rect() const {
if (rect_cache_dirty){
int l =polygon.size();
- DVector<Vector2>::Read r = polygon.read();
+ PoolVector<Vector2>::Read r = polygon.read();
item_rect=Rect2();
for(int i=0;i<l;i++) {
Vector2 pos = r[i] + offset;
@@ -84,7 +84,7 @@ void Polygon2D::_notification(int p_what) {
int len = points.size();
{
- DVector<Vector2>::Read polyr =polygon.read();
+ PoolVector<Vector2>::Read polyr =polygon.read();
for(int i=0;i<len;i++) {
points[i]=polyr[i]+offset;
}
@@ -148,7 +148,7 @@ void Polygon2D::_notification(int p_what) {
if (texture.is_valid()) {
- Matrix32 texmat(tex_rot,tex_ofs);
+ Transform2D texmat(tex_rot,tex_ofs);
texmat.scale(tex_scale);
Size2 tex_size=Vector2(1,1);
@@ -157,7 +157,7 @@ void Polygon2D::_notification(int p_what) {
if (points.size()==uv.size()) {
- DVector<Vector2>::Read uvr = uv.read();
+ PoolVector<Vector2>::Read uvr = uv.read();
for(int i=0;i<len;i++) {
uvs[i]=texmat.xform(uvr[i])/tex_size;
@@ -176,7 +176,7 @@ void Polygon2D::_notification(int p_what) {
int color_len=vertex_colors.size();
colors.resize(len);
{
- DVector<Color>::Read color_r=vertex_colors.read();
+ PoolVector<Color>::Read color_r=vertex_colors.read();
for(int i=0;i<color_len && i<len;i++){
colors[i]=color_r[i];
}
@@ -194,25 +194,25 @@ void Polygon2D::_notification(int p_what) {
}
-void Polygon2D::set_polygon(const DVector<Vector2>& p_polygon) {
+void Polygon2D::set_polygon(const PoolVector<Vector2>& p_polygon) {
polygon=p_polygon;
rect_cache_dirty=true;
update();
}
-DVector<Vector2> Polygon2D::get_polygon() const{
+PoolVector<Vector2> Polygon2D::get_polygon() const{
return polygon;
}
-void Polygon2D::set_uv(const DVector<Vector2>& p_uv) {
+void Polygon2D::set_uv(const PoolVector<Vector2>& p_uv) {
uv=p_uv;
update();
}
-DVector<Vector2> Polygon2D::get_uv() const{
+PoolVector<Vector2> Polygon2D::get_uv() const{
return uv;
}
@@ -227,12 +227,12 @@ Color Polygon2D::get_color() const{
return color;
}
-void Polygon2D::set_vertex_colors(const DVector<Color>& p_colors){
+void Polygon2D::set_vertex_colors(const PoolVector<Color>& p_colors){
vertex_colors=p_colors;
update();
}
-DVector<Color> Polygon2D::get_vertex_colors() const{
+PoolVector<Color> Polygon2D::get_vertex_colors() const{
return vertex_colors;
}
@@ -333,56 +333,60 @@ Vector2 Polygon2D::get_offset() const {
void Polygon2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&Polygon2D::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&Polygon2D::get_polygon);
+ ClassDB::bind_method(_MD("set_polygon","polygon"),&Polygon2D::set_polygon);
+ ClassDB::bind_method(_MD("get_polygon"),&Polygon2D::get_polygon);
- ObjectTypeDB::bind_method(_MD("set_uv","uv"),&Polygon2D::set_uv);
- ObjectTypeDB::bind_method(_MD("get_uv"),&Polygon2D::get_uv);
+ ClassDB::bind_method(_MD("set_uv","uv"),&Polygon2D::set_uv);
+ ClassDB::bind_method(_MD("get_uv"),&Polygon2D::get_uv);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&Polygon2D::get_color);
+ ClassDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color);
+ ClassDB::bind_method(_MD("get_color"),&Polygon2D::get_color);
- ObjectTypeDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors);
- ObjectTypeDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors);
+ ClassDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors);
+ ClassDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors);
- ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Polygon2D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture);
+ ClassDB::bind_method(_MD("set_texture","texture"),&Polygon2D::set_texture);
+ ClassDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_texture_offset","texture_offset"),&Polygon2D::set_texture_offset);
- ObjectTypeDB::bind_method(_MD("get_texture_offset"),&Polygon2D::get_texture_offset);
+ ClassDB::bind_method(_MD("set_texture_offset","texture_offset"),&Polygon2D::set_texture_offset);
+ ClassDB::bind_method(_MD("get_texture_offset"),&Polygon2D::get_texture_offset);
- ObjectTypeDB::bind_method(_MD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation);
- ObjectTypeDB::bind_method(_MD("get_texture_rotation"),&Polygon2D::get_texture_rotation);
+ ClassDB::bind_method(_MD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation);
+ ClassDB::bind_method(_MD("get_texture_rotation"),&Polygon2D::get_texture_rotation);
- ObjectTypeDB::bind_method(_MD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd);
- ObjectTypeDB::bind_method(_MD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd);
+ ClassDB::bind_method(_MD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd);
+ ClassDB::bind_method(_MD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale);
+ ClassDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale);
+ ClassDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale);
- ObjectTypeDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert);
- ObjectTypeDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert);
+ ClassDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert);
+ ClassDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert);
- ObjectTypeDB::bind_method(_MD("set_invert_border","invert_border"),&Polygon2D::set_invert_border);
- ObjectTypeDB::bind_method(_MD("get_invert_border"),&Polygon2D::get_invert_border);
+ ClassDB::bind_method(_MD("set_invert_border","invert_border"),&Polygon2D::set_invert_border);
+ ClassDB::bind_method(_MD("get_invert_border"),&Polygon2D::get_invert_border);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Polygon2D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Polygon2D::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&Polygon2D::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&Polygon2D::get_offset);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/scale"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture/rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_texture_rotationd"),_SCS("_get_texture_rotationd"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert/enable"),_SCS("set_invert"),_SCS("get_invert"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert/border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),_SCS("set_invert_border"),_SCS("get_invert_border"));
+ ADD_GROUP("Texture","");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
+ ADD_GROUP("Texture","texture_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_scale"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture_rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_texture_rotationd"),_SCS("_get_texture_rotationd"));
+
+ ADD_GROUP("Invert","invert_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert_enable"),_SCS("set_invert"),_SCS("get_invert"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert_border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),_SCS("set_invert_border"),_SCS("get_invert_border"));
}
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index cecb9081f7..8434dae40c 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,11 +33,11 @@
class Polygon2D : public Node2D {
- OBJ_TYPE(Polygon2D,Node2D);
+ GDCLASS(Polygon2D,Node2D);
- DVector<Vector2> polygon;
- DVector<Vector2> uv;
- DVector<Color> vertex_colors;
+ PoolVector<Vector2> polygon;
+ PoolVector<Vector2> uv;
+ PoolVector<Color> vertex_colors;
Color color;
Ref<Texture> texture;
Size2 tex_scale;
@@ -60,17 +60,17 @@ protected:
static void _bind_methods();
public:
- void set_polygon(const DVector<Vector2>& p_polygon);
- DVector<Vector2> get_polygon() const;
+ void set_polygon(const PoolVector<Vector2>& p_polygon);
+ PoolVector<Vector2> get_polygon() const;
- void set_uv(const DVector<Vector2>& p_uv);
- DVector<Vector2> get_uv() const;
+ void set_uv(const PoolVector<Vector2>& p_uv);
+ PoolVector<Vector2> get_uv() const;
void set_color(const Color& p_color);
Color get_color() const;
- void set_vertex_colors(const DVector<Color>& p_colors);
- DVector<Color> get_vertex_colors() const;
+ void set_vertex_colors(const PoolVector<Color>& p_colors);
+ PoolVector<Color> get_vertex_colors() const;
void set_texture(const Ref<Texture>& p_texture);
Ref<Texture> get_texture() const;
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index c293305cb2..a25be18cb9 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index 23821e62d4..fb68c265b3 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Position2D : public Node2D {
- OBJ_TYPE(Position2D,Node2D)
+ GDCLASS(Position2D,Node2D)
void _draw_cross();
protected:
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index b5d62adfb4..14dfc10d9f 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -161,7 +161,7 @@ void RayCast2D::_notification(int p_what) {
if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
break;
- Matrix32 xf;
+ Transform2D xf;
xf.rotate(cast_to.angle());
xf.translate(Vector2(0,cast_to.length()));
@@ -187,39 +187,44 @@ void RayCast2D::_notification(int p_what) {
if (!enabled)
break;
+ _update_raycast_state();
- Ref<World2D> w2d = get_world_2d();
- ERR_BREAK( w2d.is_null() );
-
- Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
- ERR_BREAK( !dss );
-
- Matrix32 gt = get_global_transform();
+ } break;
+ }
+}
- Vector2 to = cast_to;
- if (to==Vector2())
- to=Vector2(0,0.01);
+void RayCast2D::_update_raycast_state() {
+ Ref<World2D> w2d = get_world_2d();
+ ERR_FAIL_COND( w2d.is_null() );
- Physics2DDirectSpaceState::RayResult rr;
+ Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
+ ERR_FAIL_COND( !dss );
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
+ Transform2D gt = get_global_transform();
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
- } else {
- collided=false;
- }
+ Vector2 to = cast_to;
+ if (to==Vector2())
+ to=Vector2(0,0.01);
+ Physics2DDirectSpaceState::RayResult rr;
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
- } break;
+ collided=true;
+ against=rr.collider_id;
+ collision_point=rr.position;
+ collision_normal=rr.normal;
+ against_shape=rr.shape;
+ } else {
+ collided=false;
}
}
+void RayCast2D::force_raycast_update() {
+ _update_raycast_state();
+}
+
void RayCast2D::add_exception_rid(const RID& p_rid) {
exclude.insert(p_rid);
@@ -258,40 +263,41 @@ void RayCast2D::clear_exceptions(){
void RayCast2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&RayCast2D::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&RayCast2D::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enabled"),&RayCast2D::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&RayCast2D::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_cast_to","local_point"),&RayCast2D::set_cast_to);
- ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to);
+ ClassDB::bind_method(_MD("set_cast_to","local_point"),&RayCast2D::set_cast_to);
+ ClassDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding);
+ ClassDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding);
+ ClassDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update);
- ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_point"),&RayCast2D::get_collision_point);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&RayCast2D::get_collision_normal);
+ ClassDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider);
+ ClassDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape);
+ ClassDB::bind_method(_MD("get_collision_point"),&RayCast2D::get_collision_point);
+ ClassDB::bind_method(_MD("get_collision_normal"),&RayCast2D::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("add_exception_rid","rid"),&RayCast2D::add_exception_rid);
- ObjectTypeDB::bind_method(_MD("add_exception","node"),&RayCast2D::add_exception);
+ ClassDB::bind_method(_MD("add_exception_rid","rid"),&RayCast2D::add_exception_rid);
+ ClassDB::bind_method(_MD("add_exception","node"),&RayCast2D::add_exception);
- ObjectTypeDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid);
- ObjectTypeDB::bind_method(_MD("remove_exception","node"),&RayCast2D::remove_exception);
+ ClassDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid);
+ ClassDB::bind_method(_MD("remove_exception","node"),&RayCast2D::remove_exception);
- ObjectTypeDB::bind_method(_MD("clear_exceptions"),&RayCast2D::clear_exceptions);
+ ClassDB::bind_method(_MD("clear_exceptions"),&RayCast2D::clear_exceptions);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask);
+ ClassDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask);
+ ClassDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask);
- ObjectTypeDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask);
+ ClassDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask);
+ ClassDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask);
- ObjectTypeDB::bind_method(_MD("set_exclude_parent_body","mask"),&RayCast2D::set_exclude_parent_body);
- ObjectTypeDB::bind_method(_MD("get_exclude_parent_body"),&RayCast2D::get_exclude_parent_body);
+ ClassDB::bind_method(_MD("set_exclude_parent_body","mask"),&RayCast2D::set_exclude_parent_body);
+ ClassDB::bind_method(_MD("get_exclude_parent_body"),&RayCast2D::get_exclude_parent_body);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"exclude_parent"),_SCS("set_exclude_parent_body"),_SCS("get_exclude_parent_body"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
}
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index e1caa8b63e..3e7a39ffde 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class RayCast2D : public Node2D {
- OBJ_TYPE(RayCast2D,Node2D);
+ GDCLASS(RayCast2D,Node2D);
bool enabled;
@@ -52,6 +52,7 @@ class RayCast2D : public Node2D {
protected:
void _notification(int p_what);
+ void _update_raycast_state();
static void _bind_methods();
public:
@@ -70,6 +71,8 @@ public:
void set_exclude_parent_body(bool p_exclude_parent_body);
bool get_exclude_parent_body() const;
+ void force_raycast_update();
+
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index 4de648a1db..77f1a9d500 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -118,8 +118,8 @@ String RemoteTransform2D::get_configuration_warning() const {
void RemoteTransform2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform2D::set_remote_node);
- ObjectTypeDB::bind_method(_MD("get_remote_node"),&RemoteTransform2D::get_remote_node);
+ ClassDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform2D::set_remote_node);
+ ClassDB::bind_method(_MD("get_remote_node"),&RemoteTransform2D::get_remote_node);
ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node"));
}
@@ -127,7 +127,7 @@ void RemoteTransform2D::_bind_methods() {
RemoteTransform2D::RemoteTransform2D() {
cache=0;
-
+ set_notify_transform(true);
}
diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h
index 0ea1438f0a..52c28ffd4f 100644
--- a/scene/2d/remote_transform_2d.h
+++ b/scene/2d/remote_transform_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,7 +30,7 @@
class RemoteTransform2D : public Node2D {
- OBJ_TYPE(RemoteTransform2D,Node2D);
+ GDCLASS(RemoteTransform2D,Node2D);
NodePath remote_node;
diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp
index 7c997b3f12..62eabea98e 100644
--- a/scene/2d/sample_player_2d.cpp
+++ b/scene/2d/sample_player_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -220,30 +220,31 @@ String SamplePlayer2D::get_configuration_warning() const {
void SamplePlayer2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library);
- ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library);
+ ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library);
+ ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library);
- ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony);
- ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony);
+ ClassDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony);
+ ClassDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony);
- ObjectTypeDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE));
+ ClassDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE));
//voices,DEV
- ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SamplePlayer2D::voice_set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SamplePlayer2D::voice_set_volume_scale_db);
+ ClassDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SamplePlayer2D::voice_set_pitch_scale);
+ ClassDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SamplePlayer2D::voice_set_volume_scale_db);
- ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer2D::is_voice_active);
- ObjectTypeDB::bind_method(_MD("stop_voice","voice"),&SamplePlayer2D::stop_voice);
- ObjectTypeDB::bind_method(_MD("stop_all"),&SamplePlayer2D::stop_all);
+ ClassDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer2D::is_voice_active);
+ ClassDB::bind_method(_MD("stop_voice","voice"),&SamplePlayer2D::stop_voice);
+ ClassDB::bind_method(_MD("stop_all"),&SamplePlayer2D::stop_all);
- ObjectTypeDB::bind_method(_MD("set_random_pitch_scale","val"),&SamplePlayer2D::set_random_pitch_scale);
- ObjectTypeDB::bind_method(_MD("get_random_pitch_scale"),&SamplePlayer2D::get_random_pitch_scale);
+ ClassDB::bind_method(_MD("set_random_pitch_scale","val"),&SamplePlayer2D::set_random_pitch_scale);
+ ClassDB::bind_method(_MD("get_random_pitch_scale"),&SamplePlayer2D::get_random_pitch_scale);
BIND_CONSTANT( INVALID_VOICE );
BIND_CONSTANT( NEXT_VOICE );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "config/pitch_random", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_random_pitch_scale"),_SCS("get_random_pitch_scale"));
+ ADD_GROUP("Config","");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "pitch_random", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_random_pitch_scale"),_SCS("get_random_pitch_scale"));
}
diff --git a/scene/2d/sample_player_2d.h b/scene/2d/sample_player_2d.h
index 5ab7f024d3..5cf598327b 100644
--- a/scene/2d/sample_player_2d.h
+++ b/scene/2d/sample_player_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class SamplePlayer2D : public SoundPlayer2D {
- OBJ_TYPE(SamplePlayer2D,SoundPlayer2D);
+ GDCLASS(SamplePlayer2D,SoundPlayer2D);
public:
enum {
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index fac94f19dc..20db63b66f 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -236,7 +236,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (p_event.screen_touch.pressed) {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
if (finger_pressed!=-1)
@@ -307,8 +307,10 @@ Rect2 TouchScreenButton::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
return Rect2(Size2(),texture->get_size());
}
@@ -338,27 +340,27 @@ bool TouchScreenButton::is_passby_press_enabled() const{
void TouchScreenButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture"),&TouchScreenButton::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture"),&TouchScreenButton::get_texture);
+ ClassDB::bind_method(_MD("set_texture","texture"),&TouchScreenButton::set_texture);
+ ClassDB::bind_method(_MD("get_texture"),&TouchScreenButton::get_texture);
- ObjectTypeDB::bind_method(_MD("set_texture_pressed","texture_pressed"),&TouchScreenButton::set_texture_pressed);
- ObjectTypeDB::bind_method(_MD("get_texture_pressed"),&TouchScreenButton::get_texture_pressed);
+ ClassDB::bind_method(_MD("set_texture_pressed","texture_pressed"),&TouchScreenButton::set_texture_pressed);
+ ClassDB::bind_method(_MD("get_texture_pressed"),&TouchScreenButton::get_texture_pressed);
- ObjectTypeDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask);
- ObjectTypeDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask);
+ ClassDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask);
+ ClassDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask);
- ObjectTypeDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action);
- ObjectTypeDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action);
+ ClassDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action);
+ ClassDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action);
- ObjectTypeDB::bind_method(_MD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode);
- ObjectTypeDB::bind_method(_MD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode);
+ ClassDB::bind_method(_MD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode);
+ ClassDB::bind_method(_MD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode);
- ObjectTypeDB::bind_method(_MD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press);
- ObjectTypeDB::bind_method(_MD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled);
+ ClassDB::bind_method(_MD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press);
+ ClassDB::bind_method(_MD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled);
- ObjectTypeDB::bind_method(_MD("is_pressed"),&TouchScreenButton::is_pressed);
+ ClassDB::bind_method(_MD("is_pressed"),&TouchScreenButton::is_pressed);
- ObjectTypeDB::bind_method(_MD("_input"),&TouchScreenButton::_input);
+ ClassDB::bind_method(_MD("_input"),&TouchScreenButton::_input);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture_pressed"),_SCS("get_texture_pressed"));
diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h
index ff3b50bf5e..34e02d644b 100644
--- a/scene/2d/screen_button.h
+++ b/scene/2d/screen_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class TouchScreenButton : public Node2D {
- OBJ_TYPE(TouchScreenButton,Node2D);
+ GDCLASS(TouchScreenButton,Node2D);
public:
enum VisibilityMode {
diff --git a/scene/2d/sound_player_2d.cpp b/scene/2d/sound_player_2d.cpp
index 41ce87faf9..7861fb5855 100644
--- a/scene/2d/sound_player_2d.cpp
+++ b/scene/2d/sound_player_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -87,8 +87,8 @@ float SoundPlayer2D::get_param( Param p_param) const {
void SoundPlayer2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SoundPlayer2D::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SoundPlayer2D::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&SoundPlayer2D::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&SoundPlayer2D::get_param);
BIND_CONSTANT( PARAM_VOLUME_DB );
BIND_CONSTANT( PARAM_PITCH_SCALE );
@@ -97,11 +97,13 @@ void SoundPlayer2D::_bind_methods() {
BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP );
BIND_CONSTANT( PARAM_MAX );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/min_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/max_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
+ ADD_GROUP("Parameters","");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
+ ADD_GROUP("Attenuation","attenuation_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_min_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_max_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
}
@@ -114,7 +116,7 @@ SoundPlayer2D::SoundPlayer2D() {
params[PARAM_ATTENUATION_MAX_DISTANCE]=2048;
params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
-
+ set_notify_transform(true);
}
SoundPlayer2D::~SoundPlayer2D() {
diff --git a/scene/2d/sound_player_2d.h b/scene/2d/sound_player_2d.h
index 0e75887235..bfabda4ec9 100644
--- a/scene/2d/sound_player_2d.h
+++ b/scene/2d/sound_player_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
class SoundPlayer2D : public Node2D {
- OBJ_TYPE(SoundPlayer2D,Node2D);
+ GDCLASS(SoundPlayer2D,Node2D);
public:
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index c5b338bf59..bea45aae4e 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -86,7 +86,7 @@ void Sprite::_notification(int p_what) {
Point2 ofs=offset;
if (centered)
ofs-=s/2;
- if (OS::get_singleton()->get_use_pixel_snap()) {
+ if (Engine::get_singleton()->get_use_pixel_snap()) {
ofs=ofs.floor();
}
@@ -97,7 +97,7 @@ void Sprite::_notification(int p_what) {
if (vflip)
dst_rect.size.y=-dst_rect.size.y;
- texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
+ texture->draw_rect_region(ci,dst_rect,src_rect);
} break;
}
@@ -214,6 +214,7 @@ void Sprite::set_frame(int p_frame) {
frame=p_frame;
+ _change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
@@ -248,24 +249,16 @@ int Sprite::get_hframes() const {
return hframes;
}
-void Sprite::set_modulate(const Color& p_color) {
-
- modulate=p_color;
- update();
-}
-
-Color Sprite::get_modulate() const{
-
- return modulate;
-}
Rect2 Sprite::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
Size2i s;
@@ -301,38 +294,35 @@ void Sprite::_validate_property(PropertyInfo& property) const {
void Sprite::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Sprite::get_texture);
-
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&Sprite::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&Sprite::is_centered);
+ ClassDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture);
+ ClassDB::bind_method(_MD("get_texture:Texture"),&Sprite::get_texture);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Sprite::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Sprite::get_offset);
+ ClassDB::bind_method(_MD("set_centered","centered"),&Sprite::set_centered);
+ ClassDB::bind_method(_MD("is_centered"),&Sprite::is_centered);
- ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&Sprite::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Sprite::is_flipped_h);
+ ClassDB::bind_method(_MD("set_offset","offset"),&Sprite::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&Sprite::get_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&Sprite::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Sprite::is_flipped_v);
+ ClassDB::bind_method(_MD("set_flip_h","flip_h"),&Sprite::set_flip_h);
+ ClassDB::bind_method(_MD("is_flipped_h"),&Sprite::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_region","enabled"),&Sprite::set_region);
- ObjectTypeDB::bind_method(_MD("is_region"),&Sprite::is_region);
+ ClassDB::bind_method(_MD("set_flip_v","flip_v"),&Sprite::set_flip_v);
+ ClassDB::bind_method(_MD("is_flipped_v"),&Sprite::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Sprite::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Sprite::get_region_rect);
+ ClassDB::bind_method(_MD("set_region","enabled"),&Sprite::set_region);
+ ClassDB::bind_method(_MD("is_region"),&Sprite::is_region);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&Sprite::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&Sprite::get_frame);
+ ClassDB::bind_method(_MD("set_region_rect","rect"),&Sprite::set_region_rect);
+ ClassDB::bind_method(_MD("get_region_rect"),&Sprite::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_vframes","vframes"),&Sprite::set_vframes);
- ObjectTypeDB::bind_method(_MD("get_vframes"),&Sprite::get_vframes);
+ ClassDB::bind_method(_MD("set_frame","frame"),&Sprite::set_frame);
+ ClassDB::bind_method(_MD("get_frame"),&Sprite::get_frame);
- ObjectTypeDB::bind_method(_MD("set_hframes","hframes"),&Sprite::set_hframes);
- ObjectTypeDB::bind_method(_MD("get_hframes"),&Sprite::get_hframes);
+ ClassDB::bind_method(_MD("set_vframes","vframes"),&Sprite::set_vframes);
+ ClassDB::bind_method(_MD("get_vframes"),&Sprite::get_vframes);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&Sprite::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&Sprite::get_modulate);
+ ClassDB::bind_method(_MD("set_hframes","hframes"),&Sprite::set_hframes);
+ ClassDB::bind_method(_MD("get_hframes"),&Sprite::get_hframes);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("texture_changed"));
@@ -345,7 +335,6 @@ void Sprite::_bind_methods() {
ADD_PROPERTYNO( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes"));
ADD_PROPERTYNO( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_hframes"),_SCS("get_hframes"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
@@ -363,9 +352,6 @@ Sprite::Sprite() {
vframes=1;
hframes=1;
- modulate=Color(1,1,1,1);
-
-
}
@@ -376,7 +362,7 @@ Sprite::Sprite() {
///
///
-
+#if 0
void ViewportSprite::edit_set_pivot(const Point2& p_pivot) {
set_offset(p_pivot);
@@ -526,8 +512,10 @@ Rect2 ViewportSprite::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
Size2i s;
@@ -564,17 +552,17 @@ String ViewportSprite::get_configuration_warning() const {
void ViewportSprite::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_viewport_path","path"),&ViewportSprite::set_viewport_path);
- ObjectTypeDB::bind_method(_MD("get_viewport_path"),&ViewportSprite::get_viewport_path);
+ ClassDB::bind_method(_MD("set_viewport_path","path"),&ViewportSprite::set_viewport_path);
+ ClassDB::bind_method(_MD("get_viewport_path"),&ViewportSprite::get_viewport_path);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&ViewportSprite::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&ViewportSprite::is_centered);
+ ClassDB::bind_method(_MD("set_centered","centered"),&ViewportSprite::set_centered);
+ ClassDB::bind_method(_MD("is_centered"),&ViewportSprite::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&ViewportSprite::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&ViewportSprite::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&ViewportSprite::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&ViewportSprite::get_offset);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate);
+ ClassDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate);
+ ClassDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate);
ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"),_SCS("get_viewport_path"));
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
@@ -588,3 +576,4 @@ ViewportSprite::ViewportSprite() {
centered=true;
modulate=Color(1,1,1,1);
}
+#endif
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index 32d3f476d1..05c0bd9eec 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class Sprite : public Node2D {
- OBJ_TYPE( Sprite, Node2D );
+ GDCLASS( Sprite, Node2D );
Ref<Texture> texture;
@@ -52,7 +52,6 @@ class Sprite : public Node2D {
int vframes;
int hframes;
- Color modulate;
protected:
@@ -99,17 +98,15 @@ public:
void set_hframes(int p_amount);
int get_hframes() const;
- void set_modulate(const Color& p_color);
- Color get_modulate() const;
-
virtual Rect2 get_item_rect() const;
Sprite();
};
+#if 0
class ViewportSprite : public Node2D {
- OBJ_TYPE( ViewportSprite, Node2D );
+ GDCLASS( ViewportSprite, Node2D );
Ref<Texture> texture;
NodePath viewport_path;
@@ -149,4 +146,5 @@ public:
ViewportSprite();
};
+#endif
#endif // SPRITE_H
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 1a4f88c30e..d6d713920c 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -114,16 +114,16 @@ void TileMap::_update_quadrant_transform() {
if (!is_inside_tree())
return;
- Matrix32 global_transform = get_global_transform();
+ Transform2D global_transform = get_global_transform();
- Matrix32 nav_rel;
+ Transform2D nav_rel;
if (navigation)
nav_rel = get_relative_transform_to_parent(navigation);
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
- Matrix32 xform;
+ Transform2D xform;
xform.set_origin( q.pos );
xform = global_transform * xform;
Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
@@ -218,7 +218,7 @@ bool TileMap::get_center_y() const {
return center_y;
}
-void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) {
+void TileMap::_fix_cell_transform(Transform2D& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) {
Size2 s=p_sc;
Vector2 offset = p_offset;
@@ -268,16 +268,16 @@ void TileMap::_update_dirty_quadrants() {
if (!pending_update)
return;
- if (!is_inside_tree())
- return;
- if (!tile_set.is_valid())
+ if (!is_inside_tree() || !tile_set.is_valid()) {
+ pending_update = false;
return;
+ }
VisualServer *vs = VisualServer::get_singleton();
Physics2DServer *ps = Physics2DServer::get_singleton();
Vector2 tofs = get_cell_draw_offset();
Vector2 tcenter = cell_size/2;
- Matrix32 nav_rel;
+ Transform2D nav_rel;
if (navigation)
nav_rel = get_relative_transform_to_parent(navigation);
@@ -348,7 +348,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() );
- Matrix32 xform;
+ Transform2D xform;
xform.set_origin( q.pos );
vs->canvas_item_set_transform( canvas_item, xform );
vs->canvas_item_set_light_mask(canvas_item,get_light_mask());
@@ -457,10 +457,11 @@ void TileMap::_update_dirty_quadrants() {
}
+ Color modulate = tile_set->tile_get_modulate(c.id);
if (r==Rect2()) {
- tex->draw_rect(canvas_item,rect,false,Color(1,1,1),c.transpose);
+ tex->draw_rect(canvas_item,rect,false,modulate,c.transpose);
} else {
- tex->draw_rect_region(canvas_item,rect,r,Color(1,1,1),c.transpose);
+ tex->draw_rect_region(canvas_item,rect,r,modulate,c.transpose);
}
Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
@@ -472,12 +473,12 @@ void TileMap::_update_dirty_quadrants() {
if (shape.is_valid()) {
Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id);
- Matrix32 xform;
+ Transform2D xform;
xform.set_origin(offset.floor());
_fix_cell_transform(xform,c,shape_ofs+center_ofs,s);
- if (debug_canvas_item) {
+ if (debug_canvas_item.is_valid()) {
vs->canvas_item_add_set_transform(debug_canvas_item,xform);
shape->draw(debug_canvas_item,debug_collision_color);
@@ -488,15 +489,15 @@ void TileMap::_update_dirty_quadrants() {
}
}
- if (debug_canvas_item) {
- vs->canvas_item_add_set_transform(debug_canvas_item,Matrix32());
+ if (debug_canvas_item.is_valid()) {
+ vs->canvas_item_add_set_transform(debug_canvas_item,Transform2D());
}
if (navigation) {
Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id);
if (navpoly.is_valid()) {
Vector2 npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id);
- Matrix32 xform;
+ Transform2D xform;
xform.set_origin(offset.floor()+q.pos);
_fix_cell_transform(xform,c,npoly_ofs+center_ofs,s);
@@ -515,7 +516,7 @@ void TileMap::_update_dirty_quadrants() {
if (occluder.is_valid()) {
Vector2 occluder_ofs = tile_set->tile_get_occluder_offset(c.id);
- Matrix32 xform;
+ Transform2D xform;
xform.set_origin(offset.floor()+q.pos);
_fix_cell_transform(xform,c,occluder_ofs+center_ofs,s);
@@ -541,26 +542,19 @@ void TileMap::_update_dirty_quadrants() {
if (quadrant_order_dirty) {
+ int index=-0x80000000; //always must be drawn below children
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()) {
- VS::get_singleton()->canvas_item_raise(E->get());
+ VS::get_singleton()->canvas_item_set_draw_index(E->get(),index++);
}
}
quadrant_order_dirty=false;
}
- for(int i=0;i<get_child_count();i++) {
-
- CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
-
- if (c)
- VS::get_singleton()->canvas_item_raise(c->get_canvas_item());
- }
-
_recompute_rect_cache();
}
@@ -605,7 +599,7 @@ void TileMap::_recompute_rect_cache() {
Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const PosKey& p_qk) {
- Matrix32 xform;
+ Transform2D xform;
//xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size);
Quadrant q;
q.pos = _map_to_world(p_qk.x*_get_quadrant_size(),p_qk.y*_get_quadrant_size());
@@ -617,7 +611,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
xform.set_origin( q.pos );
-// q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
+ //q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
@@ -826,10 +820,10 @@ void TileMap::clear() {
tile_map.clear();
}
-void TileMap::_set_tile_data(const DVector<int>& p_data) {
+void TileMap::_set_tile_data(const PoolVector<int>& p_data) {
int c=p_data.size();
- DVector<int>::Read r = p_data.read();
+ PoolVector<int>::Read r = p_data.read();
for(int i=0;i<c;i+=2) {
@@ -856,19 +850,21 @@ void TileMap::_set_tile_data(const DVector<int>& p_data) {
bool transpose = v&(1<<31);
v&=(1<<29)-1;
-// if (x<-20 || y <-20 || x>4000 || y>4000)
-// continue;
+ /*
+ if (x<-20 || y <-20 || x>4000 || y>4000)
+ continue;
+ */
set_cell(x,y,v,flip_h,flip_v,transpose);
}
}
-DVector<int> TileMap::_get_tile_data() const {
+PoolVector<int> TileMap::_get_tile_data() const {
- DVector<int> data;
+ PoolVector<int> data;
data.resize(tile_map.size()*2);
- DVector<int>::Write w = data.write();
+ PoolVector<int>::Write w = data.write();
int idx=0;
for(const Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
@@ -889,7 +885,7 @@ DVector<int> TileMap::_get_tile_data() const {
}
- w = DVector<int>::Write();
+ w = PoolVector<int>::Write();
return data;
@@ -1041,13 +1037,13 @@ TileMap::HalfOffset TileMap::get_half_offset() const {
return half_offset;
}
-Matrix32 TileMap::get_cell_transform() const {
+Transform2D TileMap::get_cell_transform() const {
switch(mode) {
case MODE_SQUARE: {
- Matrix32 m;
+ Transform2D m;
m[0]*=cell_size.x;
m[1]*=cell_size.y;
return m;
@@ -1056,7 +1052,7 @@ Matrix32 TileMap::get_cell_transform() const {
//isometric only makes sense when y is positive in both x and y vectors, otherwise
//the drawing of tiles will overlap
- Matrix32 m;
+ Transform2D m;
m[0]=Vector2(cell_size.x*0.5,cell_size.y*0.5);
m[1]=Vector2(-cell_size.x*0.5,cell_size.y*0.5);
return m;
@@ -1068,10 +1064,10 @@ Matrix32 TileMap::get_cell_transform() const {
} break;
}
- return Matrix32();
+ return Transform2D();
}
-void TileMap::set_custom_transform(const Matrix32& p_xform) {
+void TileMap::set_custom_transform(const Transform2D& p_xform) {
_clear_quadrants();
custom_transform=p_xform;
@@ -1080,7 +1076,7 @@ void TileMap::set_custom_transform(const Matrix32& p_xform) {
}
-Matrix32 TileMap::get_custom_transform() const{
+Transform2D TileMap::get_custom_transform() const{
return custom_transform;
}
@@ -1193,95 +1189,100 @@ void TileMap::set_light_mask(int p_light_mask) {
void TileMap::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_tileset","tileset:TileSet"),&TileMap::set_tileset);
- ObjectTypeDB::bind_method(_MD("get_tileset:TileSet"),&TileMap::get_tileset);
+ ClassDB::bind_method(_MD("set_tileset","tileset:TileSet"),&TileMap::set_tileset);
+ ClassDB::bind_method(_MD("get_tileset:TileSet"),&TileMap::get_tileset);
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&TileMap::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&TileMap::get_mode);
+ ClassDB::bind_method(_MD("set_mode","mode"),&TileMap::set_mode);
+ ClassDB::bind_method(_MD("get_mode"),&TileMap::get_mode);
- ObjectTypeDB::bind_method(_MD("set_half_offset","half_offset"),&TileMap::set_half_offset);
- ObjectTypeDB::bind_method(_MD("get_half_offset"),&TileMap::get_half_offset);
+ ClassDB::bind_method(_MD("set_half_offset","half_offset"),&TileMap::set_half_offset);
+ ClassDB::bind_method(_MD("get_half_offset"),&TileMap::get_half_offset);
- ObjectTypeDB::bind_method(_MD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform);
- ObjectTypeDB::bind_method(_MD("get_custom_transform"),&TileMap::get_custom_transform);
+ ClassDB::bind_method(_MD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform);
+ ClassDB::bind_method(_MD("get_custom_transform"),&TileMap::get_custom_transform);
- ObjectTypeDB::bind_method(_MD("set_cell_size","size"),&TileMap::set_cell_size);
- ObjectTypeDB::bind_method(_MD("get_cell_size"),&TileMap::get_cell_size);
+ ClassDB::bind_method(_MD("set_cell_size","size"),&TileMap::set_cell_size);
+ ClassDB::bind_method(_MD("get_cell_size"),&TileMap::get_cell_size);
- ObjectTypeDB::bind_method(_MD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size);
- ObjectTypeDB::bind_method(_MD("_get_old_cell_size"),&TileMap::_get_old_cell_size);
+ ClassDB::bind_method(_MD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size);
+ ClassDB::bind_method(_MD("_get_old_cell_size"),&TileMap::_get_old_cell_size);
- ObjectTypeDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size);
- ObjectTypeDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size);
+ ClassDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size);
+ ClassDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size);
- ObjectTypeDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin);
- ObjectTypeDB::bind_method(_MD("get_tile_origin"),&TileMap::get_tile_origin);
+ ClassDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin);
+ ClassDB::bind_method(_MD("get_tile_origin"),&TileMap::get_tile_origin);
- ObjectTypeDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x);
- ObjectTypeDB::bind_method(_MD("get_center_x"),&TileMap::get_center_x);
+ ClassDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x);
+ ClassDB::bind_method(_MD("get_center_x"),&TileMap::get_center_x);
- ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
- ObjectTypeDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
+ ClassDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
+ ClassDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
- ObjectTypeDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode);
- ObjectTypeDB::bind_method(_MD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled);
+ ClassDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode);
+ ClassDB::bind_method(_MD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled);
- ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
- ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
+ ClassDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
+ ClassDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
- ObjectTypeDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer);
- ObjectTypeDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer);
+ ClassDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer);
+ ClassDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask);
+ ClassDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask);
+ ClassDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction);
- ObjectTypeDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction);
+ ClassDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction);
+ ClassDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction);
- ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
- ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
+ ClassDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
+ ClassDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
- ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
- ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
+ ClassDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
+ ClassDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
- ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
- ObjectTypeDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv);
- ObjectTypeDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped);
- ObjectTypeDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped);
- ObjectTypeDB::bind_method(_MD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed);
+ ClassDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
+ ClassDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
+ ClassDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
+ ClassDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv);
+ ClassDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped);
+ ClassDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped);
+ ClassDB::bind_method(_MD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed);
- ObjectTypeDB::bind_method(_MD("clear"),&TileMap::clear);
+ ClassDB::bind_method(_MD("clear"),&TileMap::clear);
- ObjectTypeDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells);
+ ClassDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells);
- ObjectTypeDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map);
+ ClassDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false));
+ ClassDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map);
- ObjectTypeDB::bind_method(_MD("_clear_quadrants"),&TileMap::_clear_quadrants);
- ObjectTypeDB::bind_method(_MD("_recreate_quadrants"),&TileMap::_recreate_quadrants);
- ObjectTypeDB::bind_method(_MD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants);
+ ClassDB::bind_method(_MD("_clear_quadrants"),&TileMap::_clear_quadrants);
+ ClassDB::bind_method(_MD("_recreate_quadrants"),&TileMap::_recreate_quadrants);
+ ClassDB::bind_method(_MD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants);
- ObjectTypeDB::bind_method(_MD("_set_tile_data"),&TileMap::_set_tile_data);
- ObjectTypeDB::bind_method(_MD("_get_tile_data"),&TileMap::_get_tile_data);
+ ClassDB::bind_method(_MD("_set_tile_data"),&TileMap::_set_tile_data);
+ ClassDB::bind_method(_MD("_get_tile_data"),&TileMap::_get_tile_data);
ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Square,Isometric,Custom"),_SCS("set_mode"),_SCS("get_mode"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_set",PROPERTY_HINT_RESOURCE_TYPE,"TileSet"),_SCS("set_tileset"),_SCS("get_tileset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1",0),_SCS("_set_old_cell_size"),_SCS("_get_old_cell_size"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell/size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
- ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell/custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center,Bottom Left"),_SCS("set_tile_origin"),_SCS("get_tile_origin"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell/y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_GROUP("Cell","cell_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
+ ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM2D,"cell_custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center,Bottom Left"),_SCS("set_tile_origin"),_SCS("get_tile_origin"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell_y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled"));
+
+ ADD_GROUP("Collision","collision_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision_use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision_friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision_bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+
+ ADD_GROUP("Occluder","occluder_");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder_light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_GROUP("","");
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data"));
ADD_SIGNAL(MethodInfo("settings_changed"));
@@ -1323,6 +1324,7 @@ TileMap::TileMap() {
fp_adjust=0.00001;
tile_origin=TILE_ORIGIN_TOP_LEFT;
+ set_notify_transform(true);
}
TileMap::~TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index b48fdde43f..ba6de62f8e 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
class TileMap : public Node2D {
- OBJ_TYPE( TileMap, Node2D );
+ GDCLASS( TileMap, Node2D );
public:
enum Mode {
@@ -66,7 +66,7 @@ private:
int quadrant_size;
bool center_x,center_y;
Mode mode;
- Matrix32 custom_transform;
+ Transform2D custom_transform;
HalfOffset half_offset;
bool use_kinematic;
Navigation2D *navigation;
@@ -114,12 +114,12 @@ private:
struct NavPoly {
int id;
- Matrix32 xform;
+ Transform2D xform;
};
struct Occluder {
RID id;
- Matrix32 xform;
+ Transform2D xform;
};
@@ -153,7 +153,7 @@ private:
int occluder_light_mask;
- void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
+ void _fix_cell_transform(Transform2D& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk);
void _erase_quadrant(Map<PosKey,Quadrant>::Element *Q);
@@ -168,8 +168,8 @@ private:
_FORCE_INLINE_ int _get_quadrant_size() const;
- void _set_tile_data(const DVector<int>& p_data);
- DVector<int> _get_tile_data() const;
+ void _set_tile_data(const PoolVector<int>& p_data);
+ PoolVector<int> _get_tile_data() const;
void _set_old_cell_size(int p_size) { set_cell_size(Size2(p_size,p_size)); }
int _get_old_cell_size() const { return cell_size.x; }
@@ -240,10 +240,10 @@ public:
void set_tile_origin(TileOrigin p_tile_origin);
TileOrigin get_tile_origin() const;
- void set_custom_transform(const Matrix32& p_xform);
- Matrix32 get_custom_transform() const;
+ void set_custom_transform(const Transform2D& p_xform);
+ Transform2D get_custom_transform() const;
- Matrix32 get_cell_transform() const;
+ Transform2D get_cell_transform() const;
Vector2 get_cell_draw_offset() const;
Vector2 map_to_world(const Vector2& p_pos, bool p_ignore_ofs=false) const;
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 852bc187d2..f1c70a8f60 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -44,11 +44,11 @@ void VisibilityNotifier2D::_enter_viewport(Viewport* p_viewport) {
return;
if (viewports.size()==1) {
- emit_signal(SceneStringNames::get_singleton()->enter_screen);
+ emit_signal(SceneStringNames::get_singleton()->screen_entered);
_screen_enter();
}
- emit_signal(SceneStringNames::get_singleton()->enter_viewport,p_viewport);
+ emit_signal(SceneStringNames::get_singleton()->viewport_entered,p_viewport);
}
@@ -60,9 +60,9 @@ void VisibilityNotifier2D::_exit_viewport(Viewport* p_viewport){
if (is_inside_tree() && get_tree()->is_editor_hint())
return;
- emit_signal(SceneStringNames::get_singleton()->exit_viewport,p_viewport);
+ emit_signal(SceneStringNames::get_singleton()->viewport_exited,p_viewport);
if (viewports.size()==0) {
- emit_signal(SceneStringNames::get_singleton()->exit_screen);
+ emit_signal(SceneStringNames::get_singleton()->screen_exited);
_screen_exit();
}
@@ -129,22 +129,23 @@ bool VisibilityNotifier2D::is_on_screen() const {
void VisibilityNotifier2D::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_rect","rect"),&VisibilityNotifier2D::set_rect);
- ObjectTypeDB::bind_method(_MD("get_rect"),&VisibilityNotifier2D::get_rect);
- ObjectTypeDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier2D::is_on_screen);
+ ClassDB::bind_method(_MD("set_rect","rect"),&VisibilityNotifier2D::set_rect);
+ ClassDB::bind_method(_MD("get_rect"),&VisibilityNotifier2D::get_rect);
+ ClassDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier2D::is_on_screen);
ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
- ADD_SIGNAL( MethodInfo("enter_viewport",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
- ADD_SIGNAL( MethodInfo("exit_viewport",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
- ADD_SIGNAL( MethodInfo("enter_screen"));
- ADD_SIGNAL( MethodInfo("exit_screen"));
+ ADD_SIGNAL( MethodInfo("viewport_entered",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
+ ADD_SIGNAL( MethodInfo("viewport_exited",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
+ ADD_SIGNAL( MethodInfo("screen_entered"));
+ ADD_SIGNAL( MethodInfo("screen_exited"));
}
VisibilityNotifier2D::VisibilityNotifier2D() {
rect=Rect2(-10,-10,20,20);
+ set_notify_transform(true);
}
@@ -232,7 +233,7 @@ void VisibilityEnabler2D::_find_nodes(Node* p_node) {
if (add) {
- p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
+ p_node->connect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
nodes[p_node]=meta;
_change_node_state(p_node,false);
}
@@ -280,7 +281,7 @@ void VisibilityEnabler2D::_notification(int p_what){
if (!visible)
_change_node_state(E->key(),true);
- E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
+ E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed");
}
nodes.clear();
@@ -354,16 +355,16 @@ String VisibilityEnabler2D::get_configuration_warning() const {
void VisibilityEnabler2D::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler);
- ObjectTypeDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled);
- ObjectTypeDB::bind_method(_MD("_node_removed"),&VisibilityEnabler2D::_node_removed);
+ ClassDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler);
+ ClassDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled);
+ ClassDB::bind_method(_MD("_node_removed"),&VisibilityEnabler2D::_node_removed);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animated_sprites"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/fixed_process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animated_sprites"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fixed_process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS);
BIND_CONSTANT( ENABLER_FREEZE_BODIES );
BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index 354ccf4345..a896e270fe 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Viewport;
class VisibilityNotifier2D : public Node2D {
- OBJ_TYPE(VisibilityNotifier2D,Node2D);
+ GDCLASS(VisibilityNotifier2D,Node2D);
Set<Viewport*> viewports;
@@ -67,7 +67,7 @@ public:
class VisibilityEnabler2D : public VisibilityNotifier2D {
- OBJ_TYPE(VisibilityEnabler2D,VisibilityNotifier2D);
+ GDCLASS(VisibilityEnabler2D,VisibilityNotifier2D);
public:
enum Enabler {
diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp
index ed753ef745..588f343048 100644
--- a/scene/2d/y_sort.cpp
+++ b/scene/2d/y_sort.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,10 +43,11 @@ bool YSort::is_sort_enabled() const {
void YSort::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sort_enabled","enabled"),&YSort::set_sort_enabled);
- ObjectTypeDB::bind_method(_MD("is_sort_enabled"),&YSort::is_sort_enabled);
+ ClassDB::bind_method(_MD("set_sort_enabled","enabled"),&YSort::set_sort_enabled);
+ ClassDB::bind_method(_MD("is_sort_enabled"),&YSort::is_sort_enabled);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort/enabled"),_SCS("set_sort_enabled"),_SCS("is_sort_enabled"));
+ ADD_GROUP("Sort","sort_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort_enabled"),_SCS("set_sort_enabled"),_SCS("is_sort_enabled"));
}
diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h
index c8fa152c75..ebfe695da1 100644
--- a/scene/2d/y_sort.h
+++ b/scene/2d/y_sort.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/2d/node_2d.h"
class YSort : public Node2D {
- OBJ_TYPE(YSort,Node2D);
+ GDCLASS(YSort,Node2D);
bool sort_enabled;
static void _bind_methods();
public:
diff --git a/scene/3d/SCsub b/scene/3d/SCsub
index 116e641593..90e78ba8d3 100644
--- a/scene/3d/SCsub
+++ b/scene/3d/SCsub
@@ -1,11 +1,13 @@
+#!/usr/bin/env python
+
Import('env')
-if (env["disable_3d"]=="yes"):
+if (env["disable_3d"] == "yes"):
- env.scene_sources.append("3d/spatial.cpp")
- env.scene_sources.append("3d/skeleton.cpp")
+ env.scene_sources.append("3d/spatial.cpp")
+ env.scene_sources.append("3d/skeleton.cpp")
else:
- env.add_source_files(env.scene_sources,"*.cpp")
+ env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index a8a4122016..99e40984c5 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -126,10 +126,10 @@ void Area::_body_enter_tree(ObjectID p_id) {
ERR_FAIL_COND(E->get().in_tree);
E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
}
}
@@ -144,10 +144,10 @@ void Area::_body_exit_tree(ObjectID p_id) {
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
}
}
@@ -174,10 +174,10 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
E->get().rc=0;
E->get().in_tree=node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
}
}
@@ -188,7 +188,7 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,objid,node,p_body_shape,p_area_shape);
}
} else {
@@ -203,10 +203,10 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
if (E->get().rc==0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree);
if (E->get().in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,obj);
}
@@ -214,7 +214,7 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
}
if (node && E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,objid,obj,p_body_shape,p_area_shape);
}
if (eraseit)
@@ -250,13 +250,13 @@ void Area::_clear_monitoring() {
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
}
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,obj);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree);
}
}
@@ -277,13 +277,13 @@ void Area::_clear_monitoring() {
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_exited,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
}
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exited,obj);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree);
}
}
@@ -295,7 +295,7 @@ void Area::_notification(int p_what) {
}
}
-void Area::set_enable_monitoring(bool p_enable) {
+void Area::set_monitoring(bool p_enable) {
if (locked) {
ERR_EXPLAIN("This function can't be used during the in/out signal.");
@@ -331,10 +331,10 @@ void Area::_area_enter_tree(ObjectID p_id) {
ERR_FAIL_COND(E->get().in_tree);
E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->area_entered,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_entered,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
}
}
@@ -348,10 +348,10 @@ void Area::_area_exit_tree(ObjectID p_id) {
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->area_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->area_exited,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_exited,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
}
}
@@ -378,10 +378,10 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
E->get().rc=0;
E->get().in_tree=node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->area_entered,node);
}
}
@@ -393,7 +393,7 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,objid,node,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_entered,objid,node,p_area_shape,p_self_shape);
}
} else {
@@ -408,10 +408,10 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
if (E->get().rc==0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree);
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exited,obj);
}
}
@@ -420,7 +420,7 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
}
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,objid,obj,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_shape_exited,objid,obj,p_area_shape,p_self_shape);
}
if (eraseit)
@@ -433,7 +433,7 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
}
-bool Area::is_monitoring_enabled() const {
+bool Area::is_monitoring() const {
return monitoring;
}
@@ -576,74 +576,74 @@ bool Area::get_layer_mask_bit(int p_bit) const{
void Area::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_body_enter_tree","id"),&Area::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree","id"),&Area::_body_exit_tree);
+ ClassDB::bind_method(_MD("_body_enter_tree","id"),&Area::_body_enter_tree);
+ ClassDB::bind_method(_MD("_body_exit_tree","id"),&Area::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("_area_enter_tree","id"),&Area::_area_enter_tree);
- ObjectTypeDB::bind_method(_MD("_area_exit_tree","id"),&Area::_area_exit_tree);
+ ClassDB::bind_method(_MD("_area_enter_tree","id"),&Area::_area_enter_tree);
+ ClassDB::bind_method(_MD("_area_exit_tree","id"),&Area::_area_exit_tree);
- ObjectTypeDB::bind_method(_MD("set_space_override_mode","enable"),&Area::set_space_override_mode);
- ObjectTypeDB::bind_method(_MD("get_space_override_mode"),&Area::get_space_override_mode);
+ ClassDB::bind_method(_MD("set_space_override_mode","enable"),&Area::set_space_override_mode);
+ ClassDB::bind_method(_MD("get_space_override_mode"),&Area::get_space_override_mode);
- ObjectTypeDB::bind_method(_MD("set_gravity_is_point","enable"),&Area::set_gravity_is_point);
- ObjectTypeDB::bind_method(_MD("is_gravity_a_point"),&Area::is_gravity_a_point);
+ ClassDB::bind_method(_MD("set_gravity_is_point","enable"),&Area::set_gravity_is_point);
+ ClassDB::bind_method(_MD("is_gravity_a_point"),&Area::is_gravity_a_point);
- ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area::set_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"),&Area::get_gravity_distance_scale);
+ ClassDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area::set_gravity_distance_scale);
+ ClassDB::bind_method(_MD("get_gravity_distance_scale"),&Area::get_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("set_gravity_vector","vector"),&Area::set_gravity_vector);
- ObjectTypeDB::bind_method(_MD("get_gravity_vector"),&Area::get_gravity_vector);
+ ClassDB::bind_method(_MD("set_gravity_vector","vector"),&Area::set_gravity_vector);
+ ClassDB::bind_method(_MD("get_gravity_vector"),&Area::get_gravity_vector);
- ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&Area::set_gravity);
- ObjectTypeDB::bind_method(_MD("get_gravity"),&Area::get_gravity);
+ ClassDB::bind_method(_MD("set_gravity","gravity"),&Area::set_gravity);
+ ClassDB::bind_method(_MD("get_gravity"),&Area::get_gravity);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&Area::get_angular_damp);
+ ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area::set_angular_damp);
+ ClassDB::bind_method(_MD("get_angular_damp"),&Area::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&Area::get_linear_damp);
+ ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area::set_linear_damp);
+ ClassDB::bind_method(_MD("get_linear_damp"),&Area::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area::set_priority);
- ObjectTypeDB::bind_method(_MD("get_priority"),&Area::get_priority);
+ ClassDB::bind_method(_MD("set_priority","priority"),&Area::set_priority);
+ ClassDB::bind_method(_MD("get_priority"),&Area::get_priority);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area::get_collision_mask);
+ ClassDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area::set_collision_mask);
+ ClassDB::bind_method(_MD("get_collision_mask"),&Area::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area::get_layer_mask);
+ ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area::set_layer_mask);
+ ClassDB::bind_method(_MD("get_layer_mask"),&Area::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area::get_collision_mask_bit);
+ ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area::set_collision_mask_bit);
+ ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area::get_layer_mask_bit);
+ ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area::set_layer_mask_bit);
+ ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area::get_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_monitorable","enable"),&Area::set_monitorable);
- ObjectTypeDB::bind_method(_MD("is_monitorable"),&Area::is_monitorable);
+ ClassDB::bind_method(_MD("set_monitorable","enable"),&Area::set_monitorable);
+ ClassDB::bind_method(_MD("is_monitorable"),&Area::is_monitorable);
- ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area::set_enable_monitoring);
- ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area::is_monitoring_enabled);
+ ClassDB::bind_method(_MD("set_monitoring","enable"),&Area::set_monitoring);
+ ClassDB::bind_method(_MD("is_monitoring"),&Area::is_monitoring);
- ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"),&Area::get_overlapping_bodies);
- ObjectTypeDB::bind_method(_MD("get_overlapping_areas"),&Area::get_overlapping_areas);
+ ClassDB::bind_method(_MD("get_overlapping_bodies"),&Area::get_overlapping_bodies);
+ ClassDB::bind_method(_MD("get_overlapping_areas"),&Area::get_overlapping_areas);
- ObjectTypeDB::bind_method(_MD("overlaps_body","body"),&Area::overlaps_body);
- ObjectTypeDB::bind_method(_MD("overlaps_area","area"),&Area::overlaps_area);
+ ClassDB::bind_method(_MD("overlaps_body","body"),&Area::overlaps_body);
+ ClassDB::bind_method(_MD("overlaps_area","area"),&Area::overlaps_area);
- ObjectTypeDB::bind_method(_MD("_body_inout"),&Area::_body_inout);
- ObjectTypeDB::bind_method(_MD("_area_inout"),&Area::_area_inout);
+ ClassDB::bind_method(_MD("_body_inout"),&Area::_body_inout);
+ ClassDB::bind_method(_MD("_area_inout"),&Area::_area_inout);
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
+ ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("body_entered",PropertyInfo(Variant::OBJECT,"body")));
+ ADD_SIGNAL( MethodInfo("body_exited",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
- ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
+ ADD_SIGNAL( MethodInfo("area_shape_entered",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_shape_exited",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_entered",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
+ ADD_SIGNAL( MethodInfo("area_exited",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
ADD_PROPERTY( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
@@ -653,10 +653,11 @@ void Area::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_monitoring"),_SCS("is_monitoring"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_GROUP("Collision","collision_");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
}
@@ -675,7 +676,7 @@ Area::Area() : CollisionObject(PhysicsServer::get_singleton()->area_create(),tru
collision_mask=1;
layer_mask=1;
set_ray_pickable(false);
- set_enable_monitoring(true);
+ set_monitoring(true);
set_monitorable(true);
}
diff --git a/scene/3d/area.h b/scene/3d/area.h
index 440a7d2030..7956846505 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Area : public CollisionObject {
- OBJ_TYPE( Area, CollisionObject );
+ GDCLASS( Area, CollisionObject );
public:
enum SpaceOverride {
@@ -153,8 +153,8 @@ public:
void set_priority(real_t p_priority);
real_t get_priority() const;
- void set_enable_monitoring(bool p_enable);
- bool is_monitoring_enabled() const;
+ void set_monitoring(bool p_enable);
+ bool is_monitoring() const;
void set_monitorable(bool p_enable);
bool is_monitorable() const;
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index ca3a309568..e42439bf3b 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,82 +28,1741 @@
/*************************************************************************/
#include "baked_light_instance.h"
#include "scene/scene_string_names.h"
+#include "mesh_instance.h"
+#include "light.h"
+#include "math.h"
+#define FINDMINMAX(x0,x1,x2,min,max) \
+ min = max = x0; \
+ if(x1<min) min=x1;\
+ if(x1>max) max=x1;\
+ if(x2<min) min=x2;\
+ if(x2>max) max=x2;
-RID BakedLightInstance::get_baked_light_instance() const {
+static bool planeBoxOverlap(Vector3 normal,float d, Vector3 maxbox)
+{
+ int q;
+ Vector3 vmin,vmax;
+ for(q=0;q<=2;q++)
+ {
+ if(normal[q]>0.0f)
+ {
+ vmin[q]=-maxbox[q];
+ vmax[q]=maxbox[q];
+ }
+ else
+ {
+ vmin[q]=maxbox[q];
+ vmax[q]=-maxbox[q];
+ }
+ }
+ if(normal.dot(vmin)+d>0.0f) return false;
+ if(normal.dot(vmax)+d>=0.0f) return true;
- if (baked_light.is_null())
- return RID();
- else
- return get_instance();
+ return false;
+}
+
+
+/*======================== X-tests ========================*/
+#define AXISTEST_X01(a, b, fa, fb) \
+ p0 = a*v0.y - b*v0.z; \
+ p2 = a*v2.y - b*v2.z; \
+ if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
+ rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+#define AXISTEST_X2(a, b, fa, fb) \
+ p0 = a*v0.y - b*v0.z; \
+ p1 = a*v1.y - b*v1.z; \
+ if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
+ rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+/*======================== Y-tests ========================*/
+#define AXISTEST_Y02(a, b, fa, fb) \
+ p0 = -a*v0.x + b*v0.z; \
+ p2 = -a*v2.x + b*v2.z; \
+ if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+#define AXISTEST_Y1(a, b, fa, fb) \
+ p0 = -a*v0.x + b*v0.z; \
+ p1 = -a*v1.x + b*v1.z; \
+ if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+/*======================== Z-tests ========================*/
+
+#define AXISTEST_Z12(a, b, fa, fb) \
+ p1 = a*v1.x - b*v1.y; \
+ p2 = a*v2.x - b*v2.y; \
+ if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \
+ if(min>rad || max<-rad) return false;
+
+#define AXISTEST_Z0(a, b, fa, fb) \
+ p0 = a*v0.x - b*v0.y; \
+ p1 = a*v1.x - b*v1.y; \
+ if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \
+ if(min>rad || max<-rad) return false;
+
+static bool fast_tri_box_overlap(const Vector3& boxcenter,const Vector3 boxhalfsize,const Vector3 *triverts) {
+
+ /* use separating axis theorem to test overlap between triangle and box */
+ /* need to test for overlap in these directions: */
+ /* 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */
+ /* we do not even need to test these) */
+ /* 2) normal of the triangle */
+ /* 3) crossproduct(edge from tri, {x,y,z}-directin) */
+ /* this gives 3x3=9 more tests */
+ Vector3 v0,v1,v2;
+ float min,max,d,p0,p1,p2,rad,fex,fey,fez;
+ Vector3 normal,e0,e1,e2;
+
+ /* This is the fastest branch on Sun */
+ /* move everything so that the boxcenter is in (0,0,0) */
+
+ v0=triverts[0]-boxcenter;
+ v1=triverts[1]-boxcenter;
+ v2=triverts[2]-boxcenter;
+
+ /* compute triangle edges */
+ e0=v1-v0; /* tri edge 0 */
+ e1=v2-v1; /* tri edge 1 */
+ e2=v0-v2; /* tri edge 2 */
+
+ /* Bullet 3: */
+ /* test the 9 tests first (this was faster) */
+ fex = Math::abs(e0.x);
+ fey = Math::abs(e0.y);
+ fez = Math::abs(e0.z);
+ AXISTEST_X01(e0.z, e0.y, fez, fey);
+ AXISTEST_Y02(e0.z, e0.x, fez, fex);
+ AXISTEST_Z12(e0.y, e0.x, fey, fex);
+
+ fex = Math::abs(e1.x);
+ fey = Math::abs(e1.y);
+ fez = Math::abs(e1.z);
+ AXISTEST_X01(e1.z, e1.y, fez, fey);
+ AXISTEST_Y02(e1.z, e1.x, fez, fex);
+ AXISTEST_Z0(e1.y, e1.x, fey, fex);
+
+ fex = Math::abs(e2.x);
+ fey = Math::abs(e2.y);
+ fez = Math::abs(e2.z);
+ AXISTEST_X2(e2.z, e2.y, fez, fey);
+ AXISTEST_Y1(e2.z, e2.x, fez, fex);
+ AXISTEST_Z12(e2.y, e2.x, fey, fex);
+ /* Bullet 1: */
+ /* first test overlap in the {x,y,z}-directions */
+ /* find min, max of the triangle each direction, and test for overlap in */
+ /* that direction -- this is equivalent to testing a minimal AABB around */
+ /* the triangle against the AABB */
+
+ /* test in X-direction */
+ FINDMINMAX(v0.x,v1.x,v2.x,min,max);
+ if(min>boxhalfsize.x || max<-boxhalfsize.x) return false;
+
+ /* test in Y-direction */
+ FINDMINMAX(v0.y,v1.y,v2.y,min,max);
+ if(min>boxhalfsize.y || max<-boxhalfsize.y) return false;
+
+ /* test in Z-direction */
+ FINDMINMAX(v0.z,v1.z,v2.z,min,max);
+ if(min>boxhalfsize.z || max<-boxhalfsize.z) return false;
+
+ /* Bullet 2: */
+ /* test if the box intersects the plane of the triangle */
+ /* compute plane equation of triangle: normal*x+d=0 */
+ normal=e0.cross(e1);
+ d=-normal.dot(v0); /* plane eq: normal.x+d=0 */
+ if(!planeBoxOverlap(normal,d,boxhalfsize)) return false;
+
+ return true; /* box and triangle overlaps */
}
-void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
- baked_light=p_baked_light;
+Vector<Color> BakedLight::_get_bake_texture(Image &p_image,const Color& p_color) {
- RID base_rid;
+ Vector<Color> ret;
+
+ if (p_image.empty()) {
+
+ ret.resize(bake_texture_size*bake_texture_size);
+ for(int i=0;i<bake_texture_size*bake_texture_size;i++) {
+ ret[i]=p_color;
+ }
+
+ return ret;
+ }
- if (baked_light.is_valid())
- base_rid=baked_light->get_rid();
- else
- base_rid=RID();
+ p_image.convert(Image::FORMAT_RGBA8);
+ p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC);
- set_base(base_rid);
- if (is_inside_world()) {
+ PoolVector<uint8_t>::Read r = p_image.get_data().read();
+ ret.resize(bake_texture_size*bake_texture_size);
- emit_signal(SceneStringNames::get_singleton()->baked_light_changed);
+ for(int i=0;i<bake_texture_size*bake_texture_size;i++) {
+ Color c;
+ c.r = r[i*4+0]/255.0;
+ c.g = r[i*4+1]/255.0;
+ c.b = r[i*4+2]/255.0;
+ c.a = r[i*4+3]/255.0;
+ ret[i]=c;
-// for (List<Node*>::Element *E=baked_geometry.front();E;E=E->next()) {
-// VS::get_singleton()->instance_geometry_set_baked_light(E->get()->get_instance(),baked_light.is_valid()?get_instance():RID());
-// }
}
- update_configuration_warning();
+ return ret;
}
-Ref<BakedLight> BakedLightInstance::get_baked_light() const{
- return baked_light;
+BakedLight::MaterialCache BakedLight::_get_material_cache(Ref<Material> p_material) {
+
+ //this way of obtaining materials is inaccurate and also does not support some compressed formats very well
+ Ref<FixedSpatialMaterial> mat = p_material;
+
+ Ref<Material> material = mat; //hack for now
+
+ if (material_cache.has(material)) {
+ return material_cache[material];
+ }
+
+ MaterialCache mc;
+
+ if (mat.is_valid()) {
+
+
+ Ref<ImageTexture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO);
+
+ Image img_albedo;
+ if (albedo_tex.is_valid()) {
+
+ img_albedo = albedo_tex->get_data();
+ }
+
+ mc.albedo=_get_bake_texture(img_albedo,mat->get_albedo());
+
+ Ref<ImageTexture> emission_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_EMISSION);
+
+ Color emission_col = mat->get_emission();
+ emission_col.r*=mat->get_emission_energy();
+ emission_col.g*=mat->get_emission_energy();
+ emission_col.b*=mat->get_emission_energy();
+
+ Image img_emission;
+
+ if (emission_tex.is_valid()) {
+
+ img_emission = emission_tex->get_data();
+ }
+
+ mc.emission=_get_bake_texture(img_emission,emission_col);
+
+ } else {
+ Image empty;
+
+ mc.albedo=_get_bake_texture(empty,Color(0.7,0.7,0.7));
+ mc.emission=_get_bake_texture(empty,Color(0,0,0));
+
+
+ }
+
+ material_cache[p_material]=mc;
+ return mc;
+
+
}
-AABB BakedLightInstance::get_aabb() const {
- return AABB(Vector3(0,0,0),Vector3(1,1,1));
+
+static _FORCE_INLINE_ Vector2 get_uv(const Vector3& p_pos, const Vector3 *p_vtx, const Vector2* p_uv) {
+
+ if (p_pos.distance_squared_to(p_vtx[0])<CMP_EPSILON2)
+ return p_uv[0];
+ if (p_pos.distance_squared_to(p_vtx[1])<CMP_EPSILON2)
+ return p_uv[1];
+ if (p_pos.distance_squared_to(p_vtx[2])<CMP_EPSILON2)
+ return p_uv[2];
+
+ Vector3 v0 = p_vtx[1] - p_vtx[0];
+ Vector3 v1 = p_vtx[2] - p_vtx[0];
+ Vector3 v2 = p_pos - p_vtx[0];
+
+ float d00 = v0.dot( v0);
+ float d01 = v0.dot( v1);
+ float d11 = v1.dot( v1);
+ float d20 = v2.dot( v0);
+ float d21 = v2.dot( v1);
+ float denom = (d00 * d11 - d01 * d01);
+ if (denom==0)
+ return p_uv[0];
+ float v = (d11 * d20 - d01 * d21) / denom;
+ float w = (d00 * d21 - d01 * d20) / denom;
+ float u = 1.0f - v - w;
+
+ return p_uv[0]*u + p_uv[1]*v + p_uv[2]*w;
}
-DVector<Face3> BakedLightInstance::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+void BakedLight::_plot_face(int p_idx, int p_level, const Vector3 *p_vtx, const Vector2* p_uv, const MaterialCache& p_material, const Rect3 &p_aabb) {
+
+
+
+ if (p_level==cell_subdiv-1) {
+ //plot the face by guessing it's albedo and emission value
+
+ //find best axis to map to, for scanning values
+ int closest_axis;
+ float closest_dot;
+
+ Vector3 normal = Plane(p_vtx[0],p_vtx[1],p_vtx[2]).normal;
+
+ for(int i=0;i<3;i++) {
+
+ Vector3 axis;
+ axis[i]=1.0;
+ float dot=ABS(normal.dot(axis));
+ if (i==0 || dot>closest_dot) {
+ closest_axis=i;
+ closest_dot=dot;
+ }
+ }
+
+ Vector3 axis;
+ axis[closest_axis]=1.0;
+ Vector3 t1;
+ t1[(closest_axis+1)%3]=1.0;
+ Vector3 t2;
+ t2[(closest_axis+2)%3]=1.0;
+
+ t1*=p_aabb.size[(closest_axis+1)%3]/float(color_scan_cell_width);
+ t2*=p_aabb.size[(closest_axis+2)%3]/float(color_scan_cell_width);
+
+ Color albedo_accum;
+ Color emission_accum;
+ float alpha=0.0;
+
+ //map to a grid average in the best axis for this face
+ for(int i=0;i<color_scan_cell_width;i++) {
+
+ Vector3 ofs_i=float(i)*t1;
+
+ for(int j=0;j<color_scan_cell_width;j++) {
+
+ Vector3 ofs_j=float(j)*t2;
+
+ Vector3 from = p_aabb.pos+ofs_i+ofs_j;
+ Vector3 to = from + t1 + t2 + axis * p_aabb.size[closest_axis];
+ Vector3 half = (to-from)*0.5;
+
+ //is in this cell?
+ if (!fast_tri_box_overlap(from+half,half,p_vtx)) {
+ continue; //face does not span this cell
+ }
+
+ //go from -size to +size*2 to avoid skipping collisions
+ Vector3 ray_from = from + (t1+t2)*0.5 - axis * p_aabb.size[closest_axis];
+ Vector3 ray_to = ray_from + axis * p_aabb.size[closest_axis]*2;
+
+ Vector3 intersection;
+
+ if (!Geometry::ray_intersects_triangle(ray_from,ray_to,p_vtx[0],p_vtx[1],p_vtx[2],&intersection)) {
+ //no intersect? look in edges
+
+ float closest_dist=1e20;
+ for(int j=0;j<3;j++) {
+ Vector3 c;
+ Vector3 inters;
+ Geometry::get_closest_points_between_segments(p_vtx[j],p_vtx[(j+1)%3],ray_from,ray_to,inters,c);
+ float d=c.distance_to(intersection);
+ if (j==0 || d<closest_dist) {
+ closest_dist=d;
+ intersection=inters;
+ }
+ }
+ }
+
+ Vector2 uv = get_uv(intersection,p_vtx,p_uv);
+
+
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+
+ int ofs = uv_y*bake_texture_size+uv_x;
+ albedo_accum.r+=p_material.albedo[ofs].r;
+ albedo_accum.g+=p_material.albedo[ofs].g;
+ albedo_accum.b+=p_material.albedo[ofs].b;
+ albedo_accum.a+=p_material.albedo[ofs].a;
+
+ emission_accum.r+=p_material.emission[ofs].r;
+ emission_accum.g+=p_material.emission[ofs].g;
+ emission_accum.b+=p_material.emission[ofs].b;
+ alpha+=1.0;
+
+ }
+ }
+
+
+ if (alpha==0) {
+ //could not in any way get texture information.. so use closest point to center
+
+ Face3 f( p_vtx[0],p_vtx[1],p_vtx[2]);
+ Vector3 inters = f.get_closest_point_to(p_aabb.pos+p_aabb.size*0.5);
+
+ Vector2 uv = get_uv(inters,p_vtx,p_uv);
+
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+
+ int ofs = uv_y*bake_texture_size+uv_x;
+
+ alpha = 1.0/(color_scan_cell_width*color_scan_cell_width);
+
+ albedo_accum.r=p_material.albedo[ofs].r*alpha;
+ albedo_accum.g=p_material.albedo[ofs].g*alpha;
+ albedo_accum.b=p_material.albedo[ofs].b*alpha;
+ albedo_accum.a=p_material.albedo[ofs].a*alpha;
+
+ emission_accum.r=p_material.emission[ofs].r*alpha;
+ emission_accum.g=p_material.emission[ofs].g*alpha;
+ emission_accum.b=p_material.emission[ofs].b*alpha;
+
+
+ zero_alphas++;
+ } else {
+
+ float accdiv = 1.0/(color_scan_cell_width*color_scan_cell_width);
+ alpha*=accdiv;
+
+ albedo_accum.r*=accdiv;
+ albedo_accum.g*=accdiv;
+ albedo_accum.b*=accdiv;
+ albedo_accum.a*=accdiv;
+
+ emission_accum.r*=accdiv;
+ emission_accum.g*=accdiv;
+ emission_accum.b*=accdiv;
+ }
+
+ //put this temporarily here, corrected in a later step
+ bake_cells_write[p_idx].albedo[0]+=albedo_accum.r;
+ bake_cells_write[p_idx].albedo[1]+=albedo_accum.g;
+ bake_cells_write[p_idx].albedo[2]+=albedo_accum.b;
+ bake_cells_write[p_idx].light[0]+=emission_accum.r;
+ bake_cells_write[p_idx].light[1]+=emission_accum.g;
+ bake_cells_write[p_idx].light[2]+=emission_accum.b;
+ bake_cells_write[p_idx].alpha+=alpha;
+
+ static const Vector3 side_normals[6]={
+ Vector3(-1, 0, 0),
+ Vector3( 1, 0, 0),
+ Vector3( 0,-1, 0),
+ Vector3( 0, 1, 0),
+ Vector3( 0, 0,-1),
+ Vector3( 0, 0, 1),
+ };
+
+ for(int i=0;i<6;i++) {
+ if (normal.dot(side_normals[i])>CMP_EPSILON) {
+ bake_cells_write[p_idx].used_sides|=(1<<i);
+ }
+ }
+
+
+ } else {
+ //go down
+ for(int i=0;i<8;i++) {
+
+ Rect3 aabb=p_aabb;
+ aabb.size*=0.5;
+
+ if (i&1)
+ aabb.pos.x+=aabb.size.x;
+ if (i&2)
+ aabb.pos.y+=aabb.size.y;
+ if (i&4)
+ aabb.pos.z+=aabb.size.z;
+
+ {
+ Rect3 test_aabb=aabb;
+ //test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time
+ Vector3 qsize = test_aabb.size*0.5; //quarter size, for fast aabb test
+
+ if (!fast_tri_box_overlap(test_aabb.pos+qsize,qsize,p_vtx)) {
+ //if (!Face3(p_vtx[0],p_vtx[1],p_vtx[2]).intersects_aabb2(aabb)) {
+ //does not fit in child, go on
+ continue;
+ }
+
+ }
+
+ if (bake_cells_write[p_idx].childs[i]==CHILD_EMPTY) {
+ //sub cell must be created
+
+ if (bake_cells_used==(1<<bake_cells_alloc)) {
+ //exhausted cells, creating more space
+ bake_cells_alloc++;
+ bake_cells_write=PoolVector<BakeCell>::Write();
+ bake_cells.resize(1<<bake_cells_alloc);
+ bake_cells_write=bake_cells.write();
+ }
+
+ bake_cells_write[p_idx].childs[i]=bake_cells_used;
+ bake_cells_level_used[p_level+1]++;
+ bake_cells_used++;
+
+
+ }
+
+
+ _plot_face(bake_cells_write[p_idx].childs[i],p_level+1,p_vtx,p_uv,p_material,aabb);
+ }
+ }
+}
+
+
+
+void BakedLight::_fixup_plot(int p_idx, int p_level,int p_x,int p_y, int p_z) {
+
+
+
+ if (p_level==cell_subdiv-1) {
+
+
+ float alpha = bake_cells_write[p_idx].alpha;
+
+ bake_cells_write[p_idx].albedo[0]/=alpha;
+ bake_cells_write[p_idx].albedo[1]/=alpha;
+ bake_cells_write[p_idx].albedo[2]/=alpha;
+
+ //transfer emission to light
+ bake_cells_write[p_idx].light[0]/=alpha;
+ bake_cells_write[p_idx].light[1]/=alpha;
+ bake_cells_write[p_idx].light[2]/=alpha;
+
+ bake_cells_write[p_idx].alpha=1.0;
+
+ //remove neighbours from used sides
+
+ for(int n=0;n<6;n++) {
+
+ int ofs[3]={0,0,0};
+
+ ofs[n/2]=(n&1)?1:-1;
+
+ //convert to x,y,z on this level
+ int x=p_x;
+ int y=p_y;
+ int z=p_z;
+
+ x+=ofs[0];
+ y+=ofs[1];
+ z+=ofs[2];
+
+ int ofs_x=0;
+ int ofs_y=0;
+ int ofs_z=0;
+ int size = 1<<p_level;
+ int half=size/2;
+
+
+ if (x<0 || x>=size || y<0 || y>=size || z<0 || z>=size) {
+ //neighbour is out, can't use it
+ bake_cells_write[p_idx].used_sides&=~(1<<uint32_t(n));
+ continue;
+ }
+
+ uint32_t neighbour=0;
+
+ for(int i=0;i<cell_subdiv-1;i++) {
+
+ BakeCell *bc = &bake_cells_write[neighbour];
+
+ int child = 0;
+ if (x >= ofs_x + half) {
+ child|=1;
+ ofs_x+=half;
+ }
+ if (y >= ofs_y + half) {
+ child|=2;
+ ofs_y+=half;
+ }
+ if (z >= ofs_z + half) {
+ child|=4;
+ ofs_z+=half;
+ }
+
+ neighbour = bc->childs[child];
+ if (neighbour==CHILD_EMPTY) {
+ break;
+ }
+
+ half>>=1;
+ }
+
+ if (neighbour!=CHILD_EMPTY) {
+ bake_cells_write[p_idx].used_sides&=~(1<<uint32_t(n));
+ }
+ }
+ } else {
+
+
+ //go down
+
+ float alpha_average=0;
+ int half = cells_per_axis >> (p_level+1);
+ for(int i=0;i<8;i++) {
+
+ uint32_t child = bake_cells_write[p_idx].childs[i];
+
+ if (child==CHILD_EMPTY)
+ continue;
+
+
+ int nx=p_x;
+ int ny=p_y;
+ int nz=p_z;
+
+ if (i&1)
+ nx+=half;
+ if (i&2)
+ ny+=half;
+ if (i&4)
+ nz+=half;
+
+ _fixup_plot(child,p_level+1,nx,ny,nz);
+ alpha_average+=bake_cells_write[child].alpha;
+ }
+
+ bake_cells_write[p_idx].alpha=alpha_average/8.0;
+ bake_cells_write[p_idx].light[0]=0;
+ bake_cells_write[p_idx].light[1]=0;
+ bake_cells_write[p_idx].light[2]=0;
+ bake_cells_write[p_idx].albedo[0]=0;
+ bake_cells_write[p_idx].albedo[1]=0;
+ bake_cells_write[p_idx].albedo[2]=0;
+
+ }
+
+ //clean up light
+ bake_cells_write[p_idx].light_pass=0;
+ //find neighbours
+
+
+
}
-String BakedLightInstance::get_configuration_warning() const {
- if (get_baked_light().is_null()) {
- return TTR("BakedLightInstance does not contain a BakedLight resource.");
+void BakedLight::_bake_add_mesh(const Transform& p_xform,Ref<Mesh>& p_mesh) {
+
+
+ for(int i=0;i<p_mesh->get_surface_count();i++) {
+
+ if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
+ continue; //only triangles
+
+ MaterialCache material = _get_material_cache(p_mesh->surface_get_material(i));
+
+ Array a = p_mesh->surface_get_arrays(i);
+
+
+ PoolVector<Vector3> vertices = a[Mesh::ARRAY_VERTEX];
+ PoolVector<Vector3>::Read vr=vertices.read();
+ PoolVector<Vector2> uv = a[Mesh::ARRAY_TEX_UV];
+ PoolVector<Vector2>::Read uvr;
+ PoolVector<int> index = a[Mesh::ARRAY_INDEX];
+
+ bool read_uv=false;
+
+ if (uv.size()) {
+
+ uvr=uv.read();
+ read_uv=true;
+ }
+
+ if (index.size()) {
+
+ int facecount = index.size()/3;
+ PoolVector<int>::Read ir=index.read();
+
+ for(int j=0;j<facecount;j++) {
+
+ Vector3 vtxs[3];
+ Vector2 uvs[3];
+
+ for(int k=0;k<3;k++) {
+ vtxs[k]=p_xform.xform(vr[ir[j*3+k]]);
+ }
+
+ if (read_uv) {
+ for(int k=0;k<3;k++) {
+ uvs[k]=uvr[ir[j*3+k]];
+ }
+ }
+
+ //plot face
+ _plot_face(0,0,vtxs,uvs,material,bounds);
+ }
+
+
+
+ } else {
+
+ int facecount = vertices.size()/3;
+
+ for(int j=0;j<facecount;j++) {
+
+ Vector3 vtxs[3];
+ Vector2 uvs[3];
+
+ for(int k=0;k<3;k++) {
+ vtxs[k]=p_xform.xform(vr[j*3+k]);
+ }
+
+ if (read_uv) {
+ for(int k=0;k<3;k++) {
+ uvs[k]=uvr[j*3+k];
+ }
+ }
+
+ //plot face
+ _plot_face(0,0,vtxs,uvs,material,bounds);
+ }
+
+ }
+ }
+}
+
+
+
+void BakedLight::_bake_add_to_aabb(const Transform& p_xform,Ref<Mesh>& p_mesh,bool &first) {
+
+ for(int i=0;i<p_mesh->get_surface_count();i++) {
+
+ if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
+ continue; //only triangles
+
+ Array a = p_mesh->surface_get_arrays(i);
+ PoolVector<Vector3> vertices = a[Mesh::ARRAY_VERTEX];
+ int vc = vertices.size();
+ PoolVector<Vector3>::Read vr=vertices.read();
+
+ if (first) {
+ bounds.pos=p_xform.xform(vr[0]);
+ first=false;
+ }
+
+
+ for(int j=0;j<vc;j++) {
+ bounds.expand_to(p_xform.xform(vr[j]));
+ }
+ }
+}
+
+void BakedLight::bake() {
+
+
+ bake_cells_alloc=16;
+ bake_cells.resize(1<<bake_cells_alloc);
+ bake_cells_used=1;
+ cells_per_axis=(1<<(cell_subdiv-1));
+ zero_alphas=0;
+
+ bool aabb_first=true;
+ print_line("Generating AABB");
+
+ bake_cells_level_used.resize(cell_subdiv);
+ for(int i=0;i<cell_subdiv;i++) {
+ bake_cells_level_used[i]=0;
+ }
+
+ int count=0;
+ for (Set<GeometryInstance*>::Element *E=geometries.front();E;E=E->next()) {
+
+ print_line("aabb geom "+itos(count)+"/"+itos(geometries.size()));
+
+ GeometryInstance *geom = E->get();
+
+ if (geom->cast_to<MeshInstance>()) {
+
+ MeshInstance *mesh_instance = geom->cast_to<MeshInstance>();
+ Ref<Mesh> mesh = mesh_instance->get_mesh();
+ if (mesh.is_valid()) {
+
+ _bake_add_to_aabb(geom->get_relative_transform(this),mesh,aabb_first);
+ }
+ }
+ count++;
+ }
+
+ print_line("AABB: "+bounds);
+ ERR_FAIL_COND(aabb_first);
+
+ bake_cells_write = bake_cells.write();
+ count=0;
+
+ for (Set<GeometryInstance*>::Element *E=geometries.front();E;E=E->next()) {
+
+ GeometryInstance *geom = E->get();
+ print_line("plot geom "+itos(count)+"/"+itos(geometries.size()));
+
+ if (geom->cast_to<MeshInstance>()) {
+
+ MeshInstance *mesh_instance = geom->cast_to<MeshInstance>();
+ Ref<Mesh> mesh = mesh_instance->get_mesh();
+ if (mesh.is_valid()) {
+
+ _bake_add_mesh(geom->get_relative_transform(this),mesh);
+ }
+ }
+
+ count++;
+ }
+
+
+ _fixup_plot(0, 0,0,0,0);
+
+
+ bake_cells_write=PoolVector<BakeCell>::Write();
+
+ bake_cells.resize(bake_cells_used);
+
+
+
+ print_line("total bake cells used: "+itos(bake_cells_used));
+ for(int i=0;i<cell_subdiv;i++) {
+ print_line("level "+itos(i)+": "+itos(bake_cells_level_used[i]));
+ }
+ print_line("zero alphas: "+itos(zero_alphas));
+
+
+
+}
+
+
+
+void BakedLight::_bake_directional(int p_idx, int p_level, int p_x,int p_y,int p_z,const Vector3& p_dir,const Color& p_color,int p_sign) {
+
+
+
+
+ if (p_level==cell_subdiv-1) {
+
+ Vector3 end;
+ end.x = float(p_x+0.5) / cells_per_axis;
+ end.y = float(p_y+0.5) / cells_per_axis;
+ end.z = float(p_z+0.5) / cells_per_axis;
+
+ end = bounds.pos + bounds.size*end;
+
+ float max_ray_len = (bounds.size).length()*1.2;
+
+ Vector3 begin = end + max_ray_len*-p_dir;
+
+ //clip begin
+
+ for(int i=0;i<3;i++) {
+
+ if (ABS(p_dir[i])<CMP_EPSILON) {
+ continue; // parallel to axis, don't clip
+ }
+
+ Plane p;
+ p.normal[i]=1.0;
+ p.d=bounds.pos[i];
+ if (p_dir[i]<0) {
+ p.d+=bounds.size[i];
+ }
+
+ Vector3 inters;
+ if (p.intersects_segment(end,begin,&inters)) {
+ begin=inters;
+ }
+
+ }
+
+
+ int idx = _plot_ray(begin,end);
+
+ if (idx>=0 && light_pass!=bake_cells_write[idx].light_pass) {
+ //hit something, add or remove light to it
+
+ Color albedo = Color(bake_cells_write[idx].albedo[0],bake_cells_write[idx].albedo[1],bake_cells_write[idx].albedo[2]);
+ bake_cells_write[idx].light[0]+=albedo.r*p_color.r*p_sign;
+ bake_cells_write[idx].light[1]+=albedo.g*p_color.g*p_sign;
+ bake_cells_write[idx].light[2]+=albedo.b*p_color.b*p_sign;
+ bake_cells_write[idx].light_pass=light_pass;
+
+ }
+
+
+ } else {
+
+ int half = cells_per_axis >> (p_level+1);
+
+ //go down
+ for(int i=0;i<8;i++) {
+
+ uint32_t child = bake_cells_write[p_idx].childs[i];
+
+ if (child==CHILD_EMPTY)
+ continue;
+
+ int nx=p_x;
+ int ny=p_y;
+ int nz=p_z;
+
+ if (i&1)
+ nx+=half;
+ if (i&2)
+ ny+=half;
+ if (i&4)
+ nz+=half;
+
+
+ _bake_directional(child,p_level+1,nx,ny,nz,p_dir,p_color,p_sign);
+ }
}
+}
+
+
+
+
+void BakedLight::_bake_light(Light* p_light) {
+
+ if (p_light->cast_to<DirectionalLight>()) {
+
+ DirectionalLight * dl = p_light->cast_to<DirectionalLight>();
+
+ Transform rel_xf = dl->get_relative_transform(this);
+
+ Vector3 light_dir = -rel_xf.basis.get_axis(2);
+
+ Color color = dl->get_color();
+ float nrg = dl->get_param(Light::PARAM_ENERGY);;
+ color.r*=nrg;
+ color.g*=nrg;
+ color.b*=nrg;
+
+ light_pass++;
+ _bake_directional(0,0,0,0,0,light_dir,color,1);
+
+ }
+}
+
+
+void BakedLight::_upscale_light(int p_idx,int p_level) {
+
+
+ //go down
+
+ float light_accum[3]={0,0,0};
+ float alpha_accum=0;
+
+ bool check_children = p_level < (cell_subdiv -2);
+
+ for(int i=0;i<8;i++) {
+
+ uint32_t child = bake_cells_write[p_idx].childs[i];
+
+ if (child==CHILD_EMPTY)
+ continue;
+
+ if (check_children) {
+ _upscale_light(child,p_level+1);
+ }
+
+ light_accum[0]+=bake_cells_write[child].light[0];
+ light_accum[1]+=bake_cells_write[child].light[1];
+ light_accum[2]+=bake_cells_write[child].light[2];
+ alpha_accum+=bake_cells_write[child].alpha;
+
+ }
+
+ bake_cells_write[p_idx].light[0]=light_accum[0]/8.0;
+ bake_cells_write[p_idx].light[1]=light_accum[1]/8.0;
+ bake_cells_write[p_idx].light[2]=light_accum[2]/8.0;
+ bake_cells_write[p_idx].alpha=alpha_accum/8.0;
+
+}
+
+
+void BakedLight::bake_lights() {
+
+ ERR_FAIL_COND(bake_cells.size()==0);
+
+ bake_cells_write = bake_cells.write();
+
+ for(Set<Light*>::Element *E=lights.front();E;E=E->next()) {
+
+ _bake_light(E->get());
+ }
+
+
+ _upscale_light(0,0);
+
+ bake_cells_write=PoolVector<BakeCell>::Write();
+
+}
+
+
+
+Color BakedLight::_cone_trace(const Vector3& p_from, const Vector3& p_dir, float p_half_angle) {
+
+
+ Color color(0,0,0,0);
+ float tha = Math::tan(p_half_angle);//tan half angle
+ Vector3 from =(p_from-bounds.pos)/bounds.size; //convert to 0..1
+ from/=cells_per_axis; //convert to voxels of size 1
+ Vector3 dir = (p_dir/bounds.size).normalized();
+
+ float max_dist = Vector3(cells_per_axis,cells_per_axis,cells_per_axis).length();
+
+ float dist = 1.0;
+ // self occlusion in flat surfaces
+
+ float alpha=0;
+
+
+ while(dist < max_dist && alpha < 0.95) {
+
+#if 0
+ // smallest sample diameter possible is the voxel size
+ float diameter = MAX(1.0, 2.0 * tha * dist);
+ float lod = log2(diameter);
+
+ Vector3 sample_pos = from + dist * dir;
+
+
+ Color samples_base[2][8]={{Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0)},
+ {Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0),Color(0,0,0,0)}};
+
+ float levelf = Math::fposmod(lod,1.0);
+ float fx = Math::fposmod(sample_pos.x,1.0);
+ float fy = Math::fposmod(sample_pos.y,1.0);
+ float fz = Math::fposmod(sample_pos.z,1.0);
+
+ for(int l=0;l<2;l++){
+
+ int bx = Math::floor(sample_pos.x);
+ int by = Math::floor(sample_pos.y);
+ int bz = Math::floor(sample_pos.z);
+
+ int lodn=int(Math::floor(lod))-l;
+
+ bx>>=lodn;
+ by>>=lodn;
+ bz>>=lodn;
+
+ int limit = MAX(0,cell_subdiv-lodn-1);
+
+ for(int c=0;c<8;c++) {
+
+ int x = bx;
+ int y = by;
+ int z = bz;
+
+ if (c&1) {
+ x+=1;
+ }
+ if (c&2) {
+ y+=1;
+ }
+ if (c&4) {
+ z+=1;
+ }
+
+ int ofs_x=0;
+ int ofs_y=0;
+ int ofs_z=0;
+ int size = cells_per_axis>>lodn;
+ int half=size/2;
+
+ bool outside=x<0 || x>=size || y<0 || y>=size || z<0 || z>=size;
+
+ if (outside)
+ continue;
+
+
+ uint32_t cell=0;
+
+ for(int i=0;i<limit;i++) {
+
+ BakeCell *bc = &bake_cells_write[cell];
+
+ int child = 0;
+ if (x >= ofs_x + half) {
+ child|=1;
+ ofs_x+=half;
+ }
+ if (y >= ofs_y + half) {
+ child|=2;
+ ofs_y+=half;
+ }
+ if (z >= ofs_z + half) {
+ child|=4;
+ ofs_z+=half;
+ }
+
+ cell = bc->childs[child];
+ if (cell==CHILD_EMPTY)
+ break;
+
+ half>>=1;
+ }
+
+ if (cell!=CHILD_EMPTY) {
+
+ samples_base[l][c].r=bake_cells_write[cell].light[0];
+ samples_base[l][c].g=bake_cells_write[cell].light[1];
+ samples_base[l][c].b=bake_cells_write[cell].light[2];
+ samples_base[l][c].a=bake_cells_write[cell].alpha;
+ }
+
+ }
+
+
+ }
+
+ Color m0x0 = samples_base[0][0].linear_interpolate(samples_base[0][1],fx);
+ Color m0x1 = samples_base[0][2].linear_interpolate(samples_base[0][3],fx);
+ Color m0y0 = m0x0.linear_interpolate(m0x1,fy);
+ m0x0 = samples_base[0][4].linear_interpolate(samples_base[0][5],fx);
+ m0x1 = samples_base[0][6].linear_interpolate(samples_base[0][7],fx);
+ Color m0y1 = m0x0.linear_interpolate(m0x1,fy);
+ Color m0z = m0y0.linear_interpolate(m0y1,fz);
+
+ Color m1x0 = samples_base[1][0].linear_interpolate(samples_base[1][1],fx);
+ Color m1x1 = samples_base[1][2].linear_interpolate(samples_base[1][3],fx);
+ Color m1y0 = m1x0.linear_interpolate(m1x1,fy);
+ m1x0 = samples_base[1][4].linear_interpolate(samples_base[1][5],fx);
+ m1x1 = samples_base[1][6].linear_interpolate(samples_base[1][7],fx);
+ Color m1y1 = m1x0.linear_interpolate(m1x1,fy);
+ Color m1z = m1y0.linear_interpolate(m1y1,fz);
+
+ Color m = m0z.linear_interpolate(m1z,levelf);
+#else
+ float diameter = 1.0;
+ Vector3 sample_pos = from + dist * dir;
+
+ Color m(0,0,0,0);
+ {
+ int x = Math::floor(sample_pos.x);
+ int y = Math::floor(sample_pos.y);
+ int z = Math::floor(sample_pos.z);
+
+ int ofs_x=0;
+ int ofs_y=0;
+ int ofs_z=0;
+ int size = cells_per_axis;
+ int half=size/2;
+
+ bool outside=x<0 || x>=size || y<0 || y>=size || z<0 || z>=size;
+
+ if (!outside) {
+
+
+ uint32_t cell=0;
+
+ for(int i=0;i<cell_subdiv-1;i++) {
+
+ BakeCell *bc = &bake_cells_write[cell];
+
+ int child = 0;
+ if (x >= ofs_x + half) {
+ child|=1;
+ ofs_x+=half;
+ }
+ if (y >= ofs_y + half) {
+ child|=2;
+ ofs_y+=half;
+ }
+ if (z >= ofs_z + half) {
+ child|=4;
+ ofs_z+=half;
+ }
+
+ cell = bc->childs[child];
+ if (cell==CHILD_EMPTY)
+ break;
+
+ half>>=1;
+ }
+
+ if (cell!=CHILD_EMPTY) {
+
+ m.r=bake_cells_write[cell].light[0];
+ m.g=bake_cells_write[cell].light[1];
+ m.b=bake_cells_write[cell].light[2];
+ m.a=bake_cells_write[cell].alpha;
+ }
+ }
+ }
+
+#endif
+ // front-to-back compositing
+ float a = (1.0 - alpha);
+ color.r += a * m.r;
+ color.g += a * m.g;
+ color.b += a * m.b;
+ alpha += a * m.a;
+ //occlusion += a * voxelColor.a;
+ //occlusion += (a * voxelColor.a) / (1.0 + 0.03 * diameter);
+ dist += diameter * 0.5; // smoother
+ //dist += diameter; // faster but misses more voxels
+ }
+
+ return color;
+}
+
+
+
+void BakedLight::_bake_radiance(int p_idx, int p_level, int p_x,int p_y,int p_z) {
+
+
+
+
+ if (p_level==cell_subdiv-1) {
+
+ const int NUM_CONES = 6;
+ Vector3 cone_directions[6] = {
+ Vector3(1, 0, 0),
+ Vector3(0.5, 0.866025, 0),
+ Vector3( 0.5, 0.267617, 0.823639),
+ Vector3( 0.5, -0.700629, 0.509037),
+ Vector3( 0.5, -0.700629, -0.509037),
+ Vector3( 0.5, 0.267617, -0.823639)
+ };
+ float coneWeights[6] = {0.25, 0.15, 0.15, 0.15, 0.15, 0.15};
+
+ Vector3 pos = (Vector3(p_x,p_y,p_z)/float(cells_per_axis))*bounds.size+bounds.pos;
+ Vector3 voxel_size = bounds.size/float(cells_per_axis);
+ pos+=voxel_size*0.5;
+
+ Color accum;
+
+ bake_cells_write[p_idx].light[0]=0;
+ bake_cells_write[p_idx].light[1]=0;
+ bake_cells_write[p_idx].light[2]=0;
+
+ int freepix=0;
+ for(int i=0;i<6;i++) {
+
+ if (!(bake_cells_write[p_idx].used_sides&(1<<i)))
+ continue;
+
+ if ((i&1)==0)
+ bake_cells_write[p_idx].light[i/2]=1.0;
+ freepix++;
+ continue;
+
+ int ofs = i/2;
+
+ Vector3 dir;
+ if ((i&1)==0)
+ dir[ofs]=1.0;
+ else
+ dir[ofs]=-1.0;
+
+ for(int j=0;j<1;j++) {
+
+
+ Vector3 cone_dir;
+ cone_dir.x = cone_directions[j][(ofs+0)%3];
+ cone_dir.y = cone_directions[j][(ofs+1)%3];
+ cone_dir.z = cone_directions[j][(ofs+2)%3];
+
+ cone_dir[ofs]*=dir[ofs];
+
+ Color res = _cone_trace(pos+dir*voxel_size,cone_dir,Math::deg2rad(29.9849));
+ accum.r+=res.r;//*coneWeights[j];
+ accum.g+=res.g;//*coneWeights[j];
+ accum.b+=res.b;//*coneWeights[j];
+ }
+
+
+ }
+#if 0
+ if (freepix==0) {
+ bake_cells_write[p_idx].light[0]=0;
+ bake_cells_write[p_idx].light[1]=0;
+ bake_cells_write[p_idx].light[2]=0;
+ }
+
+ if (freepix==1) {
+ bake_cells_write[p_idx].light[0]=1;
+ bake_cells_write[p_idx].light[1]=0;
+ bake_cells_write[p_idx].light[2]=0;
+ }
+
+ if (freepix==2) {
+ bake_cells_write[p_idx].light[0]=0;
+ bake_cells_write[p_idx].light[1]=1;
+ bake_cells_write[p_idx].light[2]=0;
+ }
+
+ if (freepix==3) {
+ bake_cells_write[p_idx].light[0]=1;
+ bake_cells_write[p_idx].light[1]=1;
+ bake_cells_write[p_idx].light[2]=0;
+ }
+
+ if (freepix==4) {
+ bake_cells_write[p_idx].light[0]=0;
+ bake_cells_write[p_idx].light[1]=0;
+ bake_cells_write[p_idx].light[2]=1;
+ }
+
+ if (freepix==5) {
+ bake_cells_write[p_idx].light[0]=1;
+ bake_cells_write[p_idx].light[1]=0;
+ bake_cells_write[p_idx].light[2]=1;
+ }
+
+ if (freepix==6) {
+ bake_cells_write[p_idx].light[0]=0;
+ bake_cells_write[p_idx].light[0]=1;
+ bake_cells_write[p_idx].light[0]=1;
+ }
+#endif
+ //bake_cells_write[p_idx].radiance[0]=accum.r;
+ //bake_cells_write[p_idx].radiance[1]=accum.g;
+ //bake_cells_write[p_idx].radiance[2]=accum.b;
+
+
+ } else {
+
+ int half = cells_per_axis >> (p_level+1);
+
+ //go down
+ for(int i=0;i<8;i++) {
+
+ uint32_t child = bake_cells_write[p_idx].childs[i];
+
+ if (child==CHILD_EMPTY)
+ continue;
+
+ int nx=p_x;
+ int ny=p_y;
+ int nz=p_z;
+
+ if (i&1)
+ nx+=half;
+ if (i&2)
+ ny+=half;
+ if (i&4)
+ nz+=half;
+
+
+ _bake_radiance(child,p_level+1,nx,ny,nz);
+ }
+ }
+}
+
+void BakedLight::bake_radiance() {
+
+ ERR_FAIL_COND(bake_cells.size()==0);
+
+ bake_cells_write = bake_cells.write();
+
+ _bake_radiance(0,0,0,0,0);
+
+ bake_cells_write=PoolVector<BakeCell>::Write();
+
+}
+int BakedLight::_find_cell(int x,int y, int z) {
+
+
+ uint32_t cell=0;
+
+ int ofs_x=0;
+ int ofs_y=0;
+ int ofs_z=0;
+ int size = cells_per_axis;
+ int half=size/2;
+
+ if (x<0 || x>=size)
+ return -1;
+ if (y<0 || y>=size)
+ return -1;
+ if (z<0 || z>=size)
+ return -1;
+
+ for(int i=0;i<cell_subdiv-1;i++) {
+
+ BakeCell *bc = &bake_cells_write[cell];
+
+ int child = 0;
+ if (x >= ofs_x + half) {
+ child|=1;
+ ofs_x+=half;
+ }
+ if (y >= ofs_y + half) {
+ child|=2;
+ ofs_y+=half;
+ }
+ if (z >= ofs_z + half) {
+ child|=4;
+ ofs_z+=half;
+ }
+
+ cell = bc->childs[child];
+ if (cell==CHILD_EMPTY)
+ return -1;
+
+ half>>=1;
+ }
+
+ return cell;
+
+}
+
+
+int BakedLight::_plot_ray(const Vector3& p_from, const Vector3& p_to) {
+
+ Vector3 from = (p_from - bounds.pos) / bounds.size;
+ Vector3 to = (p_to - bounds.pos) / bounds.size;
+
+ int x1 = Math::floor(from.x*cells_per_axis);
+ int y1 = Math::floor(from.y*cells_per_axis);
+ int z1 = Math::floor(from.z*cells_per_axis);
+
+ int x2 = Math::floor(to.x*cells_per_axis);
+ int y2 = Math::floor(to.y*cells_per_axis);
+ int z2 = Math::floor(to.z*cells_per_axis);
+
+
+ int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2;
+ int point[3];
+
+ point[0] = x1;
+ point[1] = y1;
+ point[2] = z1;
+ dx = x2 - x1;
+ dy = y2 - y1;
+ dz = z2 - z1;
+ x_inc = (dx < 0) ? -1 : 1;
+ l = ABS(dx);
+ y_inc = (dy < 0) ? -1 : 1;
+ m = ABS(dy);
+ z_inc = (dz < 0) ? -1 : 1;
+ n = ABS(dz);
+ dx2 = l << 1;
+ dy2 = m << 1;
+ dz2 = n << 1;
+
+ if ((l >= m) && (l >= n)) {
+ err_1 = dy2 - l;
+ err_2 = dz2 - l;
+ for (i = 0; i < l; i++) {
+ int cell = _find_cell(point[0],point[1],point[2]);
+ if (cell>=0)
+ return cell;
+
+ if (err_1 > 0) {
+ point[1] += y_inc;
+ err_1 -= dx2;
+ }
+ if (err_2 > 0) {
+ point[2] += z_inc;
+ err_2 -= dx2;
+ }
+ err_1 += dy2;
+ err_2 += dz2;
+ point[0] += x_inc;
+ }
+ } else if ((m >= l) && (m >= n)) {
+ err_1 = dx2 - m;
+ err_2 = dz2 - m;
+ for (i = 0; i < m; i++) {
+ int cell = _find_cell(point[0],point[1],point[2]);
+ if (cell>=0)
+ return cell;
+ if (err_1 > 0) {
+ point[0] += x_inc;
+ err_1 -= dy2;
+ }
+ if (err_2 > 0) {
+ point[2] += z_inc;
+ err_2 -= dy2;
+ }
+ err_1 += dx2;
+ err_2 += dz2;
+ point[1] += y_inc;
+ }
+ } else {
+ err_1 = dy2 - n;
+ err_2 = dx2 - n;
+ for (i = 0; i < n; i++) {
+ int cell = _find_cell(point[0],point[1],point[2]);
+ if (cell>=0)
+ return cell;
+
+ if (err_1 > 0) {
+ point[1] += y_inc;
+ err_1 -= dz2;
+ }
+ if (err_2 > 0) {
+ point[0] += x_inc;
+ err_2 -= dz2;
+ }
+ err_1 += dy2;
+ err_2 += dx2;
+ point[2] += z_inc;
+ }
+ }
+ return _find_cell(point[0],point[1],point[2]);
+
+}
+
+
+void BakedLight::set_cell_subdiv(int p_subdiv) {
+
+ cell_subdiv=p_subdiv;
+
+ //VS::get_singleton()->baked_light_set_subdivision(baked_light,p_subdiv);
+}
+
+int BakedLight::get_cell_subdiv() const {
+
+ return cell_subdiv;
+}
+
+
+
+Rect3 BakedLight::get_aabb() const {
+
+ return Rect3(Vector3(0,0,0),Vector3(1,1,1));
+}
+PoolVector<Face3> BakedLight::get_faces(uint32_t p_usage_flags) const {
+
+ return PoolVector<Face3>();
+}
+
+
+String BakedLight::get_configuration_warning() const {
return String();
}
-void BakedLightInstance::_bind_methods() {
+void BakedLight::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb,DebugMode p_mode,Ref<MultiMesh> &p_multimesh,int &idx) {
+
+
+ if (p_level==cell_subdiv-1) {
+
+ Vector3 center = p_aabb.pos+p_aabb.size*0.5;
+ Transform xform;
+ xform.origin=center;
+ xform.basis.scale(p_aabb.size*0.5);
+ p_multimesh->set_instance_transform(idx,xform);
+ Color col;
+ switch(p_mode) {
+ case DEBUG_ALBEDO: {
+ col=Color(bake_cells_write[p_idx].albedo[0],bake_cells_write[p_idx].albedo[1],bake_cells_write[p_idx].albedo[2]);
+ } break;
+ case DEBUG_LIGHT: {
+ col=Color(bake_cells_write[p_idx].light[0],bake_cells_write[p_idx].light[1],bake_cells_write[p_idx].light[2]);
+ Color colr=Color(bake_cells_write[p_idx].radiance[0],bake_cells_write[p_idx].radiance[1],bake_cells_write[p_idx].radiance[2]);
+ col.r+=colr.r;
+ col.g+=colr.g;
+ col.b+=colr.b;
+ } break;
+
+ }
+ p_multimesh->set_instance_color(idx,col);
+
+
+ idx++;
+
+ } else {
+
+ for(int i=0;i<8;i++) {
+
+ if (bake_cells_write[p_idx].childs[i]==CHILD_EMPTY)
+ continue;
+
+ Rect3 aabb=p_aabb;
+ aabb.size*=0.5;
+
+ if (i&1)
+ aabb.pos.x+=aabb.size.x;
+ if (i&2)
+ aabb.pos.y+=aabb.size.y;
+ if (i&4)
+ aabb.pos.z+=aabb.size.z;
+
+ _debug_mesh(bake_cells_write[p_idx].childs[i],p_level+1,aabb,p_mode,p_multimesh,idx);
+ }
+
+ }
+
+}
+
+
+void BakedLight::create_debug_mesh(DebugMode p_mode) {
+
+ Ref<MultiMesh> mm;
+ mm.instance();
+
+ mm->set_transform_format(MultiMesh::TRANSFORM_3D);
+ mm->set_color_format(MultiMesh::COLOR_8BIT);
+ mm->set_instance_count(bake_cells_level_used[cell_subdiv-1]);
+
+ Ref<Mesh> mesh;
+ mesh.instance();
+
+
+
+ {
+ Array arr;
+ arr.resize(Mesh::ARRAY_MAX);
+
+ PoolVector<Vector3> vertices;
+ PoolVector<Color> colors;
+
+ int vtx_idx=0;
+ #define ADD_VTX(m_idx);\
+ vertices.push_back( face_points[m_idx] );\
+ colors.push_back( Color(1,1,1,1) );\
+ vtx_idx++;\
+
+ for (int i=0;i<6;i++) {
+
+
+ Vector3 face_points[4];
+
+ for (int j=0;j<4;j++) {
+
+ float v[3];
+ v[0]=1.0;
+ v[1]=1-2*((j>>1)&1);
+ v[2]=v[1]*(1-2*(j&1));
+
+ for (int k=0;k<3;k++) {
+
+ if (i<3)
+ face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ else
+ face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ }
+ }
+
+ //tri 1
+ ADD_VTX(0);
+ ADD_VTX(1);
+ ADD_VTX(2);
+ //tri 2
+ ADD_VTX(2);
+ ADD_VTX(3);
+ ADD_VTX(0);
+
+ }
+
+
+ arr[Mesh::ARRAY_VERTEX]=vertices;
+ arr[Mesh::ARRAY_COLOR]=colors;
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,arr);
+ }
+
+ {
+ Ref<FixedSpatialMaterial> fsm;
+ fsm.instance();
+ fsm->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ fsm->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
+ fsm->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ fsm->set_albedo(Color(1,1,1,1));
+
+ mesh->surface_set_material(0,fsm);
+ }
+
+ mm->set_mesh(mesh);
+
+
+ bake_cells_write = bake_cells.write();
+
+
+
+ int idx=0;
+ _debug_mesh(0,0,bounds,p_mode,mm,idx);
+
+ print_line("written: "+itos(idx)+" total: "+itos(bake_cells_level_used[cell_subdiv-1]));
+
+
+ MultiMeshInstance *mmi = memnew( MultiMeshInstance );
+ mmi->set_multimesh(mm);
+ add_child(mmi);
+#ifdef TOOLS_ENABLED
+ if (get_tree()->get_edited_scene_root()==this){
+ mmi->set_owner(this);
+ } else {
+ mmi->set_owner(get_owner());
+
+ }
+#else
+ mmi->set_owner(get_owner());
+#endif
+
+}
+
+void BakedLight::_debug_mesh_albedo() {
+ create_debug_mesh(DEBUG_ALBEDO);
+}
+
+void BakedLight::_debug_mesh_light() {
+ create_debug_mesh(DEBUG_LIGHT);
+}
+
+
+void BakedLight::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_cell_subdiv","steps"),&BakedLight::set_cell_subdiv);
+ ClassDB::bind_method(_MD("get_cell_subdiv"),&BakedLight::get_cell_subdiv);
+
+ ClassDB::bind_method(_MD("bake"),&BakedLight::bake);
+ ClassDB::set_method_flags(get_class_static(),_SCS("bake"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ClassDB::bind_method(_MD("bake_lights"),&BakedLight::bake_lights);
+ ClassDB::set_method_flags(get_class_static(),_SCS("bake_lights"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ClassDB::bind_method(_MD("bake_radiance"),&BakedLight::bake_radiance);
+ ClassDB::set_method_flags(get_class_static(),_SCS("bake_radiance"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ClassDB::bind_method(_MD("debug_mesh_albedo"),&BakedLight::_debug_mesh_albedo);
+ ClassDB::set_method_flags(get_class_static(),_SCS("debug_mesh_albedo"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("set_baked_light","baked_light"),&BakedLightInstance::set_baked_light);
- ObjectTypeDB::bind_method(_MD("get_baked_light"),&BakedLightInstance::get_baked_light);
- ObjectTypeDB::bind_method(_MD("get_baked_light_instance"),&BakedLightInstance::get_baked_light_instance);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"baked_light",PROPERTY_HINT_RESOURCE_TYPE,"BakedLight"),_SCS("set_baked_light"),_SCS("get_baked_light"));
+ ClassDB::bind_method(_MD("debug_mesh_light"),&BakedLight::_debug_mesh_light);
+ ClassDB::set_method_flags(get_class_static(),_SCS("debug_mesh_light"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"cell_subdiv"),_SCS("set_cell_subdiv"),_SCS("get_cell_subdiv"));
ADD_SIGNAL( MethodInfo("baked_light_changed"));
+
}
-BakedLightInstance::BakedLightInstance() {
+BakedLight::BakedLight() {
+ //baked_light=VisualServer::get_singleton()->baked_light_create();
+ VS::get_singleton()->instance_set_base(get_instance(),baked_light);
+ cell_subdiv=8;
+ bake_texture_size=128;
+ color_scan_cell_width=8;
+ light_pass=0;
}
-/////////////////////////
+BakedLight::~BakedLight() {
+
+ VS::get_singleton()->free(baked_light);
+}
+
+/////////////////////////
+
+#if 0
void BakedLightSampler::set_param(Param p_param,float p_value) {
ERR_FAIL_INDEX(p_param,PARAM_MAX);
params[p_param]=p_value;
@@ -139,11 +1798,11 @@ DVector<Face3> BakedLightSampler::get_faces(uint32_t p_usage_flags) const {
void BakedLightSampler::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&BakedLightSampler::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&BakedLightSampler::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&BakedLightSampler::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&BakedLightSampler::get_param);
- ObjectTypeDB::bind_method(_MD("set_resolution","resolution"),&BakedLightSampler::set_resolution);
- ObjectTypeDB::bind_method(_MD("get_resolution"),&BakedLightSampler::get_resolution);
+ ClassDB::bind_method(_MD("set_resolution","resolution"),&BakedLightSampler::set_resolution);
+ ClassDB::bind_method(_MD("get_resolution"),&BakedLightSampler::get_resolution);
BIND_CONSTANT( PARAM_RADIUS );
@@ -156,7 +1815,7 @@ void BakedLightSampler::_bind_methods() {
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/strength",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_STRENGTH);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
-// ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
+ //ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"params/resolution",PROPERTY_HINT_RANGE,"4,32,1"),_SCS("set_resolution"),_SCS("get_resolution"));
}
@@ -179,3 +1838,4 @@ BakedLightSampler::~BakedLightSampler(){
VS::get_singleton()->free(base);
}
+#endif
diff --git a/scene/3d/baked_light_instance.h b/scene/3d/baked_light_instance.h
index 002e55df1d..2fda26ecea 100644
--- a/scene/3d/baked_light_instance.h
+++ b/scene/3d/baked_light_instance.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,39 +31,144 @@
#include "scene/3d/visual_instance.h"
#include "scene/resources/baked_light.h"
+#include "scene/3d/multimesh_instance.h"
+
class BakedLightBaker;
+class Light;
+
+class BakedLight : public VisualInstance {
+ GDCLASS(BakedLight,VisualInstance);
+
+public:
+ enum DebugMode {
+ DEBUG_ALBEDO,
+ DEBUG_LIGHT
+ };
+
+private:
+ RID baked_light;
+ int cell_subdiv;
+ Rect3 bounds;
+ int cells_per_axis;
+
+ enum {
+ CHILD_EMPTY=0xFFFFFFFF,
+ };
+
+
+ /* BAKE DATA */
+
+ struct BakeCell {
+
+ uint32_t childs[8];
+ float albedo[3]; //albedo in RGB24
+ float light[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast)
+ float radiance[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast)
+ uint32_t used_sides;
+ float alpha; //used for upsampling
+ uint32_t light_pass; //used for baking light
+
+ BakeCell() {
+ for(int i=0;i<8;i++) {
+ childs[i]=0xFFFFFFFF;
+ }
+
+ for(int i=0;i<3;i++) {
+ light[i]=0;
+ albedo[i]=0;
+ radiance[i]=0;
+ }
+ alpha=0;
+ light_pass=0;
+ used_sides=0;
+ }
+ };
+
+
+ int bake_texture_size;
+ int color_scan_cell_width;
+
+ struct MaterialCache {
+ //128x128 textures
+ Vector<Color> albedo;
+ Vector<Color> emission;
+ };
+
+
+ Vector<Color> _get_bake_texture(Image &p_image, const Color &p_color);
-class BakedLightInstance : public VisualInstance {
- OBJ_TYPE(BakedLightInstance,VisualInstance);
- Ref<BakedLight> baked_light;
+ Map<Ref<Material>,MaterialCache> material_cache;
+ MaterialCache _get_material_cache(Ref<Material> p_material);
+ int bake_cells_alloc;
+ int bake_cells_used;
+ int zero_alphas;
+ Vector<int> bake_cells_level_used;
+ PoolVector<BakeCell> bake_cells;
+ PoolVector<BakeCell>::Write bake_cells_write;
+
+
+ void _plot_face(int p_idx,int p_level,const Vector3 *p_vtx,const Vector2* p_uv, const MaterialCache& p_material,const Rect3& p_aabb);
+ void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z);
+ void _bake_add_mesh(const Transform& p_xform,Ref<Mesh>& p_mesh);
+ void _bake_add_to_aabb(const Transform& p_xform,Ref<Mesh>& p_mesh,bool &first);
+
+ void _debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb,DebugMode p_mode,Ref<MultiMesh> &p_multimesh,int &idx);
+ void _debug_mesh_albedo();
+ void _debug_mesh_light();
+
+
+ _FORCE_INLINE_ int _find_cell(int x,int y, int z);
+ int _plot_ray(const Vector3& p_from, const Vector3& p_to);
+
+ uint32_t light_pass;
+
+
+ void _bake_directional(int p_idx, int p_level, int p_x,int p_y,int p_z,const Vector3& p_dir,const Color& p_color,int p_sign);
+ void _upscale_light(int p_idx,int p_level);
+ void _bake_light(Light* p_light);
+
+ Color _cone_trace(const Vector3& p_from, const Vector3& p_dir, float p_half_angle);
+ void _bake_radiance(int p_idx, int p_level, int p_x,int p_y,int p_z);
+
+friend class GeometryInstance;
+
+ Set<GeometryInstance*> geometries;
+friend class Light;
+
+ Set<Light*> lights;
protected:
static void _bind_methods();
public:
+ void set_cell_subdiv(int p_subdiv);
+ int get_cell_subdiv() const;
- RID get_baked_light_instance() const;
+ void bake();
+ void bake_lights();
+ void bake_radiance();
- void set_baked_light(const Ref<BakedLight>& baked_light);
- Ref<BakedLight> get_baked_light() const;
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ void create_debug_mesh(DebugMode p_mode);
+
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
String get_configuration_warning() const;
- BakedLightInstance();
+ BakedLight();
+ ~BakedLight();
};
-
+#if 0
class BakedLightSampler : public VisualInstance {
- OBJ_TYPE(BakedLightSampler,VisualInstance);
+ GDCLASS(BakedLightSampler,VisualInstance);
public:
@@ -87,7 +192,7 @@ protected:
public:
virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_param(Param p_param,float p_value);
float get_param(Param p_param) const;
@@ -101,5 +206,5 @@ public:
VARIANT_ENUM_CAST( BakedLightSampler::Param );
-
+#endif
#endif // BAKED_LIGHT_H
diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp
index adb0d17753..f6ec8639d3 100644
--- a/scene/3d/body_shape.cpp
+++ b/scene/3d/body_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -83,8 +83,8 @@ void CollisionShape::_update_indicator() {
if (shape.is_null())
return;
- DVector<Vector3> points;
- DVector<Vector3> normals;
+ PoolVector<Vector3> points;
+ PoolVector<Vector3> normals;
VS::PrimitiveType pt = VS::PRIMITIVE_TRIANGLES;
@@ -96,7 +96,7 @@ void CollisionShape::_update_indicator() {
pt = VS::PRIMITIVE_LINES;
} else if (shape->cast_to<SphereShape>()) {
-// VisualServer *vs=VisualServer::get_singleton();
+ //VisualServer *vs=VisualServer::get_singleton();
SphereShape *shapeptr=shape->cast_to<SphereShape>();
@@ -235,7 +235,7 @@ void CollisionShape::_update_indicator() {
CapsuleShape *shapeptr=shape->cast_to<CapsuleShape>();
- DVector<Plane> planes = Geometry::build_capsule_planes(shapeptr->get_radius(), shapeptr->get_height()/2.0, 12, Vector3::AXIS_Z);
+ PoolVector<Plane> planes = Geometry::build_capsule_planes(shapeptr->get_radius(), shapeptr->get_height()/2.0, 12, Vector3::AXIS_Z);
Geometry::MeshData md = Geometry::build_convex_mesh(planes);
for(int i=0;i<md.faces.size();i++) {
@@ -337,7 +337,7 @@ void CollisionShape::_notification(int p_what) {
//indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- // VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
+ //VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
if (can_update_body && updating_body) {
_update_body();
}
@@ -414,18 +414,18 @@ String CollisionShape::get_configuration_warning() const {
void CollisionShape::_bind_methods() {
//not sure if this should do anything
- ObjectTypeDB::bind_method(_MD("resource_changed","resource"),&CollisionShape::resource_changed);
- ObjectTypeDB::bind_method(_MD("set_shape","shape"),&CollisionShape::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&CollisionShape::get_shape);
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_trigger","enable"),&CollisionShape::set_trigger);
- ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionShape::is_trigger);
- ObjectTypeDB::bind_method(_MD("make_convex_from_brothers"),&CollisionShape::make_convex_from_brothers);
- ObjectTypeDB::set_method_flags("CollisionShape","make_convex_from_brothers",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape::_set_update_shape_index);
- ObjectTypeDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape::_get_update_shape_index);
-
- ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape::get_collision_object_shape_index);
+ ClassDB::bind_method(_MD("resource_changed","resource"),&CollisionShape::resource_changed);
+ ClassDB::bind_method(_MD("set_shape","shape"),&CollisionShape::set_shape);
+ ClassDB::bind_method(_MD("get_shape"),&CollisionShape::get_shape);
+ ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape::_add_to_collision_object);
+ ClassDB::bind_method(_MD("set_trigger","enable"),&CollisionShape::set_trigger);
+ ClassDB::bind_method(_MD("is_trigger"),&CollisionShape::is_trigger);
+ ClassDB::bind_method(_MD("make_convex_from_brothers"),&CollisionShape::make_convex_from_brothers);
+ ClassDB::set_method_flags("CollisionShape","make_convex_from_brothers",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape::_set_update_shape_index);
+ ClassDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape::_get_update_shape_index);
+
+ ClassDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape::get_collision_object_shape_index);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), _SCS("set_shape"), _SCS("get_shape"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
@@ -620,7 +620,7 @@ RID CollisionShape::_get_visual_instance_rid() const {
void CollisionShape::_bind_methods() {
- ObjectTypeDB::bind_method("_get_visual_instance_rid",&CollisionShape::_get_visual_instance_rid);
+ ClassDB::bind_method("_get_visual_instance_rid",&CollisionShape::_get_visual_instance_rid);
}
CollisionShape::CollisionShape() {
@@ -840,7 +840,7 @@ void CollisionShapeCylinder::update_indicator(RID p_indicator) {
vs->poly_clear(p_indicator);
Color col(0.4,1.0,1.0,0.5);
- DVector<Plane> planes = Geometry::build_cylinder_planes(radius, height, 12, Vector3::AXIS_Z);
+ PoolVector<Plane> planes = Geometry::build_cylinder_planes(radius, height, 12, Vector3::AXIS_Z);
Geometry::MeshData md = Geometry::build_convex_mesh(planes);
for(int i=0;i<md.faces.size();i++) {
@@ -906,7 +906,7 @@ void CollisionShapeCapsule::update_indicator(RID p_indicator) {
vs->poly_clear(p_indicator);
Color col(0.4,1.0,1.0,0.5);
- DVector<Plane> planes = Geometry::build_capsule_planes(radius, height, 12, 3, Vector3::AXIS_Z);
+ PoolVector<Plane> planes = Geometry::build_capsule_planes(radius, height, 12, 3, Vector3::AXIS_Z);
Geometry::MeshData md = Geometry::build_convex_mesh(planes);
for(int i=0;i<md.faces.size();i++) {
diff --git a/scene/3d/body_shape.h b/scene/3d/body_shape.h
index a3289bf26a..a7c3678251 100644
--- a/scene/3d/body_shape.h
+++ b/scene/3d/body_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class CollisionShape : public Spatial {
- OBJ_TYPE( CollisionShape, Spatial );
+ GDCLASS( CollisionShape, Spatial );
OBJ_CATEGORY("3D Physics Nodes");
Ref<Shape> shape;
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index 56b61d40e2..c3ab2df939 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -137,3 +137,8 @@ BoneAttachment::BoneAttachment()
bound=false;
}
+
+void BoneAttachment::_bind_methods(){
+ ClassDB::bind_method(_MD("set_bone_name","bone_name"),&BoneAttachment::set_bone_name);
+ ClassDB::bind_method(_MD("get_bone_name"),&BoneAttachment::get_bone_name);
+}
diff --git a/scene/3d/bone_attachment.h b/scene/3d/bone_attachment.h
index f1c27a9650..9bcbb82865 100644
--- a/scene/3d/bone_attachment.h
+++ b/scene/3d/bone_attachment.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class BoneAttachment : public Spatial {
- OBJ_TYPE(BoneAttachment,Spatial);
+ GDCLASS(BoneAttachment,Spatial);
bool bound;
String bone_name;
@@ -47,6 +47,8 @@ protected:
void _get_property_list( List<PropertyInfo>* p_list ) const;
void _notification(int p_what);
+ static void _bind_methods();
+
public:
void set_bone_name(const String& p_name);
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index e76c0938fb..3f36caf62c 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,8 +96,8 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
} else {
clear_current();
}
- } else if (p_name=="visible_layers") {
- set_visible_layers(p_value);
+ } else if (p_name=="cull_mask") {
+ set_cull_mask(p_value);
} else if (p_name=="environment") {
set_environment(p_value);
} else
@@ -130,8 +130,8 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
} else {
r_ret=is_current();
}
- } else if (p_name=="visible_layers") {
- r_ret=get_visible_layers();
+ } else if (p_name=="cull_mask") {
+ r_ret=get_cull_mask();
} else if (p_name=="h_offset") {
r_ret=get_h_offset();
} else if (p_name=="v_offset") {
@@ -176,7 +176,7 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::REAL, "far" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") );
p_list->push_back( PropertyInfo( Variant::INT, "keep_aspect",PROPERTY_HINT_ENUM,"Keep Width,Keep Height") );
p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
- p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) );
+ p_list->push_back( PropertyInfo( Variant::INT, "cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER ) );
p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "h_offset" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "v_offset" ) );
@@ -190,9 +190,11 @@ void Camera::_update_camera() {
tr.origin+=tr.basis.get_axis(0)*h_offset;
VisualServer::get_singleton()->camera_set_transform( camera, tr );
-// here goes listener stuff
-// if (viewport_ptr && is_inside_scene() && is_current())
-// get_viewport()->_camera_transform_changed_notify();
+ // here goes listener stuff
+ /*
+ if (viewport_ptr && is_inside_scene() && is_current())
+ get_viewport()->_camera_transform_changed_notify();
+ */
if (is_inside_tree() && is_current()) {
get_viewport()->_camera_transform_changed_notify();
@@ -342,91 +344,6 @@ bool Camera::_can_gizmo_scale() const {
}
-RES Camera::_get_gizmo_geometry() const {
-
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.5,1.0,0.5) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
- //mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
- switch(mode) {
-
- case PROJECTION_PERSPECTIVE: {
-
-
-
- Vector3 side=Vector3( Math::sin(Math::deg2rad(fov)), 0, -Math::cos(Math::deg2rad(fov)) );
- Vector3 nside=side;
- nside.x=-nside.x;
- Vector3 up=Vector3(0,side.x,0);
-
-
-#define ADD_TRIANGLE( m_a, m_b, m_c)\
-{\
- surface_tool->add_vertex(m_a);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_a);\
-}
-
- ADD_TRIANGLE( Vector3(), side+up, side-up );
- ADD_TRIANGLE( Vector3(), nside+up, nside-up );
- ADD_TRIANGLE( Vector3(), side+up, nside+up );
- ADD_TRIANGLE( Vector3(), side-up, nside-up );
-
- side.x*=0.25;
- nside.x*=0.25;
- Vector3 tup( 0, up.y*3/2,side.z);
- ADD_TRIANGLE( tup, side+up, nside+up );
-
- } break;
- case PROJECTION_ORTHOGONAL: {
-
-#define ADD_QUAD( m_a, m_b, m_c, m_d)\
-{\
- surface_tool->add_vertex(m_a);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_d);\
- surface_tool->add_vertex(m_d);\
- surface_tool->add_vertex(m_a);\
-}
-
- float hsize=size*0.5;
- Vector3 right(hsize,0,0);
- Vector3 up(0,hsize,0);
- Vector3 back(0,0,-1.0);
- Vector3 front(0,0,0);
-
- ADD_QUAD( -up-right,-up+right,up+right,up-right);
- ADD_QUAD( -up-right+back,-up+right+back,up+right+back,up-right+back);
- ADD_QUAD( up+right,up+right+back,up-right+back,up-right);
- ADD_QUAD( -up+right,-up+right+back,-up-right+back,-up-right);
-
- right.x*=0.25;
- Vector3 tup( 0, up.y*3/2,back.z );
- ADD_TRIANGLE( tup, right+up+back, -right+up+back );
-
- } break;
-
- }
-
- return surface_tool->commit();
-
-}
Vector3 Camera::project_ray_normal(const Point2& p_pos) const {
@@ -458,7 +375,7 @@ Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const {
ray=Vector3(0,0,-1);
} else {
CameraMatrix cm;
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
float screen_w,screen_h;
cm.get_viewport_size(screen_w,screen_h);
ray=Vector3( ((cpos.x/viewport_size.width)*2.0-1.0)*screen_w, ((1.0-(cpos.y/viewport_size.height))*2.0-1.0)*screen_h,-near).normalized();
@@ -485,7 +402,7 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
#endif
ERR_FAIL_COND_V( viewport_size.y == 0, Vector3() );
-// float aspect = viewport_size.x / viewport_size.y;
+ //float aspect = viewport_size.x / viewport_size.y;
if (mode == PROJECTION_PERSPECTIVE) {
@@ -495,10 +412,10 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
Vector2 pos = cpos / viewport_size;
float vsize,hsize;
if (keep_aspect==KEEP_WIDTH) {
- vsize = size/viewport_size.get_aspect();
+ vsize = size/viewport_size.aspect();
hsize = size;
} else {
- hsize = size*viewport_size.get_aspect();
+ hsize = size*viewport_size.aspect();
vsize = size;
}
@@ -534,9 +451,9 @@ Point2 Camera::unproject_position(const Vector3& p_pos) const {
if (mode==PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
else
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
Plane p(get_camera_transform().xform_inv(p_pos),1.0);
@@ -564,9 +481,9 @@ Vector3 Camera::project_position(const Point2& p_point) const {
CameraMatrix cm;
if (mode==PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
else
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
Size2 vp_size;
cm.get_viewport_size(vp_size.x,vp_size.y);
@@ -631,30 +548,34 @@ Camera::KeepAspect Camera::get_keep_aspect_mode() const{
void Camera::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("project_ray_normal","screen_point"), &Camera::project_ray_normal);
- ObjectTypeDB::bind_method( _MD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
- ObjectTypeDB::bind_method( _MD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
- ObjectTypeDB::bind_method( _MD("unproject_position","world_point"), &Camera::unproject_position);
- ObjectTypeDB::bind_method( _MD("is_position_behind","world_point"), &Camera::is_position_behind);
- ObjectTypeDB::bind_method( _MD("project_position","screen_point"), &Camera::project_position);
- ObjectTypeDB::bind_method( _MD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
- ObjectTypeDB::bind_method( _MD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );
- ObjectTypeDB::bind_method( _MD("make_current"),&Camera::make_current );
- ObjectTypeDB::bind_method( _MD("clear_current"),&Camera::clear_current );
- ObjectTypeDB::bind_method( _MD("is_current"),&Camera::is_current );
- ObjectTypeDB::bind_method( _MD("get_camera_transform"),&Camera::get_camera_transform );
- ObjectTypeDB::bind_method( _MD("get_fov"),&Camera::get_fov );
- ObjectTypeDB::bind_method( _MD("get_size"),&Camera::get_size );
- ObjectTypeDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
- ObjectTypeDB::bind_method( _MD("get_znear"),&Camera::get_znear );
- ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
- ObjectTypeDB::bind_method( _MD("set_visible_layers","mask"),&Camera::set_visible_layers );
- ObjectTypeDB::bind_method( _MD("get_visible_layers"),&Camera::get_visible_layers );
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&Camera::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&Camera::get_environment);
- ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode);
- ObjectTypeDB::bind_method(_MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode);
- //ObjectTypeDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current );
+ ClassDB::bind_method( _MD("project_ray_normal","screen_point"), &Camera::project_ray_normal);
+ ClassDB::bind_method( _MD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
+ ClassDB::bind_method( _MD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
+ ClassDB::bind_method( _MD("unproject_position","world_point"), &Camera::unproject_position);
+ ClassDB::bind_method( _MD("is_position_behind","world_point"), &Camera::is_position_behind);
+ ClassDB::bind_method( _MD("project_position","screen_point"), &Camera::project_position);
+ ClassDB::bind_method( _MD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
+ ClassDB::bind_method( _MD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );
+ ClassDB::bind_method( _MD("make_current"),&Camera::make_current );
+ ClassDB::bind_method( _MD("clear_current"),&Camera::clear_current );
+ ClassDB::bind_method( _MD("is_current"),&Camera::is_current );
+ ClassDB::bind_method( _MD("get_camera_transform"),&Camera::get_camera_transform );
+ ClassDB::bind_method( _MD("get_fov"),&Camera::get_fov );
+ ClassDB::bind_method( _MD("get_size"),&Camera::get_size );
+ ClassDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
+ ClassDB::bind_method( _MD("get_znear"),&Camera::get_znear );
+ ClassDB::bind_method( _MD("get_projection"),&Camera::get_projection );
+ ClassDB::bind_method( _MD("set_h_offset","ofs"),&Camera::set_h_offset );
+ ClassDB::bind_method( _MD("get_h_offset"),&Camera::get_h_offset );
+ ClassDB::bind_method( _MD("set_v_offset","ofs"),&Camera::set_v_offset );
+ ClassDB::bind_method( _MD("get_v_offset"),&Camera::get_v_offset );
+ ClassDB::bind_method( _MD("set_cull_mask","mask"),&Camera::set_cull_mask );
+ ClassDB::bind_method( _MD("get_cull_mask"),&Camera::get_cull_mask );
+ ClassDB::bind_method( _MD("set_environment","env:Environment"),&Camera::set_environment );
+ ClassDB::bind_method( _MD("get_environment:Environment"),&Camera::get_environment );
+ ClassDB::bind_method( _MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode );
+ ClassDB::bind_method( _MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode );
+ //ClassDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current );
BIND_CONSTANT( PROJECTION_PERSPECTIVE );
BIND_CONSTANT( PROJECTION_ORTHOGONAL );
@@ -690,13 +611,13 @@ Camera::Projection Camera::get_projection() const {
return mode;
}
-void Camera::set_visible_layers(uint32_t p_layers) {
+void Camera::set_cull_mask(uint32_t p_layers) {
layers=p_layers;
- VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
+ VisualServer::get_singleton()->camera_set_cull_mask(camera,layers);
}
-uint32_t Camera::get_visible_layers() const{
+uint32_t Camera::get_cull_mask() const{
return layers;
}
@@ -709,9 +630,9 @@ Vector<Plane> Camera::get_frustum() const {
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
if (mode==PROJECTION_PERSPECTIVE)
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
else
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
return cm.get_projection_planes(get_camera_transform());
@@ -757,8 +678,9 @@ Camera::Camera() {
layers=0xfffff;
v_offset=0;
h_offset=0;
- VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
+ VisualServer::get_singleton()->camera_set_cull_mask(camera,layers);
//active=false;
+ set_notify_transform(true);
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 30c6928245..5301c06ee5 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
*/
class Camera : public Spatial {
- OBJ_TYPE( Camera, Spatial );
+ GDCLASS( Camera, Spatial );
public:
enum Projection {
@@ -75,7 +75,7 @@ private:
Ref<Environment> environment;
virtual bool _can_gizmo_scale() const;
- virtual RES _get_gizmo_geometry() const;
+
//void _camera_make_current(Node *p_camera);
@@ -126,8 +126,8 @@ public:
bool is_position_behind(const Vector3& p_pos) const;
Vector3 project_position(const Point2& p_point) const;
- void set_visible_layers(uint32_t p_layers);
- uint32_t get_visible_layers() const;
+ void set_cull_mask(uint32_t p_layers);
+ uint32_t get_cull_mask() const;
Vector<Plane> get_frustum() const;
diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp
index fc3dfcd645..b4cd46bd35 100644
--- a/scene/3d/character_camera.cpp
+++ b/scene/3d/character_camera.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -255,8 +255,8 @@ void CharacterCamera::_compute_camera() {
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));
+ 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;
@@ -432,8 +432,8 @@ void CharacterCamera::set_orbit(const Vector2& p_orbit) {
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);
+ 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;
@@ -475,8 +475,8 @@ 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));
+ 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;
@@ -634,30 +634,30 @@ float CharacterCamera::get_autoturn_speed() const {
void CharacterCamera::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_camera_type","type"),&CharacterCamera::set_camera_type);
- ObjectTypeDB::bind_method(_MD("get_camera_type"),&CharacterCamera::get_camera_type);
- ObjectTypeDB::bind_method(_MD("set_orbit","orbit"),&CharacterCamera::set_orbit);
- ObjectTypeDB::bind_method(_MD("get_orbit"),&CharacterCamera::get_orbit);
- ObjectTypeDB::bind_method(_MD("set_orbit_x","x"),&CharacterCamera::set_orbit_x);
- ObjectTypeDB::bind_method(_MD("set_orbit_y","y"),&CharacterCamera::set_orbit_y);
- ObjectTypeDB::bind_method(_MD("set_min_orbit_x","x"),&CharacterCamera::set_min_orbit_x);
- ObjectTypeDB::bind_method(_MD("get_min_orbit_x"),&CharacterCamera::get_min_orbit_x);
- ObjectTypeDB::bind_method(_MD("set_max_orbit_x","x"),&CharacterCamera::set_max_orbit_x);
- ObjectTypeDB::bind_method(_MD("get_max_orbit_x"),&CharacterCamera::get_max_orbit_x);
- ObjectTypeDB::bind_method(_MD("rotate_orbit"),&CharacterCamera::rotate_orbit);
- ObjectTypeDB::bind_method(_MD("set_distance","distance"),&CharacterCamera::set_distance);
- ObjectTypeDB::bind_method(_MD("get_distance"),&CharacterCamera::get_distance);
- ObjectTypeDB::bind_method(_MD("set_clip","enable"),&CharacterCamera::set_clip);
- ObjectTypeDB::bind_method(_MD("has_clip"),&CharacterCamera::has_clip);
- ObjectTypeDB::bind_method(_MD("set_autoturn","enable"),&CharacterCamera::set_autoturn);
- ObjectTypeDB::bind_method(_MD("has_autoturn"),&CharacterCamera::has_autoturn);
- ObjectTypeDB::bind_method(_MD("set_autoturn_tolerance","degrees"),&CharacterCamera::set_autoturn_tolerance);
- ObjectTypeDB::bind_method(_MD("get_autoturn_tolerance"),&CharacterCamera::get_autoturn_tolerance);
- ObjectTypeDB::bind_method(_MD("set_autoturn_speed","speed"),&CharacterCamera::set_autoturn_speed);
- ObjectTypeDB::bind_method(_MD("get_autoturn_speed"),&CharacterCamera::get_autoturn_speed);
- ObjectTypeDB::bind_method(_MD("set_use_lookat_target","use","lookat"),&CharacterCamera::set_use_lookat_target, DEFVAL(Vector3()));
-
- ObjectTypeDB::bind_method(_MD("_ray_collision"),&CharacterCamera::_ray_collision);
+ ClassDB::bind_method(_MD("set_camera_type","type"),&CharacterCamera::set_camera_type);
+ ClassDB::bind_method(_MD("get_camera_type"),&CharacterCamera::get_camera_type);
+ ClassDB::bind_method(_MD("set_orbit","orbit"),&CharacterCamera::set_orbit);
+ ClassDB::bind_method(_MD("get_orbit"),&CharacterCamera::get_orbit);
+ ClassDB::bind_method(_MD("set_orbit_x","x"),&CharacterCamera::set_orbit_x);
+ ClassDB::bind_method(_MD("set_orbit_y","y"),&CharacterCamera::set_orbit_y);
+ ClassDB::bind_method(_MD("set_min_orbit_x","x"),&CharacterCamera::set_min_orbit_x);
+ ClassDB::bind_method(_MD("get_min_orbit_x"),&CharacterCamera::get_min_orbit_x);
+ ClassDB::bind_method(_MD("set_max_orbit_x","x"),&CharacterCamera::set_max_orbit_x);
+ ClassDB::bind_method(_MD("get_max_orbit_x"),&CharacterCamera::get_max_orbit_x);
+ ClassDB::bind_method(_MD("rotate_orbit"),&CharacterCamera::rotate_orbit);
+ ClassDB::bind_method(_MD("set_distance","distance"),&CharacterCamera::set_distance);
+ ClassDB::bind_method(_MD("get_distance"),&CharacterCamera::get_distance);
+ ClassDB::bind_method(_MD("set_clip","enable"),&CharacterCamera::set_clip);
+ ClassDB::bind_method(_MD("has_clip"),&CharacterCamera::has_clip);
+ ClassDB::bind_method(_MD("set_autoturn","enable"),&CharacterCamera::set_autoturn);
+ ClassDB::bind_method(_MD("has_autoturn"),&CharacterCamera::has_autoturn);
+ ClassDB::bind_method(_MD("set_autoturn_tolerance","degrees"),&CharacterCamera::set_autoturn_tolerance);
+ ClassDB::bind_method(_MD("get_autoturn_tolerance"),&CharacterCamera::get_autoturn_tolerance);
+ ClassDB::bind_method(_MD("set_autoturn_speed","speed"),&CharacterCamera::set_autoturn_speed);
+ ClassDB::bind_method(_MD("get_autoturn_speed"),&CharacterCamera::get_autoturn_speed);
+ ClassDB::bind_method(_MD("set_use_lookat_target","use","lookat"),&CharacterCamera::set_use_lookat_target, DEFVAL(Vector3()));
+
+ ClassDB::bind_method(_MD("_ray_collision"),&CharacterCamera::_ray_collision);
BIND_CONSTANT( CAMERA_FIXED );
BIND_CONSTANT( CAMERA_FOLLOW );
diff --git a/scene/3d/character_camera.h b/scene/3d/character_camera.h
index d636b4b1a5..5fde8c342e 100644
--- a/scene/3d/character_camera.h
+++ b/scene/3d/character_camera.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#if 0
class CharacterCamera : public Camera {
- OBJ_TYPE( CharacterCamera, Camera );
+ GDCLASS( CharacterCamera, Camera );
public:
enum CameraType {
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 373c356a45..7bba382db0 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -190,7 +190,7 @@ void CollisionObject::_mouse_enter() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
}
- emit_signal(SceneStringNames::get_singleton()->mouse_enter);
+ emit_signal(SceneStringNames::get_singleton()->mouse_entered);
}
@@ -199,14 +199,14 @@ void CollisionObject::_mouse_exit() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
}
- emit_signal(SceneStringNames::get_singleton()->mouse_exit);
+ emit_signal(SceneStringNames::get_singleton()->mouse_exited);
}
void CollisionObject::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = ray_pickable && is_inside_tree() && is_visible();
+ bool pickable = ray_pickable && is_inside_tree() && is_visible_in_tree();
if (area)
PhysicsServer::get_singleton()->area_set_ray_pickable(rid,pickable);
else
@@ -228,30 +228,30 @@ bool CollisionObject::is_ray_pickable() const {
void CollisionObject::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_shape","shape:Shape","transform"),&CollisionObject::add_shape,DEFVAL(Transform()));
- ObjectTypeDB::bind_method(_MD("get_shape_count"),&CollisionObject::get_shape_count);
- ObjectTypeDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject::set_shape);
- ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
-// ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
- ObjectTypeDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject::set_shape_as_trigger);
- ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject::is_shape_set_as_trigger);
- ObjectTypeDB::bind_method(_MD("get_shape:Shape","shape_idx"),&CollisionObject::get_shape);
- ObjectTypeDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject::get_shape_transform);
- ObjectTypeDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject::remove_shape);
- ObjectTypeDB::bind_method(_MD("clear_shapes"),&CollisionObject::clear_shapes);
- ObjectTypeDB::bind_method(_MD("set_ray_pickable","ray_pickable"),&CollisionObject::set_ray_pickable);
- ObjectTypeDB::bind_method(_MD("is_ray_pickable"),&CollisionObject::is_ray_pickable);
- ObjectTypeDB::bind_method(_MD("set_capture_input_on_drag","enable"),&CollisionObject::set_capture_input_on_drag);
- ObjectTypeDB::bind_method(_MD("get_capture_input_on_drag"),&CollisionObject::get_capture_input_on_drag);
- ObjectTypeDB::bind_method(_MD("get_rid"),&CollisionObject::get_rid);
+ ClassDB::bind_method(_MD("add_shape","shape:Shape","transform"),&CollisionObject::add_shape,DEFVAL(Transform()));
+ ClassDB::bind_method(_MD("get_shape_count"),&CollisionObject::get_shape_count);
+ ClassDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject::set_shape);
+ ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
+// ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
+ ClassDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject::set_shape_as_trigger);
+ ClassDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject::is_shape_set_as_trigger);
+ ClassDB::bind_method(_MD("get_shape:Shape","shape_idx"),&CollisionObject::get_shape);
+ ClassDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject::get_shape_transform);
+ ClassDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject::remove_shape);
+ ClassDB::bind_method(_MD("clear_shapes"),&CollisionObject::clear_shapes);
+ ClassDB::bind_method(_MD("set_ray_pickable","ray_pickable"),&CollisionObject::set_ray_pickable);
+ ClassDB::bind_method(_MD("is_ray_pickable"),&CollisionObject::is_ray_pickable);
+ ClassDB::bind_method(_MD("set_capture_input_on_drag","enable"),&CollisionObject::set_capture_input_on_drag);
+ ClassDB::bind_method(_MD("get_capture_input_on_drag"),&CollisionObject::get_capture_input_on_drag);
+ ClassDB::bind_method(_MD("get_rid"),&CollisionObject::get_rid);
BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"camera"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::VECTOR3,"click_pos"),PropertyInfo(Variant::VECTOR3,"click_normal"),PropertyInfo(Variant::INT,"shape_idx")));
ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::OBJECT,"camera"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::VECTOR3,"click_pos"),PropertyInfo(Variant::VECTOR3,"click_normal"),PropertyInfo(Variant::INT,"shape_idx")));
- ADD_SIGNAL( MethodInfo("mouse_enter"));
- ADD_SIGNAL( MethodInfo("mouse_exit"));
+ ADD_SIGNAL( MethodInfo("mouse_entered"));
+ ADD_SIGNAL( MethodInfo("mouse_exited"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input/ray_pickable"),_SCS("set_ray_pickable"),_SCS("is_ray_pickable"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"input/capture_on_drag"),_SCS("set_capture_input_on_drag"),_SCS("get_capture_input_on_drag"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_ray_pickable"),_SCS("set_ray_pickable"),_SCS("is_ray_pickable"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"input_capture_on_drag"),_SCS("set_capture_input_on_drag"),_SCS("get_capture_input_on_drag"));
}
@@ -339,7 +339,7 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) {
} else {
PhysicsServer::get_singleton()->body_attach_object_instance_ID(rid,get_instance_ID());
}
-// set_transform_notify(true);
+ //set_transform_notify(true);
}
@@ -360,7 +360,7 @@ CollisionObject::CollisionObject() {
capture_input_on_drag=false;
ray_pickable=true;
-
+ set_notify_transform(true);
//owner=
//set_transform_notify(true);
diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h
index f8daeb3ed2..b89b7e3361 100644
--- a/scene/3d/collision_object.h
+++ b/scene/3d/collision_object.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class CollisionObject : public Spatial {
- OBJ_TYPE( CollisionObject, Spatial );
+ GDCLASS( CollisionObject, Spatial );
bool area;
RID rid;
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index 2948966fb3..d0612986df 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -56,11 +56,11 @@ void CollisionPolygon::_add_to_collision_object(Object *p_obj) {
shape_from=co->get_shape_count();
for(int i=0;i<decomp.size();i++) {
Ref<ConvexPolygonShape> convex = memnew( ConvexPolygonShape );
- DVector<Vector3> cp;
+ PoolVector<Vector3> cp;
int cs = decomp[i].size();
cp.resize(cs*2);
{
- DVector<Vector3>::Write w = cp.write();
+ PoolVector<Vector3>::Write w = cp.write();
int idx=0;
for(int j=0;j<cs;j++) {
@@ -84,16 +84,16 @@ void CollisionPolygon::_add_to_collision_object(Object *p_obj) {
#if 0
Ref<ConcavePolygonShape> concave = memnew( ConcavePolygonShape );
- DVector<Vector2> segments;
+ PoolVector<Vector2> segments;
segments.resize(polygon.size()*2);
- DVector<Vector2>::Write w=segments.write();
+ PoolVector<Vector2>::Write w=segments.write();
for(int i=0;i<polygon.size();i++) {
w[(i<<1)+0]=polygon[i];
w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
}
- w=DVector<Vector2>::Write();
+ w=PoolVector<Vector2>::Write();
concave->set_segments(segments);
co->add_shape(concave,get_transform());
@@ -200,7 +200,7 @@ void CollisionPolygon::set_polygon(const Vector<Point2>& p_polygon) {
Vector3 p1(polygon[i].x,polygon[i].y,depth*0.5);
if (i==0)
- aabb=AABB(p1,Vector3());
+ aabb=Rect3(p1,Vector3());
else
aabb.expand_to(p1);
@@ -209,9 +209,9 @@ void CollisionPolygon::set_polygon(const Vector<Point2>& p_polygon) {
}
- if (aabb==AABB()) {
+ if (aabb==Rect3()) {
- aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2));
+ aabb=Rect3(Vector3(-1,-1,-1),Vector3(2,2,2));
} else {
aabb.pos-=aabb.size*0.3;
aabb.size+=aabb.size*0.6;
@@ -240,7 +240,7 @@ CollisionPolygon::BuildMode CollisionPolygon::get_build_mode() const{
return build_mode;
}
-AABB CollisionPolygon::get_item_rect() const {
+Rect3 CollisionPolygon::get_item_rect() const {
return aabb;
}
@@ -275,26 +275,26 @@ String CollisionPolygon::get_configuration_warning() const {
void CollisionPolygon::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon::_add_to_collision_object);
+ ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon::set_build_mode);
- ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon::get_build_mode);
+ ClassDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon::set_build_mode);
+ ClassDB::bind_method(_MD("get_build_mode"),&CollisionPolygon::get_build_mode);
- ObjectTypeDB::bind_method(_MD("set_depth","depth"),&CollisionPolygon::set_depth);
- ObjectTypeDB::bind_method(_MD("get_depth"),&CollisionPolygon::get_depth);
+ ClassDB::bind_method(_MD("set_depth","depth"),&CollisionPolygon::set_depth);
+ ClassDB::bind_method(_MD("get_depth"),&CollisionPolygon::get_depth);
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon::get_polygon);
+ ClassDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon::set_polygon);
+ ClassDB::bind_method(_MD("get_polygon"),&CollisionPolygon::get_polygon);
- ObjectTypeDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon::_set_shape_range);
- ObjectTypeDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon::_get_shape_range);
+ ClassDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon::_set_shape_range);
+ ClassDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon::_get_shape_range);
- ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon::get_collision_object_first_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon::get_collision_object_last_shape);
+ ClassDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon::get_collision_object_first_shape);
+ ClassDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon::get_collision_object_last_shape);
ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Triangles"),_SCS("set_build_mode"),_SCS("get_build_mode"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"depth"),_SCS("set_depth"),_SCS("get_depth"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range"));
}
@@ -304,7 +304,7 @@ CollisionPolygon::CollisionPolygon() {
shape_to=-1;
can_update_body=false;
- aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2));
+ aabb=Rect3(Vector3(-1,-1,-1),Vector3(2,2,2));
build_mode=BUILD_SOLIDS;
depth=1.0;
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index 63ff3e84e4..693cf0640a 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
class CollisionPolygon : public Spatial {
- OBJ_TYPE(CollisionPolygon,Spatial);
+ GDCLASS(CollisionPolygon,Spatial);
public:
enum BuildMode {
@@ -48,7 +48,7 @@ protected:
float depth;
- AABB aabb;
+ Rect3 aabb;
BuildMode build_mode;
Vector<Point2> polygon;
@@ -78,7 +78,7 @@ public:
void set_polygon(const Vector<Point2>& p_polygon);
Vector<Point2> get_polygon() const;
- virtual AABB get_item_rect() const;
+ virtual Rect3 get_item_rect() const;
int get_collision_object_first_shape() const { return shape_from; }
int get_collision_object_last_shape() const { return shape_to; }
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
new file mode 100644
index 0000000000..54d7cb6b9e
--- /dev/null
+++ b/scene/3d/gi_probe.cpp
@@ -0,0 +1,1407 @@
+#include "gi_probe.h"
+#include "mesh_instance.h"
+
+
+void GIProbeData::set_bounds(const Rect3& p_bounds) {
+
+ VS::get_singleton()->gi_probe_set_bounds(probe,p_bounds);
+}
+
+Rect3 GIProbeData::get_bounds() const{
+
+ return VS::get_singleton()->gi_probe_get_bounds(probe);
+}
+
+void GIProbeData::set_cell_size(float p_size) {
+
+ VS::get_singleton()->gi_probe_set_cell_size(probe,p_size);
+
+}
+
+float GIProbeData::get_cell_size() const {
+
+ return VS::get_singleton()->gi_probe_get_cell_size(probe);
+
+}
+
+void GIProbeData::set_to_cell_xform(const Transform& p_xform) {
+
+ VS::get_singleton()->gi_probe_set_to_cell_xform(probe,p_xform);
+
+}
+
+Transform GIProbeData::get_to_cell_xform() const {
+
+ return VS::get_singleton()->gi_probe_get_to_cell_xform(probe);
+
+}
+
+
+void GIProbeData::set_dynamic_data(const PoolVector<int>& p_data){
+
+ VS::get_singleton()->gi_probe_set_dynamic_data(probe,p_data);
+
+}
+PoolVector<int> GIProbeData::get_dynamic_data() const{
+
+ return VS::get_singleton()->gi_probe_get_dynamic_data(probe);
+}
+
+void GIProbeData::set_dynamic_range(int p_range){
+
+ VS::get_singleton()->gi_probe_set_dynamic_range(probe,p_range);
+
+}
+
+void GIProbeData::set_energy(float p_range) {
+
+ VS::get_singleton()->gi_probe_set_energy(probe,p_range);
+}
+
+float GIProbeData::get_energy() const{
+
+ return VS::get_singleton()->gi_probe_get_energy(probe);
+
+}
+
+void GIProbeData::set_interior(bool p_enable) {
+
+ VS::get_singleton()->gi_probe_set_interior(probe,p_enable);
+
+}
+
+bool GIProbeData::is_interior() const{
+
+ return VS::get_singleton()->gi_probe_is_interior(probe);
+}
+
+
+bool GIProbeData::is_compressed() const{
+
+ return VS::get_singleton()->gi_probe_is_compressed(probe);
+}
+
+
+void GIProbeData::set_compress(bool p_enable) {
+
+ VS::get_singleton()->gi_probe_set_compress(probe,p_enable);
+
+}
+
+int GIProbeData::get_dynamic_range() const{
+
+
+ return VS::get_singleton()->gi_probe_get_dynamic_range(probe);
+}
+
+
+RID GIProbeData::get_rid() const {
+
+ return probe;
+}
+
+
+void GIProbeData::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_bounds","bounds"),&GIProbeData::set_bounds);
+ ClassDB::bind_method(_MD("get_bounds"),&GIProbeData::get_bounds);
+
+ ClassDB::bind_method(_MD("set_cell_size","cell_size"),&GIProbeData::set_cell_size);
+ ClassDB::bind_method(_MD("get_cell_size"),&GIProbeData::get_cell_size);
+
+ ClassDB::bind_method(_MD("set_to_cell_xform","to_cell_xform"),&GIProbeData::set_to_cell_xform);
+ ClassDB::bind_method(_MD("get_to_cell_xform"),&GIProbeData::get_to_cell_xform);
+
+ ClassDB::bind_method(_MD("set_dynamic_data","dynamic_data"),&GIProbeData::set_dynamic_data);
+ ClassDB::bind_method(_MD("get_dynamic_data"),&GIProbeData::get_dynamic_data);
+
+ ClassDB::bind_method(_MD("set_dynamic_range","dynamic_range"),&GIProbeData::set_dynamic_range);
+ ClassDB::bind_method(_MD("get_dynamic_range"),&GIProbeData::get_dynamic_range);
+
+ ClassDB::bind_method(_MD("set_energy","energy"),&GIProbeData::set_energy);
+ ClassDB::bind_method(_MD("get_energy"),&GIProbeData::get_energy);
+
+ ClassDB::bind_method(_MD("set_interior","interior"),&GIProbeData::set_interior);
+ ClassDB::bind_method(_MD("is_interior"),&GIProbeData::is_interior);
+
+ ClassDB::bind_method(_MD("set_compress","compress"),&GIProbeData::set_compress);
+ ClassDB::bind_method(_MD("is_compressed"),&GIProbeData::is_compressed);
+
+ ADD_PROPERTY(PropertyInfo(Variant::RECT3,"bounds",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_bounds"),_SCS("get_bounds"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"cell_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_cell_size"),_SCS("get_cell_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM,"to_cell_xform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_to_cell_xform"),_SCS("get_to_cell_xform"));
+
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY,"dynamic_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_data"),_SCS("get_dynamic_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_range"),_SCS("get_dynamic_range"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_energy"),_SCS("get_energy"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"interior",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_interior"),_SCS("is_interior"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"compress",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_compress"),_SCS("is_compressed"));
+
+}
+
+GIProbeData::GIProbeData() {
+
+ probe=VS::get_singleton()->gi_probe_create();
+}
+
+GIProbeData::~GIProbeData() {
+
+ VS::get_singleton()->free(probe);
+}
+
+
+//////////////////////
+//////////////////////
+
+
+void GIProbe::set_probe_data(const Ref<GIProbeData>& p_data) {
+
+ if (p_data.is_valid()) {
+ VS::get_singleton()->instance_set_base(get_instance(),p_data->get_rid());
+ } else {
+ VS::get_singleton()->instance_set_base(get_instance(),RID());
+ }
+
+ probe_data=p_data;
+}
+
+Ref<GIProbeData> GIProbe::get_probe_data() const {
+
+ return probe_data;
+}
+
+void GIProbe::set_subdiv(Subdiv p_subdiv) {
+
+ ERR_FAIL_INDEX(p_subdiv,SUBDIV_MAX);
+ subdiv=p_subdiv;
+ update_gizmo();
+}
+
+GIProbe::Subdiv GIProbe::get_subdiv() const {
+
+ return subdiv;
+}
+
+void GIProbe::set_extents(const Vector3& p_extents) {
+
+ extents=p_extents;
+ update_gizmo();
+}
+
+Vector3 GIProbe::get_extents() const {
+
+ return extents;
+}
+
+void GIProbe::set_dynamic_range(int p_dynamic_range) {
+
+ dynamic_range=p_dynamic_range;
+}
+int GIProbe::get_dynamic_range() const {
+
+ return dynamic_range;
+}
+
+void GIProbe::set_energy(float p_energy) {
+
+ energy=p_energy;
+ if (probe_data.is_valid()) {
+ probe_data->set_energy(energy);
+ }
+}
+float GIProbe::get_energy() const {
+
+ return energy;
+}
+
+void GIProbe::set_interior(bool p_enable) {
+
+ interior=p_enable;
+ if (probe_data.is_valid()) {
+ probe_data->set_interior(p_enable);
+ }
+}
+
+bool GIProbe::is_interior() const {
+
+ return interior;
+}
+
+
+void GIProbe::set_compress(bool p_enable) {
+
+ compress=p_enable;
+ if (probe_data.is_valid()) {
+ probe_data->set_compress(p_enable);
+ }
+}
+
+bool GIProbe::is_compressed() const {
+
+ return compress;
+}
+
+
+#include "math.h"
+
+#define FINDMINMAX(x0,x1,x2,min,max) \
+ min = max = x0; \
+ if(x1<min) min=x1;\
+ if(x1>max) max=x1;\
+ if(x2<min) min=x2;\
+ if(x2>max) max=x2;
+
+static bool planeBoxOverlap(Vector3 normal,float d, Vector3 maxbox)
+{
+ int q;
+ Vector3 vmin,vmax;
+ for(q=0;q<=2;q++)
+ {
+ if(normal[q]>0.0f)
+ {
+ vmin[q]=-maxbox[q];
+ vmax[q]=maxbox[q];
+ }
+ else
+ {
+ vmin[q]=maxbox[q];
+ vmax[q]=-maxbox[q];
+ }
+ }
+ if(normal.dot(vmin)+d>0.0f) return false;
+ if(normal.dot(vmax)+d>=0.0f) return true;
+
+ return false;
+}
+
+
+/*======================== X-tests ========================*/
+#define AXISTEST_X01(a, b, fa, fb) \
+ p0 = a*v0.y - b*v0.z; \
+ p2 = a*v2.y - b*v2.z; \
+ if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
+ rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+#define AXISTEST_X2(a, b, fa, fb) \
+ p0 = a*v0.y - b*v0.z; \
+ p1 = a*v1.y - b*v1.z; \
+ if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
+ rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+/*======================== Y-tests ========================*/
+#define AXISTEST_Y02(a, b, fa, fb) \
+ p0 = -a*v0.x + b*v0.z; \
+ p2 = -a*v2.x + b*v2.z; \
+ if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+#define AXISTEST_Y1(a, b, fa, fb) \
+ p0 = -a*v0.x + b*v0.z; \
+ p1 = -a*v1.x + b*v1.z; \
+ if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
+ if(min>rad || max<-rad) return false;
+
+/*======================== Z-tests ========================*/
+
+#define AXISTEST_Z12(a, b, fa, fb) \
+ p1 = a*v1.x - b*v1.y; \
+ p2 = a*v2.x - b*v2.y; \
+ if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \
+ if(min>rad || max<-rad) return false;
+
+#define AXISTEST_Z0(a, b, fa, fb) \
+ p0 = a*v0.x - b*v0.y; \
+ p1 = a*v1.x - b*v1.y; \
+ if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} \
+ rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \
+ if(min>rad || max<-rad) return false;
+
+static bool fast_tri_box_overlap(const Vector3& boxcenter,const Vector3 boxhalfsize,const Vector3 *triverts) {
+
+ /* use separating axis theorem to test overlap between triangle and box */
+ /* need to test for overlap in these directions: */
+ /* 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */
+ /* we do not even need to test these) */
+ /* 2) normal of the triangle */
+ /* 3) crossproduct(edge from tri, {x,y,z}-directin) */
+ /* this gives 3x3=9 more tests */
+ Vector3 v0,v1,v2;
+ float min,max,d,p0,p1,p2,rad,fex,fey,fez;
+ Vector3 normal,e0,e1,e2;
+
+ /* This is the fastest branch on Sun */
+ /* move everything so that the boxcenter is in (0,0,0) */
+
+ v0=triverts[0]-boxcenter;
+ v1=triverts[1]-boxcenter;
+ v2=triverts[2]-boxcenter;
+
+ /* compute triangle edges */
+ e0=v1-v0; /* tri edge 0 */
+ e1=v2-v1; /* tri edge 1 */
+ e2=v0-v2; /* tri edge 2 */
+
+ /* Bullet 3: */
+ /* test the 9 tests first (this was faster) */
+ fex = Math::abs(e0.x);
+ fey = Math::abs(e0.y);
+ fez = Math::abs(e0.z);
+ AXISTEST_X01(e0.z, e0.y, fez, fey);
+ AXISTEST_Y02(e0.z, e0.x, fez, fex);
+ AXISTEST_Z12(e0.y, e0.x, fey, fex);
+
+ fex = Math::abs(e1.x);
+ fey = Math::abs(e1.y);
+ fez = Math::abs(e1.z);
+ AXISTEST_X01(e1.z, e1.y, fez, fey);
+ AXISTEST_Y02(e1.z, e1.x, fez, fex);
+ AXISTEST_Z0(e1.y, e1.x, fey, fex);
+
+ fex = Math::abs(e2.x);
+ fey = Math::abs(e2.y);
+ fez = Math::abs(e2.z);
+ AXISTEST_X2(e2.z, e2.y, fez, fey);
+ AXISTEST_Y1(e2.z, e2.x, fez, fex);
+ AXISTEST_Z12(e2.y, e2.x, fey, fex);
+
+ /* Bullet 1: */
+ /* first test overlap in the {x,y,z}-directions */
+ /* find min, max of the triangle each direction, and test for overlap in */
+ /* that direction -- this is equivalent to testing a minimal AABB around */
+ /* the triangle against the AABB */
+
+ /* test in X-direction */
+ FINDMINMAX(v0.x,v1.x,v2.x,min,max);
+ if(min>boxhalfsize.x || max<-boxhalfsize.x) return false;
+
+ /* test in Y-direction */
+ FINDMINMAX(v0.y,v1.y,v2.y,min,max);
+ if(min>boxhalfsize.y || max<-boxhalfsize.y) return false;
+
+ /* test in Z-direction */
+ FINDMINMAX(v0.z,v1.z,v2.z,min,max);
+ if(min>boxhalfsize.z || max<-boxhalfsize.z) return false;
+
+ /* Bullet 2: */
+ /* test if the box intersects the plane of the triangle */
+ /* compute plane equation of triangle: normal*x+d=0 */
+ normal=e0.cross(e1);
+ d=-normal.dot(v0); /* plane eq: normal.x+d=0 */
+ if(!planeBoxOverlap(normal,d,boxhalfsize)) return false;
+
+ return true; /* box and triangle overlaps */
+}
+
+
+
+static _FORCE_INLINE_ Vector2 get_uv(const Vector3& p_pos, const Vector3 *p_vtx, const Vector2* p_uv) {
+
+ if (p_pos.distance_squared_to(p_vtx[0])<CMP_EPSILON2)
+ return p_uv[0];
+ if (p_pos.distance_squared_to(p_vtx[1])<CMP_EPSILON2)
+ return p_uv[1];
+ if (p_pos.distance_squared_to(p_vtx[2])<CMP_EPSILON2)
+ return p_uv[2];
+
+ Vector3 v0 = p_vtx[1] - p_vtx[0];
+ Vector3 v1 = p_vtx[2] - p_vtx[0];
+ Vector3 v2 = p_pos - p_vtx[0];
+
+ float d00 = v0.dot( v0);
+ float d01 = v0.dot( v1);
+ float d11 = v1.dot( v1);
+ float d20 = v2.dot( v0);
+ float d21 = v2.dot( v1);
+ float denom = (d00 * d11 - d01 * d01);
+ if (denom==0)
+ return p_uv[0];
+ float v = (d11 * d20 - d01 * d21) / denom;
+ float w = (d00 * d21 - d01 * d20) / denom;
+ float u = 1.0f - v - w;
+
+ return p_uv[0]*u + p_uv[1]*v + p_uv[2]*w;
+}
+
+void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const Vector3 *p_vtx, const Vector2* p_uv, const Baker::MaterialCache& p_material, const Rect3 &p_aabb,Baker *p_baker) {
+
+
+
+ if (p_level==p_baker->cell_subdiv-1) {
+ //plot the face by guessing it's albedo and emission value
+
+ //find best axis to map to, for scanning values
+ int closest_axis;
+ float closest_dot;
+
+ Vector3 normal = Plane(p_vtx[0],p_vtx[1],p_vtx[2]).normal;
+
+ for(int i=0;i<3;i++) {
+
+ Vector3 axis;
+ axis[i]=1.0;
+ float dot=ABS(normal.dot(axis));
+ if (i==0 || dot>closest_dot) {
+ closest_axis=i;
+ closest_dot=dot;
+ }
+ }
+
+ Vector3 axis;
+ axis[closest_axis]=1.0;
+ Vector3 t1;
+ t1[(closest_axis+1)%3]=1.0;
+ Vector3 t2;
+ t2[(closest_axis+2)%3]=1.0;
+
+ t1*=p_aabb.size[(closest_axis+1)%3]/float(color_scan_cell_width);
+ t2*=p_aabb.size[(closest_axis+2)%3]/float(color_scan_cell_width);
+
+ Color albedo_accum;
+ Color emission_accum;
+ Vector3 normal_accum;
+
+ float alpha=0.0;
+
+ //map to a grid average in the best axis for this face
+ for(int i=0;i<color_scan_cell_width;i++) {
+
+ Vector3 ofs_i=float(i)*t1;
+
+ for(int j=0;j<color_scan_cell_width;j++) {
+
+ Vector3 ofs_j=float(j)*t2;
+
+ Vector3 from = p_aabb.pos+ofs_i+ofs_j;
+ Vector3 to = from + t1 + t2 + axis * p_aabb.size[closest_axis];
+ Vector3 half = (to-from)*0.5;
+
+ //is in this cell?
+ if (!fast_tri_box_overlap(from+half,half,p_vtx)) {
+ continue; //face does not span this cell
+ }
+
+ //go from -size to +size*2 to avoid skipping collisions
+ Vector3 ray_from = from + (t1+t2)*0.5 - axis * p_aabb.size[closest_axis];
+ Vector3 ray_to = ray_from + axis * p_aabb.size[closest_axis]*2;
+
+ Vector3 intersection;
+
+ if (!Geometry::ray_intersects_triangle(ray_from,ray_to,p_vtx[0],p_vtx[1],p_vtx[2],&intersection)) {
+ //no intersect? look in edges
+
+ float closest_dist=1e20;
+ for(int j=0;j<3;j++) {
+ Vector3 c;
+ Vector3 inters;
+ Geometry::get_closest_points_between_segments(p_vtx[j],p_vtx[(j+1)%3],ray_from,ray_to,inters,c);
+ float d=c.distance_to(intersection);
+ if (j==0 || d<closest_dist) {
+ closest_dist=d;
+ intersection=inters;
+ }
+ }
+ }
+
+ Vector2 uv = get_uv(intersection,p_vtx,p_uv);
+
+
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+
+ int ofs = uv_y*bake_texture_size+uv_x;
+ albedo_accum.r+=p_material.albedo[ofs].r;
+ albedo_accum.g+=p_material.albedo[ofs].g;
+ albedo_accum.b+=p_material.albedo[ofs].b;
+ albedo_accum.a+=p_material.albedo[ofs].a;
+
+ emission_accum.r+=p_material.emission[ofs].r;
+ emission_accum.g+=p_material.emission[ofs].g;
+ emission_accum.b+=p_material.emission[ofs].b;
+
+ normal_accum+=normal;
+
+ alpha+=1.0;
+
+ }
+ }
+
+
+ if (alpha==0) {
+ //could not in any way get texture information.. so use closest point to center
+
+ Face3 f( p_vtx[0],p_vtx[1],p_vtx[2]);
+ Vector3 inters = f.get_closest_point_to(p_aabb.pos+p_aabb.size*0.5);
+
+ Vector2 uv = get_uv(inters,p_vtx,p_uv);
+
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+
+ int ofs = uv_y*bake_texture_size+uv_x;
+
+ alpha = 1.0/(color_scan_cell_width*color_scan_cell_width);
+
+ albedo_accum.r=p_material.albedo[ofs].r*alpha;
+ albedo_accum.g=p_material.albedo[ofs].g*alpha;
+ albedo_accum.b=p_material.albedo[ofs].b*alpha;
+ albedo_accum.a=p_material.albedo[ofs].a*alpha;
+
+ emission_accum.r=p_material.emission[ofs].r*alpha;
+ emission_accum.g=p_material.emission[ofs].g*alpha;
+ emission_accum.b=p_material.emission[ofs].b*alpha;
+
+ normal_accum*=alpha;
+
+
+ } else {
+
+ float accdiv = 1.0/(color_scan_cell_width*color_scan_cell_width);
+ alpha*=accdiv;
+
+ albedo_accum.r*=accdiv;
+ albedo_accum.g*=accdiv;
+ albedo_accum.b*=accdiv;
+ albedo_accum.a*=accdiv;
+
+ emission_accum.r*=accdiv;
+ emission_accum.g*=accdiv;
+ emission_accum.b*=accdiv;
+
+ normal_accum*=accdiv;
+
+ }
+
+ //put this temporarily here, corrected in a later step
+ p_baker->bake_cells[p_idx].albedo[0]+=albedo_accum.r;
+ p_baker->bake_cells[p_idx].albedo[1]+=albedo_accum.g;
+ p_baker->bake_cells[p_idx].albedo[2]+=albedo_accum.b;
+ p_baker->bake_cells[p_idx].emission[0]+=emission_accum.r;
+ p_baker->bake_cells[p_idx].emission[1]+=emission_accum.g;
+ p_baker->bake_cells[p_idx].emission[2]+=emission_accum.b;
+ p_baker->bake_cells[p_idx].normal[0]+=normal_accum.x;
+ p_baker->bake_cells[p_idx].normal[1]+=normal_accum.y;
+ p_baker->bake_cells[p_idx].normal[2]+=normal_accum.z;
+ p_baker->bake_cells[p_idx].alpha+=alpha;
+
+ static const Vector3 side_normals[6]={
+ Vector3(-1, 0, 0),
+ Vector3( 1, 0, 0),
+ Vector3( 0,-1, 0),
+ Vector3( 0, 1, 0),
+ Vector3( 0, 0,-1),
+ Vector3( 0, 0, 1),
+ };
+
+ /*
+ for(int i=0;i<6;i++) {
+ if (normal.dot(side_normals[i])>CMP_EPSILON) {
+ p_baker->bake_cells[p_idx].used_sides|=(1<<i);
+ }
+ }*/
+
+
+ } else {
+ //go down
+
+ int half = (1<<(p_baker->cell_subdiv-1)) >> (p_level+1);
+ for(int i=0;i<8;i++) {
+
+ Rect3 aabb=p_aabb;
+ aabb.size*=0.5;
+
+ int nx=p_x;
+ int ny=p_y;
+ int nz=p_z;
+
+ if (i&1) {
+ aabb.pos.x+=aabb.size.x;
+ nx+=half;
+ }
+ if (i&2) {
+ aabb.pos.y+=aabb.size.y;
+ ny+=half;
+ }
+ if (i&4) {
+ aabb.pos.z+=aabb.size.z;
+ nz+=half;
+ }
+ //make sure to not plot beyond limits
+ if (nx<0 || nx>=p_baker->axis_cell_size[0] || ny<0 || ny>=p_baker->axis_cell_size[1] || nz<0 || nz>=p_baker->axis_cell_size[2])
+ continue;
+
+ {
+ Rect3 test_aabb=aabb;
+ //test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time
+ Vector3 qsize = test_aabb.size*0.5; //quarter size, for fast aabb test
+
+ if (!fast_tri_box_overlap(test_aabb.pos+qsize,qsize,p_vtx)) {
+ //if (!Face3(p_vtx[0],p_vtx[1],p_vtx[2]).intersects_aabb2(aabb)) {
+ //does not fit in child, go on
+ continue;
+ }
+
+ }
+
+ if (p_baker->bake_cells[p_idx].childs[i]==Baker::CHILD_EMPTY) {
+ //sub cell must be created
+
+ uint32_t child_idx = p_baker->bake_cells.size();
+ p_baker->bake_cells[p_idx].childs[i]=child_idx;
+ p_baker->bake_cells.resize( p_baker->bake_cells.size() + 1);
+ p_baker->bake_cells[child_idx].level=p_level+1;
+
+ }
+
+
+ _plot_face(p_baker->bake_cells[p_idx].childs[i],p_level+1,nx,ny,nz,p_vtx,p_uv,p_material,aabb,p_baker);
+ }
+ }
+}
+
+
+
+void GIProbe::_fixup_plot(int p_idx, int p_level,int p_x,int p_y, int p_z,Baker *p_baker) {
+
+
+
+ if (p_level==p_baker->cell_subdiv-1) {
+
+ p_baker->leaf_voxel_count++;
+ float alpha = p_baker->bake_cells[p_idx].alpha;
+
+ p_baker->bake_cells[p_idx].albedo[0]/=alpha;
+ p_baker->bake_cells[p_idx].albedo[1]/=alpha;
+ p_baker->bake_cells[p_idx].albedo[2]/=alpha;
+
+ //transfer emission to light
+ p_baker->bake_cells[p_idx].emission[0]/=alpha;
+ p_baker->bake_cells[p_idx].emission[1]/=alpha;
+ p_baker->bake_cells[p_idx].emission[2]/=alpha;
+
+ p_baker->bake_cells[p_idx].normal[0]/=alpha;
+ p_baker->bake_cells[p_idx].normal[1]/=alpha;
+ p_baker->bake_cells[p_idx].normal[2]/=alpha;
+
+ Vector3 n(p_baker->bake_cells[p_idx].normal[0],p_baker->bake_cells[p_idx].normal[1],p_baker->bake_cells[p_idx].normal[2]);
+ if (n.length()<0.01) {
+ //too much fight over normal, zero it
+ p_baker->bake_cells[p_idx].normal[0]=0;
+ p_baker->bake_cells[p_idx].normal[1]=0;
+ p_baker->bake_cells[p_idx].normal[2]=0;
+ } else {
+ n.normalize();
+ p_baker->bake_cells[p_idx].normal[0]=n.x;
+ p_baker->bake_cells[p_idx].normal[1]=n.y;
+ p_baker->bake_cells[p_idx].normal[2]=n.z;
+ }
+
+
+ p_baker->bake_cells[p_idx].alpha=1.0;
+
+ /*
+ //remove neighbours from used sides
+
+ for(int n=0;n<6;n++) {
+
+ int ofs[3]={0,0,0};
+
+ ofs[n/2]=(n&1)?1:-1;
+
+ //convert to x,y,z on this level
+ int x=p_x;
+ int y=p_y;
+ int z=p_z;
+
+ x+=ofs[0];
+ y+=ofs[1];
+ z+=ofs[2];
+
+ int ofs_x=0;
+ int ofs_y=0;
+ int ofs_z=0;
+ int size = 1<<p_level;
+ int half=size/2;
+
+
+ if (x<0 || x>=size || y<0 || y>=size || z<0 || z>=size) {
+ //neighbour is out, can't use it
+ p_baker->bake_cells[p_idx].used_sides&=~(1<<uint32_t(n));
+ continue;
+ }
+
+ uint32_t neighbour=0;
+
+ for(int i=0;i<p_baker->cell_subdiv-1;i++) {
+
+ Baker::Cell *bc = &p_baker->bake_cells[neighbour];
+
+ int child = 0;
+ if (x >= ofs_x + half) {
+ child|=1;
+ ofs_x+=half;
+ }
+ if (y >= ofs_y + half) {
+ child|=2;
+ ofs_y+=half;
+ }
+ if (z >= ofs_z + half) {
+ child|=4;
+ ofs_z+=half;
+ }
+
+ neighbour = bc->childs[child];
+ if (neighbour==Baker::CHILD_EMPTY) {
+ break;
+ }
+
+ half>>=1;
+ }
+
+ if (neighbour!=Baker::CHILD_EMPTY) {
+ p_baker->bake_cells[p_idx].used_sides&=~(1<<uint32_t(n));
+ }
+ }
+ */
+ } else {
+
+
+ //go down
+
+ float alpha_average=0;
+ int half = (1<<(p_baker->cell_subdiv-1)) >> (p_level+1);
+ for(int i=0;i<8;i++) {
+
+ uint32_t child = p_baker->bake_cells[p_idx].childs[i];
+
+ if (child==Baker::CHILD_EMPTY)
+ continue;
+
+
+ int nx=p_x;
+ int ny=p_y;
+ int nz=p_z;
+
+ if (i&1)
+ nx+=half;
+ if (i&2)
+ ny+=half;
+ if (i&4)
+ nz+=half;
+
+ _fixup_plot(child,p_level+1,nx,ny,nz,p_baker);
+ alpha_average+=p_baker->bake_cells[child].alpha;
+ }
+
+ p_baker->bake_cells[p_idx].alpha=alpha_average/8.0;
+ p_baker->bake_cells[p_idx].emission[0]=0;
+ p_baker->bake_cells[p_idx].emission[1]=0;
+ p_baker->bake_cells[p_idx].emission[2]=0;
+ p_baker->bake_cells[p_idx].normal[0]=0;
+ p_baker->bake_cells[p_idx].normal[1]=0;
+ p_baker->bake_cells[p_idx].normal[2]=0;
+ p_baker->bake_cells[p_idx].albedo[0]=0;
+ p_baker->bake_cells[p_idx].albedo[1]=0;
+ p_baker->bake_cells[p_idx].albedo[2]=0;
+
+ }
+
+}
+
+
+
+Vector<Color> GIProbe::_get_bake_texture(Image &p_image,const Color& p_color) {
+
+ Vector<Color> ret;
+
+ if (p_image.empty()) {
+
+ ret.resize(bake_texture_size*bake_texture_size);
+ for(int i=0;i<bake_texture_size*bake_texture_size;i++) {
+ ret[i]=p_color;
+ }
+
+ return ret;
+ }
+
+ p_image.convert(Image::FORMAT_RGBA8);
+ p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC);
+
+
+ PoolVector<uint8_t>::Read r = p_image.get_data().read();
+ ret.resize(bake_texture_size*bake_texture_size);
+
+ for(int i=0;i<bake_texture_size*bake_texture_size;i++) {
+ Color c;
+ c.r = r[i*4+0]/255.0;
+ c.g = r[i*4+1]/255.0;
+ c.b = r[i*4+2]/255.0;
+ c.a = r[i*4+3]/255.0;
+ ret[i]=c;
+
+ }
+
+ return ret;
+}
+
+
+GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_material,Baker *p_baker) {
+
+ //this way of obtaining materials is inaccurate and also does not support some compressed formats very well
+ Ref<FixedSpatialMaterial> mat = p_material;
+
+ Ref<Material> material = mat; //hack for now
+
+ if (p_baker->material_cache.has(material)) {
+ return p_baker->material_cache[material];
+ }
+
+ Baker::MaterialCache mc;
+
+ if (mat.is_valid()) {
+
+
+ Ref<ImageTexture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO);
+
+ Image img_albedo;
+ if (albedo_tex.is_valid()) {
+
+ img_albedo = albedo_tex->get_data();
+ }
+
+ mc.albedo=_get_bake_texture(img_albedo,mat->get_albedo());
+
+ Ref<ImageTexture> emission_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_EMISSION);
+
+ Color emission_col = mat->get_emission();
+ emission_col.r*=mat->get_emission_energy();
+ emission_col.g*=mat->get_emission_energy();
+ emission_col.b*=mat->get_emission_energy();
+
+ Image img_emission;
+
+ if (emission_tex.is_valid()) {
+
+ img_emission = emission_tex->get_data();
+ }
+
+ mc.emission=_get_bake_texture(img_emission,emission_col);
+
+ } else {
+ Image empty;
+
+ mc.albedo=_get_bake_texture(empty,Color(0.7,0.7,0.7));
+ mc.emission=_get_bake_texture(empty,Color(0,0,0));
+
+
+ }
+
+ p_baker->material_cache[p_material]=mc;
+ return mc;
+
+
+}
+
+void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker) {
+
+
+ for(int i=0;i<p_mesh->get_surface_count();i++) {
+
+ if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
+ continue; //only triangles
+
+ Baker::MaterialCache material = _get_material_cache(p_mesh->surface_get_material(i),p_baker);
+
+ Array a = p_mesh->surface_get_arrays(i);
+
+
+ PoolVector<Vector3> vertices = a[Mesh::ARRAY_VERTEX];
+ PoolVector<Vector3>::Read vr=vertices.read();
+ PoolVector<Vector2> uv = a[Mesh::ARRAY_TEX_UV];
+ PoolVector<Vector2>::Read uvr;
+ PoolVector<int> index = a[Mesh::ARRAY_INDEX];
+
+ bool read_uv=false;
+
+ if (uv.size()) {
+
+ uvr=uv.read();
+ read_uv=true;
+ }
+
+ if (index.size()) {
+
+ int facecount = index.size()/3;
+ PoolVector<int>::Read ir=index.read();
+
+ for(int j=0;j<facecount;j++) {
+
+ Vector3 vtxs[3];
+ Vector2 uvs[3];
+
+ for(int k=0;k<3;k++) {
+ vtxs[k]=p_xform.xform(vr[ir[j*3+k]]);
+ }
+
+ if (read_uv) {
+ for(int k=0;k<3;k++) {
+ uvs[k]=uvr[ir[j*3+k]];
+ }
+ }
+
+ //test against original bounds
+ if (!fast_tri_box_overlap(-extents,extents*2,vtxs))
+ continue;
+ //plot
+ _plot_face(0,0,0,0,0,vtxs,uvs,material,p_baker->po2_bounds,p_baker);
+ }
+
+
+
+ } else {
+
+ int facecount = vertices.size()/3;
+
+ for(int j=0;j<facecount;j++) {
+
+ Vector3 vtxs[3];
+ Vector2 uvs[3];
+
+ for(int k=0;k<3;k++) {
+ vtxs[k]=p_xform.xform(vr[j*3+k]);
+ }
+
+ if (read_uv) {
+ for(int k=0;k<3;k++) {
+ uvs[k]=uvr[j*3+k];
+ }
+ }
+
+ //test against original bounds
+ if (!fast_tri_box_overlap(-extents,extents*2,vtxs))
+ continue;
+ //plot face
+ _plot_face(0,0,0,0,0,vtxs,uvs,material,p_baker->po2_bounds,p_baker);
+ }
+
+ }
+ }
+}
+
+
+
+void GIProbe::_find_meshes(Node *p_at_node,Baker *p_baker){
+
+ MeshInstance *mi = p_at_node->cast_to<MeshInstance>();
+ if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
+ Ref<Mesh> mesh = mi->get_mesh();
+ if (mesh.is_valid()) {
+
+ Rect3 aabb = mesh->get_aabb();
+
+ Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform();
+
+ if (Rect3(-extents,extents*2).intersects(xf.xform(aabb))) {
+ Baker::PlotMesh pm;
+ pm.local_xform=xf;
+ pm.mesh=mesh;
+ p_baker->mesh_list.push_back(pm);
+
+ }
+ }
+ }
+
+ for(int i=0;i<p_at_node->get_child_count();i++) {
+
+ Node *child = p_at_node->get_child(i);
+ if (!child->get_owner())
+ continue; //maybe a helper
+
+ _find_meshes(child,p_baker);
+
+ }
+}
+
+
+
+
+void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug){
+
+ Baker baker;
+
+ static const int subdiv_value[SUBDIV_MAX]={7,8,9,10};
+
+ baker.cell_subdiv=subdiv_value[subdiv];
+ baker.bake_cells.resize(1);
+
+ //find out the actual real bounds, power of 2, which gets the highest subdivision
+ baker.po2_bounds=Rect3(-extents,extents*2.0);
+ int longest_axis = baker.po2_bounds.get_longest_axis_index();
+ baker.axis_cell_size[longest_axis]=(1<<(baker.cell_subdiv-1));
+ baker.leaf_voxel_count=0;
+
+ for(int i=0;i<3;i++) {
+
+ if (i==longest_axis)
+ continue;
+
+ baker.axis_cell_size[i]=baker.axis_cell_size[longest_axis];
+ float axis_size = baker.po2_bounds.size[longest_axis];
+
+ //shrink until fit subdiv
+ while (axis_size/2.0 >= baker.po2_bounds.size[i]) {
+ axis_size/=2.0;
+ baker.axis_cell_size[i]>>=1;
+ }
+
+ baker.po2_bounds.size[i]=baker.po2_bounds.size[longest_axis];
+ }
+
+
+
+ Transform to_bounds;
+ to_bounds.basis.scale(Vector3(baker.po2_bounds.size[longest_axis],baker.po2_bounds.size[longest_axis],baker.po2_bounds.size[longest_axis]));
+ to_bounds.origin=baker.po2_bounds.pos;
+
+ Transform to_grid;
+ to_grid.basis.scale(Vector3(baker.axis_cell_size[longest_axis],baker.axis_cell_size[longest_axis],baker.axis_cell_size[longest_axis]));
+
+ baker.to_cell_space = to_grid * to_bounds.affine_inverse();
+
+
+ _find_meshes(p_from_node?p_from_node:get_parent(),&baker);
+
+
+
+ int pmc=0;
+
+ for(List<Baker::PlotMesh>::Element *E=baker.mesh_list.front();E;E=E->next()) {
+
+ print_line("plotting mesh "+itos(pmc++)+"/"+itos(baker.mesh_list.size()));
+
+ _plot_mesh(E->get().local_xform,E->get().mesh,&baker);
+ }
+
+ _fixup_plot(0,0,0,0,0,&baker);
+
+ //create the data for visual server
+
+ PoolVector<int> data;
+
+ data.resize( 16+(8+1+1+1+1)*baker.bake_cells.size() ); //4 for header, rest for rest.
+
+ {
+ PoolVector<int>::Write w = data.write();
+
+ uint32_t * w32 = (uint32_t*)w.ptr();
+
+ w32[0]=0;//version
+ w32[1]=baker.cell_subdiv; //subdiv
+ w32[2]=baker.axis_cell_size[0];
+ w32[3]=baker.axis_cell_size[1];
+ w32[4]=baker.axis_cell_size[2];
+ w32[5]=baker.bake_cells.size();
+ w32[6]=baker.leaf_voxel_count;
+
+ int ofs=16;
+
+ for(int i=0;i<baker.bake_cells.size();i++) {
+
+ for(int j=0;j<8;j++) {
+ w32[ofs++]=baker.bake_cells[i].childs[j];
+ }
+
+ { //albedo
+ uint32_t rgba=uint32_t(CLAMP(baker.bake_cells[i].albedo[0]*255.0,0,255))<<16;
+ rgba|=uint32_t(CLAMP(baker.bake_cells[i].albedo[1]*255.0,0,255))<<8;
+ rgba|=uint32_t(CLAMP(baker.bake_cells[i].albedo[2]*255.0,0,255))<<0;
+
+ w32[ofs++]=rgba;
+
+
+ }
+ { //emission
+
+ Vector3 e(baker.bake_cells[i].emission[0],baker.bake_cells[i].emission[1],baker.bake_cells[i].emission[2]);
+ float l = e.length();
+ if (l>0) {
+ e.normalize();
+ l=CLAMP(l/8.0,0,1.0);
+ }
+
+ uint32_t em=uint32_t(CLAMP(e[0]*255,0,255))<<24;
+ em|=uint32_t(CLAMP(e[1]*255,0,255))<<16;
+ em|=uint32_t(CLAMP(e[2]*255,0,255))<<8;
+ em|=uint32_t(CLAMP(l*255,0,255));
+
+ w32[ofs++]=em;
+ }
+
+ //w32[ofs++]=baker.bake_cells[i].used_sides;
+ { //normal
+
+ Vector3 n(baker.bake_cells[i].normal[0],baker.bake_cells[i].normal[1],baker.bake_cells[i].normal[2]);
+ n=n*Vector3(0.5,0.5,0.5)+Vector3(0.5,0.5,0.5);
+ uint32_t norm=0;
+
+
+ norm|=uint32_t(CLAMP( n.x*255.0, 0, 255))<<16;
+ norm|=uint32_t(CLAMP( n.y*255.0, 0, 255))<<8;
+ norm|=uint32_t(CLAMP( n.z*255.0, 0, 255))<<0;
+
+ w32[ofs++]=norm;
+ }
+
+ {
+ uint16_t alpha = CLAMP(uint32_t(baker.bake_cells[i].alpha*65535.0),0,65535);
+ uint16_t level = baker.bake_cells[i].level;
+
+ w32[ofs++] = (uint32_t(level)<<16)|uint32_t(alpha);
+ }
+
+ }
+
+ }
+
+ Ref<GIProbeData> probe_data;
+ probe_data.instance();
+ probe_data->set_bounds(Rect3(-extents,extents*2.0));
+ probe_data->set_cell_size(baker.po2_bounds.size[longest_axis]/baker.axis_cell_size[longest_axis]);
+ probe_data->set_dynamic_data(data);
+ probe_data->set_dynamic_range(dynamic_range);
+ probe_data->set_energy(energy);
+ probe_data->set_interior(interior);
+ probe_data->set_compress(compress);
+ probe_data->set_to_cell_xform(baker.to_cell_space);
+
+ set_probe_data(probe_data);
+
+
+ if (p_create_visual_debug) {
+ //_create_debug_mesh(&baker);
+ }
+
+
+
+}
+
+
+void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb,Ref<MultiMesh> &p_multimesh,int &idx,Baker *p_baker) {
+
+
+ if (p_level==p_baker->cell_subdiv-1) {
+
+ Vector3 center = p_aabb.pos+p_aabb.size*0.5;
+ Transform xform;
+ xform.origin=center;
+ xform.basis.scale(p_aabb.size*0.5);
+ p_multimesh->set_instance_transform(idx,xform);
+ Color col=Color(p_baker->bake_cells[p_idx].albedo[0],p_baker->bake_cells[p_idx].albedo[1],p_baker->bake_cells[p_idx].albedo[2]);
+ p_multimesh->set_instance_color(idx,col);
+
+ idx++;
+
+ } else {
+
+ for(int i=0;i<8;i++) {
+
+ if (p_baker->bake_cells[p_idx].childs[i]==Baker::CHILD_EMPTY)
+ continue;
+
+ Rect3 aabb=p_aabb;
+ aabb.size*=0.5;
+
+ if (i&1)
+ aabb.pos.x+=aabb.size.x;
+ if (i&2)
+ aabb.pos.y+=aabb.size.y;
+ if (i&4)
+ aabb.pos.z+=aabb.size.z;
+
+ _debug_mesh(p_baker->bake_cells[p_idx].childs[i],p_level+1,aabb,p_multimesh,idx,p_baker);
+ }
+
+ }
+
+}
+
+
+void GIProbe::_create_debug_mesh(Baker *p_baker) {
+
+ Ref<MultiMesh> mm;
+ mm.instance();
+
+ mm->set_transform_format(MultiMesh::TRANSFORM_3D);
+ mm->set_color_format(MultiMesh::COLOR_8BIT);
+ print_line("leaf voxels: "+itos(p_baker->leaf_voxel_count));
+ mm->set_instance_count(p_baker->leaf_voxel_count);
+
+ Ref<Mesh> mesh;
+ mesh.instance();
+
+ {
+ Array arr;
+ arr.resize(Mesh::ARRAY_MAX);
+
+ PoolVector<Vector3> vertices;
+ PoolVector<Color> colors;
+
+ int vtx_idx=0;
+ #define ADD_VTX(m_idx);\
+ vertices.push_back( face_points[m_idx] );\
+ colors.push_back( Color(1,1,1,1) );\
+ vtx_idx++;\
+
+ for (int i=0;i<6;i++) {
+
+
+ Vector3 face_points[4];
+
+ for (int j=0;j<4;j++) {
+
+ float v[3];
+ v[0]=1.0;
+ v[1]=1-2*((j>>1)&1);
+ v[2]=v[1]*(1-2*(j&1));
+
+ for (int k=0;k<3;k++) {
+
+ if (i<3)
+ face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ else
+ face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ }
+ }
+
+ //tri 1
+ ADD_VTX(0);
+ ADD_VTX(1);
+ ADD_VTX(2);
+ //tri 2
+ ADD_VTX(2);
+ ADD_VTX(3);
+ ADD_VTX(0);
+
+ }
+
+
+ arr[Mesh::ARRAY_VERTEX]=vertices;
+ arr[Mesh::ARRAY_COLOR]=colors;
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,arr);
+ }
+
+ {
+ Ref<FixedSpatialMaterial> fsm;
+ fsm.instance();
+ fsm->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ fsm->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
+ fsm->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ fsm->set_albedo(Color(1,1,1,1));
+
+ mesh->surface_set_material(0,fsm);
+ }
+
+ mm->set_mesh(mesh);
+
+
+ int idx=0;
+ _debug_mesh(0,0,p_baker->po2_bounds,mm,idx,p_baker);
+
+ MultiMeshInstance *mmi = memnew( MultiMeshInstance );
+ mmi->set_multimesh(mm);
+ add_child(mmi);
+#ifdef TOOLS_ENABLED
+ if (get_tree()->get_edited_scene_root()==this){
+ mmi->set_owner(this);
+ } else {
+ mmi->set_owner(get_owner());
+
+ }
+#else
+ mmi->set_owner(get_owner());
+#endif
+
+}
+
+void GIProbe::_debug_bake() {
+
+ bake(NULL,true);
+}
+
+Rect3 GIProbe::get_aabb() const {
+
+ return Rect3(-extents,extents*2);
+}
+
+PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
+
+ return PoolVector<Face3>();
+}
+
+void GIProbe::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_probe_data","data"),&GIProbe::set_probe_data);
+ ClassDB::bind_method(_MD("get_probe_data"),&GIProbe::get_probe_data);
+
+ ClassDB::bind_method(_MD("set_subdiv","subdiv"),&GIProbe::set_subdiv);
+ ClassDB::bind_method(_MD("get_subdiv"),&GIProbe::get_subdiv);
+
+ ClassDB::bind_method(_MD("set_extents","extents"),&GIProbe::set_extents);
+ ClassDB::bind_method(_MD("get_extents"),&GIProbe::get_extents);
+
+ ClassDB::bind_method(_MD("set_dynamic_range","max"),&GIProbe::set_dynamic_range);
+ ClassDB::bind_method(_MD("get_dynamic_range"),&GIProbe::get_dynamic_range);
+
+ ClassDB::bind_method(_MD("set_energy","max"),&GIProbe::set_energy);
+ ClassDB::bind_method(_MD("get_energy"),&GIProbe::get_energy);
+
+ ClassDB::bind_method(_MD("set_interior","enable"),&GIProbe::set_interior);
+ ClassDB::bind_method(_MD("is_interior"),&GIProbe::is_interior);
+
+ ClassDB::bind_method(_MD("set_compress","enable"),&GIProbe::set_compress);
+ ClassDB::bind_method(_MD("is_compressed"),&GIProbe::is_compressed);
+
+ ClassDB::bind_method(_MD("bake","from_node","create_visual_debug"),&GIProbe::bake,DEFVAL(Variant()),DEFVAL(false));
+ ClassDB::bind_method(_MD("debug_bake"),&GIProbe::_debug_bake);
+ ClassDB::set_method_flags(get_class_static(),_SCS("debug_bake"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"subdiv",PROPERTY_HINT_ENUM,"64,128,256,512"),_SCS("set_subdiv"),_SCS("get_subdiv"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"),_SCS("set_extents"),_SCS("get_extents"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_RANGE,"1,16,1"),_SCS("set_dynamic_range"),_SCS("get_dynamic_range"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_energy"),_SCS("get_energy"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior"),_SCS("set_interior"),_SCS("is_interior"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"compress"),_SCS("set_compress"),_SCS("is_compressed"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"data",PROPERTY_HINT_RESOURCE_TYPE,"GIProbeData"),_SCS("set_probe_data"),_SCS("get_probe_data"));
+
+
+ BIND_CONSTANT( SUBDIV_64 );
+ BIND_CONSTANT( SUBDIV_128 );
+ BIND_CONSTANT( SUBDIV_256 );
+ BIND_CONSTANT( SUBDIV_MAX );
+
+}
+
+GIProbe::GIProbe() {
+
+ subdiv=SUBDIV_128;
+ dynamic_range=4;
+ energy=1.0;
+ extents=Vector3(10,10,10);
+ color_scan_cell_width=4;
+ bake_texture_size=128;
+ interior=false;
+ compress=false;
+
+ gi_probe = VS::get_singleton()->gi_probe_create();
+
+
+}
+
+GIProbe::~GIProbe() {
+
+
+}
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
new file mode 100644
index 0000000000..e416b28791
--- /dev/null
+++ b/scene/3d/gi_probe.h
@@ -0,0 +1,190 @@
+#ifndef GIPROBE_H
+#define GIPROBE_H
+
+#include "scene/3d/visual_instance.h"
+#include "multimesh_instance.h"
+
+class GIProbeData : public Resource {
+
+ GDCLASS(GIProbeData,Resource);
+
+ RID probe;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+
+ void set_bounds(const Rect3& p_bounds);
+ Rect3 get_bounds() const;
+
+ void set_cell_size(float p_size);
+ float get_cell_size() const;
+
+ void set_to_cell_xform(const Transform& p_xform);
+ Transform get_to_cell_xform() const;
+
+ void set_dynamic_data(const PoolVector<int>& p_data);
+ PoolVector<int> get_dynamic_data() const;
+
+ void set_dynamic_range(int p_range);
+ int get_dynamic_range() const;
+
+ void set_energy(float p_range);
+ float get_energy() const;
+
+ void set_interior(bool p_enable);
+ bool is_interior() const;
+
+ void set_compress(bool p_enable);
+ bool is_compressed() const;
+
+ virtual RID get_rid() const;
+
+ GIProbeData();
+ ~GIProbeData();
+};
+
+
+
+class GIProbe : public VisualInstance {
+ GDCLASS(GIProbe,VisualInstance);
+public:
+ enum Subdiv{
+ SUBDIV_64,
+ SUBDIV_128,
+ SUBDIV_256,
+ SUBDIV_512,
+ SUBDIV_MAX
+
+ };
+private:
+
+ //stuff used for bake
+ struct Baker {
+
+ enum {
+ CHILD_EMPTY=0xFFFFFFFF
+ };
+ struct Cell {
+
+ uint32_t childs[8];
+ float albedo[3]; //albedo in RGB24
+ float emission[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast)
+ float normal[3];
+ uint32_t used_sides;
+ float alpha; //used for upsampling
+ int level;
+
+ Cell() {
+ for(int i=0;i<8;i++) {
+ childs[i]=CHILD_EMPTY;
+ }
+
+ for(int i=0;i<3;i++) {
+ emission[i]=0;
+ albedo[i]=0;
+ normal[i]=0;
+ }
+ alpha=0;
+ used_sides=0;
+ level=0;
+ }
+ };
+
+ Vector<Cell> bake_cells;
+ int cell_subdiv;
+
+ struct MaterialCache {
+ //128x128 textures
+ Vector<Color> albedo;
+ Vector<Color> emission;
+ };
+
+
+ Vector<Color> _get_bake_texture(Image &p_image, const Color &p_color);
+ Map<Ref<Material>,MaterialCache> material_cache;
+ MaterialCache _get_material_cache(Ref<Material> p_material);
+ int leaf_voxel_count;
+
+
+ Rect3 po2_bounds;
+ int axis_cell_size[3];
+
+ struct PlotMesh {
+ Ref<Mesh> mesh;
+ Transform local_xform;
+ };
+
+ Transform to_cell_space;
+
+ List<PlotMesh> mesh_list;
+ };
+
+
+ Ref<GIProbeData> probe_data;
+
+ RID gi_probe;
+
+ Subdiv subdiv;
+ Vector3 extents;
+ int dynamic_range;
+ float energy;
+ bool interior;
+ bool compress;
+
+ int color_scan_cell_width;
+ int bake_texture_size;
+
+ Vector<Color> _get_bake_texture(Image &p_image,const Color& p_color);
+ Baker::MaterialCache _get_material_cache(Ref<Material> p_material,Baker *p_baker);
+ void _plot_face(int p_idx, int p_level, int p_x,int p_y,int p_z,const Vector3 *p_vtx, const Vector2* p_uv, const Baker::MaterialCache& p_material, const Rect3 &p_aabb,Baker *p_baker);
+ void _plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker);
+ void _find_meshes(Node *p_at_node,Baker *p_baker);
+ void _fixup_plot(int p_idx, int p_level,int p_x,int p_y, int p_z,Baker *p_baker);
+
+ void _debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb,Ref<MultiMesh> &p_multimesh,int &idx,Baker *p_baker);
+ void _create_debug_mesh(Baker *p_baker);
+
+ void _debug_bake();
+
+protected:
+
+ static void _bind_methods();
+public:
+
+ void set_probe_data(const Ref<GIProbeData>& p_data);
+ Ref<GIProbeData> get_probe_data() const;
+
+ void set_subdiv(Subdiv p_subdiv);
+ Subdiv get_subdiv() const;
+
+ void set_extents(const Vector3& p_extents);
+ Vector3 get_extents() const;
+
+ void set_dynamic_range(int p_dynamic_range);
+ int get_dynamic_range() const;
+
+ void set_energy(float p_energy);
+ float get_energy() const;
+
+ void set_interior(bool p_enable);
+ bool is_interior() const;
+
+ void set_compress(bool p_enable);
+ bool is_compressed() const;
+
+ void bake(Node *p_from_node=NULL,bool p_create_visual_debug=false);
+
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
+
+ GIProbe();
+ ~GIProbe();
+};
+
+VARIANT_ENUM_CAST(GIProbe::Subdiv)
+
+#endif // GIPROBE_H
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 99c7fd047f..08fc1f59e8 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -92,13 +92,13 @@ void ImmediateGeometry::clear(){
}
-AABB ImmediateGeometry::get_aabb() const {
+Rect3 ImmediateGeometry::get_aabb() const {
return aabb;
}
-DVector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+ return PoolVector<Face3>();
}
@@ -154,16 +154,16 @@ void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool
void ImmediateGeometry::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin,DEFVAL(Ref<Texture>()));
- ObjectTypeDB::bind_method(_MD("set_normal","normal"),&ImmediateGeometry::set_normal);
- ObjectTypeDB::bind_method(_MD("set_tangent","tangent"),&ImmediateGeometry::set_tangent);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ImmediateGeometry::set_color);
- ObjectTypeDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
- ObjectTypeDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
- ObjectTypeDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
- ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("end"),&ImmediateGeometry::end);
- ObjectTypeDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
+ ClassDB::bind_method(_MD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin,DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(_MD("set_normal","normal"),&ImmediateGeometry::set_normal);
+ ClassDB::bind_method(_MD("set_tangent","tangent"),&ImmediateGeometry::set_tangent);
+ ClassDB::bind_method(_MD("set_color","color"),&ImmediateGeometry::set_color);
+ ClassDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
+ ClassDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
+ ClassDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
+ ClassDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
+ ClassDB::bind_method(_MD("end"),&ImmediateGeometry::end);
+ ClassDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
}
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index fc7f4de634..e385a34da1 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class ImmediateGeometry : public GeometryInstance {
- OBJ_TYPE(ImmediateGeometry,GeometryInstance);
+ GDCLASS(ImmediateGeometry,GeometryInstance);
RID im;
@@ -42,7 +42,7 @@ class ImmediateGeometry : public GeometryInstance {
// in VisualServer from becoming invalid if the texture is no longer used
List<Ref<Texture> > cached_textures;
bool empty;
- AABB aabb;
+ Rect3 aabb;
protected:
static void _bind_methods();
@@ -66,8 +66,8 @@ public:
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
ImmediateGeometry();
~ImmediateGeometry();
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index 96306d1180..c7464d3c5d 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -134,15 +134,15 @@ real_t InterpolatedCamera::get_speed() const {
void InterpolatedCamera::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_target_path","target_path"),&InterpolatedCamera::set_target_path);
- ObjectTypeDB::bind_method(_MD("get_target_path"),&InterpolatedCamera::get_target_path);
- ObjectTypeDB::bind_method(_MD("set_target","target:Camera"),&InterpolatedCamera::_set_target);
+ ClassDB::bind_method(_MD("set_target_path","target_path"),&InterpolatedCamera::set_target_path);
+ ClassDB::bind_method(_MD("get_target_path"),&InterpolatedCamera::get_target_path);
+ ClassDB::bind_method(_MD("set_target","target:Camera"),&InterpolatedCamera::_set_target);
- ObjectTypeDB::bind_method(_MD("set_speed","speed"),&InterpolatedCamera::set_speed);
- ObjectTypeDB::bind_method(_MD("get_speed"),&InterpolatedCamera::get_speed);
+ ClassDB::bind_method(_MD("set_speed","speed"),&InterpolatedCamera::set_speed);
+ ClassDB::bind_method(_MD("get_speed"),&InterpolatedCamera::get_speed);
- ObjectTypeDB::bind_method(_MD("set_interpolation_enabled","target_path"),&InterpolatedCamera::set_interpolation_enabled);
- ObjectTypeDB::bind_method(_MD("is_interpolation_enabled"),&InterpolatedCamera::is_interpolation_enabled);
+ ClassDB::bind_method(_MD("set_interpolation_enabled","target_path"),&InterpolatedCamera::set_interpolation_enabled);
+ ClassDB::bind_method(_MD("is_interpolation_enabled"),&InterpolatedCamera::is_interpolation_enabled);
ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"target"), _SCS("set_target_path"), _SCS("get_target_path") );
ADD_PROPERTY( PropertyInfo(Variant::REAL,"speed"), _SCS("set_speed"), _SCS("get_speed") );
diff --git a/scene/3d/interpolated_camera.h b/scene/3d/interpolated_camera.h
index dbe84327fb..c78e6935da 100644
--- a/scene/3d/interpolated_camera.h
+++ b/scene/3d/interpolated_camera.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class InterpolatedCamera : public Camera {
- OBJ_TYPE(InterpolatedCamera,Camera);
+ GDCLASS(InterpolatedCamera,Camera);
bool enabled;
real_t speed;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 227bb3a59d..d685cd8ce7 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,413 +30,125 @@
#include "globals.h"
#include "scene/resources/surface_tool.h"
+#include "baked_light_instance.h"
-static const char* _light_param_names[VS::LIGHT_PARAM_MAX]={
- "params/spot_attenuation",
- "params/spot_angle",
- "params/radius",
- "params/energy",
- "params/attenuation",
- "shadow/darkening",
- "shadow/z_offset",
- "shadow/z_slope_scale",
- "shadow/esm_multiplier",
- "shadow/blur_passes"
-};
-
-void Light::set_parameter(Parameter p_param, float p_value) {
+bool Light::_can_gizmo_scale() const {
- ERR_FAIL_INDEX(p_param, PARAM_MAX);
- vars[p_param]=p_value;
- VisualServer::get_singleton()->light_set_param(light,(VisualServer::LightParam)p_param,p_value);
- if (p_param==PARAM_RADIUS || p_param==PARAM_SPOT_ANGLE)
- update_gizmo();
- _change_notify(_light_param_names[p_param]);
-// _change_notify(_param_names[p_param]);
+ return false;
}
-float Light::get_parameter(Parameter p_param) const {
- ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
- return vars[p_param];
+void Light::set_param(Param p_param, float p_value) {
-}
-
-void Light::set_color(LightColor p_color, const Color& p_value) {
+ ERR_FAIL_INDEX(p_param,PARAM_MAX);
+ param[p_param]=p_value;
- ERR_FAIL_INDEX(p_color, 3);
- colors[p_color]=p_value;
- VisualServer::get_singleton()->light_set_color(light,(VisualServer::LightColor)p_color,p_value);
- //_change_notify(_color_names[p_color]);
+ VS::get_singleton()->light_set_param(light,VS::LightParam(p_param),p_value);
-}
-Color Light::get_color(LightColor p_color) const {
+ if (p_param==PARAM_SPOT_ANGLE || p_param==PARAM_RANGE) {
+ update_gizmo();;
+ }
- ERR_FAIL_INDEX_V(p_color, 3, Color());
- return colors[p_color];
}
+float Light::get_param(Param p_param) const{
-void Light::set_project_shadows(bool p_enabled) {
+ ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ return param[p_param];
- shadows=p_enabled;
- VisualServer::get_singleton()->light_set_shadow(light, p_enabled);
- _change_notify("shadow");
}
-bool Light::has_project_shadows() const {
- return shadows;
-}
+void Light::set_shadow(bool p_enable){
-void Light::set_projector(const Ref<Texture>& p_projector) {
+ shadow=p_enable;
+ VS::get_singleton()->light_set_shadow(light,p_enable);
- projector=p_projector;
- VisualServer::get_singleton()->light_set_projector(light, projector.is_null()?RID():projector->get_rid());
}
+bool Light::has_shadow() const{
-Ref<Texture> Light::get_projector() const {
-
- return projector;
+ return shadow;
}
+void Light::set_negative(bool p_enable){
-bool Light::_can_gizmo_scale() const {
-
- return false;
+ negative=p_enable;
+ VS::get_singleton()->light_set_negative(light,p_enable);
}
+bool Light::is_negative() const{
-
-static void _make_sphere(int p_lats, int p_lons, float p_radius, Ref<SurfaceTool> p_tool) {
-
-
- p_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
- for(int i = 1; i <= p_lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats);
- double z0 = Math::sin(lat0);
- double zr0 = Math::cos(lat0);
-
- double lat1 = Math_PI * (-0.5 + (double) i / p_lats);
- double z1 = Math::sin(lat1);
- double zr1 = Math::cos(lat1);
-
- for(int j = p_lons; j >= 1; j--) {
-
- double lng0 = 2 * Math_PI * (double) (j - 1) / p_lons;
- double x0 = Math::cos(lng0);
- double y0 = Math::sin(lng0);
-
- double lng1 = 2 * Math_PI * (double) (j) / p_lons;
- double x1 = Math::cos(lng1);
- double y1 = Math::sin(lng1);
-
-
- Vector3 v[4]={
- Vector3(x1 * zr0, z0, y1 *zr0),
- Vector3(x1 * zr1, z1, y1 *zr1),
- Vector3(x0 * zr1, z1, y0 *zr1),
- Vector3(x0 * zr0, z0, y0 *zr0)
- };
-
-#define ADD_POINT(m_idx) \
- p_tool->add_normal(v[m_idx]);\
- p_tool->add_vertex(v[m_idx]*p_radius);
-
- ADD_POINT(0);
- ADD_POINT(1);
- ADD_POINT(2);
-
- ADD_POINT(2);
- ADD_POINT(3);
- ADD_POINT(0);
- }
- }
-
+ return negative;
}
-RES Light::_get_gizmo_geometry() const {
-
-
- Ref<FixedMaterial> mat_area( memnew( FixedMaterial ));
-
- mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.7,0.6,0.0,0.05) );
- mat_area->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.7,0.7,0.7) );
- mat_area->set_blend_mode( Material::BLEND_MODE_ADD );
- mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- Ref<FixedMaterial> mat_light( memnew( FixedMaterial ));
-
- mat_light->set_parameter( FixedMaterial::PARAM_DIFFUSE, Color(1.0,1.0,0.8,0.9) );
- mat_light->set_flag(Material::FLAG_UNSHADED,true);
-
- Ref< Mesh > mesh;
-
- Ref<SurfaceTool> surftool( memnew( SurfaceTool ));
-
- switch(type) {
-
- case VisualServer::LIGHT_DIRECTIONAL: {
-
-
- mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.9,0.8,0.1,0.8) );
- mat_area->set_blend_mode( Material::BLEND_MODE_MIX);
- mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,false);
- mat_area->set_flag(Material::FLAG_UNSHADED,true);
-
- _make_sphere( 5,5,0.6, surftool );
- surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
-
- // float radius=1;
-
- surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
- const int arrow_points=5;
- Vector3 arrow[arrow_points]={
- Vector3(0,0,2),
- Vector3(1,1,2),
- Vector3(1,1,-1),
- Vector3(2,2,-1),
- Vector3(0,0,-3)
- };
-
- int arrow_sides=4;
+void Light::set_cull_mask(uint32_t p_cull_mask){
+ cull_mask=p_cull_mask;
+ VS::get_singleton()->light_set_cull_mask(light,p_cull_mask);
- for(int i = 0; i < arrow_sides ; i++) {
-
-
- Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
- Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);
-
-
- for(int j=0;j<arrow_points-1;j++) {
-
- Vector3 points[4]={
- ma.xform(arrow[j]),
- mb.xform(arrow[j]),
- mb.xform(arrow[j+1]),
- ma.xform(arrow[j+1]),
- };
-
- Vector3 n = Plane(points[0],points[1],points[2]).normal;
-
- surftool->add_normal(n);
- surftool->add_vertex(points[0]);
- surftool->add_normal(n);
- surftool->add_vertex(points[1]);
- surftool->add_normal(n);
- surftool->add_vertex(points[2]);
-
- surftool->add_normal(n);
- surftool->add_vertex(points[0]);
- surftool->add_normal(n);
- surftool->add_vertex(points[2]);
- surftool->add_normal(n);
- surftool->add_vertex(points[3]);
-
-
- }
-
-
- }
-
- surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
-
-
-
- } break;
- case VisualServer::LIGHT_OMNI: {
-
-
- _make_sphere( 20,20,vars[PARAM_RADIUS], surftool );
- surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
- _make_sphere(5,5, 0.1, surftool );
- surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
- } break;
-
- case VisualServer::LIGHT_SPOT: {
-
- _make_sphere( 5,5,0.1, surftool );
- surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
-
- // make cone
- int points=24;
- float len=vars[PARAM_RADIUS];
- float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
-
- surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
- for(int i = 0; i < points; i++) {
-
- float x0=Math::sin(i * Math_PI * 2 / points);
- float y0=Math::cos(i * Math_PI * 2 / points);
- float x1=Math::sin((i+1) * Math_PI * 2 / points);
- float y1=Math::cos((i+1) * Math_PI * 2 / points);
-
- Vector3 v1=Vector3(x0*size,y0*size,-len).normalized()*len;
- Vector3 v2=Vector3(x1*size,y1*size,-len).normalized()*len;
-
- Vector3 v3=Vector3(0,0,0);
- Vector3 v4=Vector3(0,0,v1.z);
-
- Vector3 n = Plane(v1,v2,v3).normal;
-
-
- surftool->add_normal(n);
- surftool->add_vertex(v1);
- surftool->add_normal(n);
- surftool->add_vertex(v2);
- surftool->add_normal(n);
- surftool->add_vertex(v3);
-
- n=Vector3(0,0,-1);
-
- surftool->add_normal(n);
- surftool->add_vertex(v1);
- surftool->add_normal(n);
- surftool->add_vertex(v2);
- surftool->add_normal(n);
- surftool->add_vertex(v4);
-
-
- }
-
- surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
-
-
- } break;
- }
-
- return mesh;
}
+uint32_t Light::get_cull_mask() const{
-
-AABB Light::get_aabb() const {
-
- if (type==VisualServer::LIGHT_DIRECTIONAL) {
-
- return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
-
- } else if (type==VisualServer::LIGHT_OMNI) {
-
- return AABB( Vector3(-1,-1,-1) * vars[PARAM_RADIUS], Vector3(2, 2, 2 ) * vars[PARAM_RADIUS]);
-
- } else if (type==VisualServer::LIGHT_SPOT) {
-
- float len=vars[PARAM_RADIUS];
- float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
- return AABB( Vector3( -size,-size,-len ), Vector3( size*2, size*2, len ) );
- }
-
- return AABB();
-}
-
-DVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
-
- return DVector<Face3>();
+ return cull_mask;
}
+void Light::set_color(const Color& p_color){
-void Light::set_operator(Operator p_op) {
- ERR_FAIL_INDEX(p_op,2);
- op=p_op;
- VisualServer::get_singleton()->light_set_operator(light,VS::LightOp(op));
-
+ color=p_color;
+ VS::get_singleton()->light_set_color(light,p_color);
}
+Color Light::get_color() const{
-void Light::set_bake_mode(BakeMode p_bake_mode) {
-
- bake_mode=p_bake_mode;
+ return color;
}
-Light::BakeMode Light::get_bake_mode() const {
+void Light::set_shadow_color(const Color& p_shadow_color){
- return bake_mode;
+ shadow_color=p_shadow_color;
+ VS::get_singleton()->light_set_shadow_color(light,p_shadow_color);
}
+Color Light::get_shadow_color() const{
-Light::Operator Light::get_operator() const {
-
- return op;
+ return shadow_color;
}
-void Light::approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic,float p_radius_treshold) {
-
- //this is horrible and must never be used
-
- float a = p_quadratic * p_radius_treshold;
- float b = p_linear * p_radius_treshold;
- float c = p_constant * p_radius_treshold -1;
-
- float radius=10000;
-
- if(a == 0) { // solve linear
- float d = Math::abs(-c/b);
- if(d<radius)
- radius=d;
-
-
- } else { // solve quadratic
- // now ad^2 + bd + c = 0, solve quadratic equation:
-
- float denominator = 2*a;
-
- if(denominator != 0) {
+Rect3 Light::get_aabb() const {
- float root = b*b - 4*a*c;
- if(root >=0) {
+ if (type==VisualServer::LIGHT_DIRECTIONAL) {
- root = sqrt(root);
+ return Rect3( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
- float solution1 = fabs( (-b + root) / denominator);
- float solution2 = fabs( (-b - root) / denominator);
+ } else if (type==VisualServer::LIGHT_OMNI) {
- if(solution1 > radius)
- solution1 = radius;
+ return Rect3( Vector3(-1,-1,-1) * param[PARAM_RANGE], Vector3(2, 2, 2 ) * param[PARAM_RANGE]);
- if(solution2 > radius)
- solution2 = radius;
+ } else if (type==VisualServer::LIGHT_SPOT) {
- radius = (solution1 > solution2 ? solution1 : solution2);
- }
- }
+ float len=param[PARAM_RANGE];
+ float size=Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE]))*len;
+ return Rect3( Vector3( -size,-size,-len ), Vector3( size*2, size*2, len ) );
}
- float energy=1.0;
-
- /*if (p_constant>0)
- energy=1.0/p_constant; //energy is this
- else
- energy=8.0; // some high number..
-*/
-
- if (radius==10000)
- radius=100; //bug?
+ return Rect3();
+}
- set_parameter(PARAM_RADIUS,radius);
- set_parameter(PARAM_ENERGY,energy);
+PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
+ return PoolVector<Face3>();
}
+
void Light::_update_visibility() {
if (!is_inside_tree())
return;
-bool editor_ok=true;
+ bool editor_ok=true;
#ifdef TOOLS_ENABLED
if (editor_only) {
@@ -446,9 +158,13 @@ bool editor_ok=true;
editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root()));
}
}
+#else
+ if (editor_only) {
+ editor_ok=false;
+ }
#endif
- VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && enabled && editor_ok);
+ //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible_in_tree() && editor_ok);
_change_notify("geometry/visible");
}
@@ -456,22 +172,40 @@ bool editor_ok=true;
void Light::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
_update_visibility();
+
}
-}
-void Light::set_enabled(bool p_enabled) {
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+ _update_visibility();
- enabled=p_enabled;
- _update_visibility();
-}
+ Node *node = this;
+
+ while(node) {
-bool Light::is_enabled() const{
+ baked_light=node->cast_to<BakedLight>();
+ if (baked_light) {
+ baked_light->lights.insert(this);
+ break;
+ }
+
+ node=node->get_parent();
+ }
+ }
+
+ if (p_what==NOTIFICATION_EXIT_TREE) {
+
+ if (baked_light) {
+ baked_light->lights.erase(this);
+ }
+ }
- return enabled;
}
+
void Light::set_editor_only(bool p_editor_only) {
editor_only=p_editor_only;
@@ -486,68 +220,58 @@ bool Light::is_editor_only() const{
void Light::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_parameter","variable","value"), &Light::set_parameter );
- ObjectTypeDB::bind_method(_MD("get_parameter","variable"), &Light::get_parameter );
- ObjectTypeDB::bind_method(_MD("set_color","color","value"), &Light::set_color );
- ObjectTypeDB::bind_method(_MD("get_color","color"), &Light::get_color );
- ObjectTypeDB::bind_method(_MD("set_project_shadows","enable"), &Light::set_project_shadows );
- ObjectTypeDB::bind_method(_MD("has_project_shadows"), &Light::has_project_shadows );
- ObjectTypeDB::bind_method(_MD("set_projector","projector:Texture"), &Light::set_projector );
- ObjectTypeDB::bind_method(_MD("get_projector:Texture"), &Light::get_projector );
- ObjectTypeDB::bind_method(_MD("set_operator","operator"), &Light::set_operator );
- ObjectTypeDB::bind_method(_MD("get_operator"), &Light::get_operator );
- ObjectTypeDB::bind_method(_MD("set_bake_mode","bake_mode"), &Light::set_bake_mode );
- ObjectTypeDB::bind_method(_MD("get_bake_mode"), &Light::get_bake_mode );
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"), &Light::set_enabled );
- ObjectTypeDB::bind_method(_MD("is_enabled"), &Light::is_enabled );
- ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light::set_editor_only );
- ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light::is_editor_only );
-
-
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "params/enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "params/editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/bake_mode",PROPERTY_HINT_ENUM,"Disabled,Indirect,Indirect+Shadows,Full"), _SCS("set_bake_mode"), _SCS("get_bake_mode"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/energy", PROPERTY_HINT_EXP_RANGE, "0,64,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ENERGY );
- /*
- if (type == VisualServer::LIGHT_OMNI || type == VisualServer::LIGHT_SPOT) {
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_RANGE, "0,8,0.01"));
- }
- if (type == VisualServer::LIGHT_SPOT) {
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/spot_angle", PROPERTY_HINT_RANGE, "0.01,90.0,0.01"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_RANGE, "0,8,0.01"));
+ ClassDB::bind_method(_MD("set_editor_only","editor_only"), &Light::set_editor_only );
+ ClassDB::bind_method(_MD("is_editor_only"), &Light::is_editor_only );
+
+
+ ClassDB::bind_method(_MD("set_param","param","value"), &Light::set_param );
+ ClassDB::bind_method(_MD("get_param","param"), &Light::get_param );
+
+ ClassDB::bind_method(_MD("set_shadow","enabled"), &Light::set_shadow );
+ ClassDB::bind_method(_MD("has_shadow"), &Light::has_shadow );
+
+ ClassDB::bind_method(_MD("set_negative","enabled"), &Light::set_negative );
+ ClassDB::bind_method(_MD("is_negative"), &Light::is_negative );
- }*/
+ ClassDB::bind_method(_MD("set_cull_mask","cull_mask"), &Light::set_cull_mask );
+ ClassDB::bind_method(_MD("get_cull_mask"), &Light::get_cull_mask );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/diffuse"), _SCS("set_color"), _SCS("get_color"),COLOR_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/specular"), _SCS("set_color"), _SCS("get_color"),COLOR_SPECULAR);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow/shadow"), _SCS("set_project_shadows"), _SCS("has_project_shadows"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/darkening", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_DARKENING );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/z_offset", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_OFFSET);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/z_slope_scale", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_SLOPE_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/esm_multiplier", PROPERTY_HINT_RANGE, "1.0,512.0,0.1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_ESM_MULTIPLIER);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, "shadow/blur_passes", PROPERTY_HINT_RANGE, "0,4,1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_BLUR_PASSES);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "projector",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_projector"), _SCS("get_projector"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "operator",PROPERTY_HINT_ENUM,"Add,Sub"), _SCS("set_operator"), _SCS("get_operator"));
+ ClassDB::bind_method(_MD("set_color","color"), &Light::set_color );
+ ClassDB::bind_method(_MD("get_color"), &Light::get_color );
+ ClassDB::bind_method(_MD("set_shadow_color","shadow_color"), &Light::set_shadow_color );
+ ClassDB::bind_method(_MD("get_shadow_color"), &Light::get_shadow_color );
+
+ ADD_GROUP("Light","light_");
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color",PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_color"), _SCS("get_color"));
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "light_energy",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ENERGY);
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "light_negative"), _SCS("set_negative"), _SCS("is_negative"));
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "light_specular",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SPECULAR);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "light_cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER), _SCS("set_cull_mask"), _SCS("get_cull_mask"));
+ ADD_GROUP("Shadow","shadow_");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow_enabled"), _SCS("set_shadow"), _SCS("has_shadow"));
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "shadow_color",PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_shadow_color"), _SCS("get_shadow_color"));
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_bias",PROPERTY_HINT_RANGE,"-16,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_BIAS);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_max_distance",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_MAX_DISTANCE);
+ ADD_GROUP("Editor","");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
+ ADD_GROUP("","");
- BIND_CONSTANT( PARAM_RADIUS );
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_SHADOW_DARKENING );
- BIND_CONSTANT( PARAM_SHADOW_Z_OFFSET );
-
-
- BIND_CONSTANT( COLOR_DIFFUSE );
- BIND_CONSTANT( COLOR_SPECULAR );
-
- BIND_CONSTANT( BAKE_MODE_DISABLED );
- BIND_CONSTANT( BAKE_MODE_INDIRECT );
- BIND_CONSTANT( BAKE_MODE_INDIRECT_AND_SHADOWS );
- BIND_CONSTANT( BAKE_MODE_FULL );
+ 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_CONSTANT( PARAM_SHADOW_BIAS_SPLIT_SCALE );
+ BIND_CONSTANT( PARAM_MAX );
}
@@ -557,28 +281,29 @@ Light::Light(VisualServer::LightType p_type) {
type=p_type;
light=VisualServer::get_singleton()->light_create(p_type);
+ VS::get_singleton()->instance_set_base(get_instance(),light);
+
+ baked_light=NULL;
- set_parameter(PARAM_SPOT_ATTENUATION,1.0);
- set_parameter(PARAM_SPOT_ANGLE,30.0);
- set_parameter(PARAM_RADIUS,2.0);
- set_parameter(PARAM_ENERGY,1.0);
- set_parameter(PARAM_ATTENUATION,1.0);
- set_parameter(PARAM_SHADOW_DARKENING,0.0);
- set_parameter(PARAM_SHADOW_Z_OFFSET,0.05);
- set_parameter(PARAM_SHADOW_Z_SLOPE_SCALE,0);
- set_parameter(PARAM_SHADOW_ESM_MULTIPLIER,60);
- set_parameter(PARAM_SHADOW_BLUR_PASSES,1);
-
-
- set_color( COLOR_DIFFUSE, Color(1,1,1));
- set_color( COLOR_SPECULAR, Color(1,1,1));
-
- op=OPERATOR_ADD;
- set_project_shadows( false );
- set_base(light);
- enabled=true;
editor_only=false;
- bake_mode=BAKE_MODE_DISABLED;
+ set_color(Color(1,1,1,1));
+ set_shadow(false);
+ set_negative(false);
+ set_cull_mask(0xFFFFFFFF);
+
+ set_param(PARAM_ENERGY,1);
+ set_param(PARAM_SPECULAR,0.5);
+ set_param(PARAM_RANGE,5);
+ set_param(PARAM_ATTENUATION,1);
+ set_param(PARAM_SPOT_ANGLE,45);
+ set_param(PARAM_SPOT_ATTENUATION,1);
+ set_param(PARAM_SHADOW_MAX_DISTANCE,0);
+ set_param(PARAM_SHADOW_SPLIT_1_OFFSET,0.1);
+ set_param(PARAM_SHADOW_SPLIT_2_OFFSET,0.2);
+ set_param(PARAM_SHADOW_SPLIT_3_OFFSET,0.5);
+ set_param(PARAM_SHADOW_NORMAL_BIAS,0.1);
+ set_param(PARAM_SHADOW_BIAS,0.1);
+ set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE,0.1);
}
@@ -592,85 +317,119 @@ Light::Light() {
Light::~Light() {
+ VS::get_singleton()->instance_set_base(get_instance(),RID());
+
if (light.is_valid())
VisualServer::get_singleton()->free(light);
}
/////////////////////////////////////////
-
void DirectionalLight::set_shadow_mode(ShadowMode p_mode) {
shadow_mode=p_mode;
- VS::get_singleton()->light_directional_set_shadow_mode(light,(VS::LightDirectionalShadowMode)p_mode);
-
+ VS::get_singleton()->light_directional_set_shadow_mode(light,VS::LightDirectionalShadowMode(p_mode));
}
-DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const{
+DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
return shadow_mode;
}
-void DirectionalLight::set_shadow_param(ShadowParam p_param, float p_value) {
+void DirectionalLight::set_blend_splits(bool p_enable) {
- ERR_FAIL_INDEX(p_param,3);
- shadow_param[p_param]=p_value;
- VS::get_singleton()->light_directional_set_shadow_param(light,VS::LightDirectionalShadowParam(p_param),p_value);
+ blend_splits=p_enable;
+ VS::get_singleton()->light_directional_set_blend_splits(light,p_enable);
}
-float DirectionalLight::get_shadow_param(ShadowParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,3,0);
- return shadow_param[p_param];
+bool DirectionalLight::is_blend_splits_enabled() const {
+
+ return blend_splits;
}
+
void DirectionalLight::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shadow_mode","mode"),&DirectionalLight::set_shadow_mode);
- ObjectTypeDB::bind_method(_MD("get_shadow_mode"),&DirectionalLight::get_shadow_mode);
- ObjectTypeDB::bind_method(_MD("set_shadow_param","param","value"),&DirectionalLight::set_shadow_param);
- ObjectTypeDB::bind_method(_MD("get_shadow_param","param"),&DirectionalLight::get_shadow_param);
+ ClassDB::bind_method( _MD("set_shadow_mode","mode"),&DirectionalLight::set_shadow_mode);
+ ClassDB::bind_method( _MD("get_shadow_mode"),&DirectionalLight::get_shadow_mode);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/mode",PROPERTY_HINT_ENUM,"Orthogonal,Perspective,PSSM 2 Splits,PSSM 4 Splits"),_SCS("set_shadow_mode"),_SCS("get_shadow_mode"));
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/max_distance",PROPERTY_HINT_EXP_RANGE,"0.00,99999,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/split_weight",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_PSSM_SPLIT_WEIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/zoffset_scale",PROPERTY_HINT_RANGE,"0.01,1024.0,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_PSSM_ZOFFSET_SCALE);
+ ClassDB::bind_method( _MD("set_blend_splits","enabled"),&DirectionalLight::set_blend_splits);
+ ClassDB::bind_method( _MD("is_blend_splits_enabled"),&DirectionalLight::is_blend_splits_enabled);
+
+ ADD_GROUP("Directional Shadow","directional_shadow_");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "directional_shadow_mode",PROPERTY_HINT_ENUM,"Orthogonal,PSSM 2 Splits,PSSM 4 Splits"), _SCS("set_shadow_mode"), _SCS("get_shadow_mode"));
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_1",PROPERTY_HINT_RANGE,"0,1,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_SPLIT_1_OFFSET);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_2",PROPERTY_HINT_RANGE,"0,1,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_SPLIT_2_OFFSET);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_3",PROPERTY_HINT_RANGE,"0,1,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_SPLIT_3_OFFSET);
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "directional_shadow_blend_splits"), _SCS("set_blend_splits"), _SCS("is_blend_splits_enabled"));
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_normal_bias",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_NORMAL_BIAS);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_bias_split_scale",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_BIAS_SPLIT_SCALE);
BIND_CONSTANT( SHADOW_ORTHOGONAL );
- BIND_CONSTANT( SHADOW_PERSPECTIVE );
BIND_CONSTANT( SHADOW_PARALLEL_2_SPLITS );
BIND_CONSTANT( SHADOW_PARALLEL_4_SPLITS );
- BIND_CONSTANT( SHADOW_PARAM_MAX_DISTANCE );
- BIND_CONSTANT( SHADOW_PARAM_PSSM_SPLIT_WEIGHT );
- BIND_CONSTANT( SHADOW_PARAM_PSSM_ZOFFSET_SCALE );
}
DirectionalLight::DirectionalLight() : Light( VisualServer::LIGHT_DIRECTIONAL ) {
- shadow_mode=SHADOW_ORTHOGONAL;
- shadow_param[SHADOW_PARAM_MAX_DISTANCE]=0;
- shadow_param[SHADOW_PARAM_PSSM_SPLIT_WEIGHT]=0.5;
- shadow_param[SHADOW_PARAM_PSSM_ZOFFSET_SCALE]=2.0;
+ set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
+ blend_splits=false;
+}
+void OmniLight::set_shadow_mode(ShadowMode p_mode) {
+ shadow_mode=p_mode;
+ VS::get_singleton()->light_omni_set_shadow_mode(light,VS::LightOmniShadowMode(p_mode));
}
+OmniLight::ShadowMode OmniLight::get_shadow_mode() const{
-void OmniLight::_bind_methods() {
+ return shadow_mode;
+}
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION );
+void OmniLight::set_shadow_detail(ShadowDetail p_detail){
+ shadow_detail=p_detail;
+ VS::get_singleton()->light_omni_set_shadow_detail(light,VS::LightOmniShadowDetail(p_detail));
+}
+OmniLight::ShadowDetail OmniLight::get_shadow_detail() const{
+
+ return shadow_detail;
}
-void SpotLight::_bind_methods() {
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_angle", PROPERTY_HINT_RANGE, "0.01,89.9,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ANGLE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_EXP_EASING, "spot_attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ATTENUATION );
+
+void OmniLight::_bind_methods() {
+
+ ClassDB::bind_method( _MD("set_shadow_mode","mode"),&OmniLight::set_shadow_mode);
+ ClassDB::bind_method( _MD("get_shadow_mode"),&OmniLight::get_shadow_mode);
+
+ ClassDB::bind_method( _MD("set_shadow_detail","detail"),&OmniLight::set_shadow_detail);
+ ClassDB::bind_method( _MD("get_shadow_detail"),&OmniLight::get_shadow_detail);
+
+ ADD_GROUP("Omni","omni_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "omni_range",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_RANGE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "omni_attenuation",PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "omni_shadow_mode",PROPERTY_HINT_ENUM,"Dual Paraboloid,Cube"), _SCS("set_shadow_mode"), _SCS("get_shadow_mode"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "omni_shadow_detail",PROPERTY_HINT_ENUM,"Vertical,Horizontal"), _SCS("set_shadow_detail"), _SCS("get_shadow_detail"));
+
+}
+
+OmniLight::OmniLight() : Light( VisualServer::LIGHT_OMNI ) {
+
+ set_shadow_mode(SHADOW_DUAL_PARABOLOID);
+ set_shadow_detail(SHADOW_DETAIL_HORIZONTAL);
}
+void SpotLight::_bind_methods() {
+ ADD_GROUP("Spot","spot_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_range",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_RANGE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_attenuation",PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_angle",PROPERTY_HINT_RANGE,"0,180,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_SPOT_ANGLE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_angle_attenuation",PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_SPOT_ATTENUATION);
+
+}
diff --git a/scene/3d/light.h b/scene/3d/light.h
index b25c6a44b5..d27b9fed12 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,65 +37,47 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class Light : public VisualInstance {
-
- OBJ_TYPE( Light, VisualInstance );
- OBJ_CATEGORY("3D Light Nodes");
-public:
-
- enum Parameter {
- PARAM_RADIUS=VisualServer::LIGHT_PARAM_RADIUS,
- PARAM_ENERGY=VisualServer::LIGHT_PARAM_ENERGY,
- PARAM_ATTENUATION=VisualServer::LIGHT_PARAM_ATTENUATION,
- PARAM_SPOT_ANGLE=VisualServer::LIGHT_PARAM_SPOT_ANGLE,
- PARAM_SPOT_ATTENUATION=VisualServer::LIGHT_PARAM_SPOT_ATTENUATION,
- PARAM_SHADOW_DARKENING=VisualServer::LIGHT_PARAM_SHADOW_DARKENING,
- PARAM_SHADOW_Z_OFFSET=VisualServer::LIGHT_PARAM_SHADOW_Z_OFFSET,
- PARAM_SHADOW_Z_SLOPE_SCALE=VisualServer::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE,
- PARAM_SHADOW_ESM_MULTIPLIER=VisualServer::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER,
- PARAM_SHADOW_BLUR_PASSES=VisualServer::LIGHT_PARAM_SHADOW_BLUR_PASSES,
- PARAM_MAX=VisualServer::LIGHT_PARAM_MAX
- };
+class BakedLight;
- enum LightColor {
-
- COLOR_DIFFUSE=VisualServer::LIGHT_COLOR_DIFFUSE,
- COLOR_SPECULAR=VisualServer::LIGHT_COLOR_SPECULAR
- };
+class Light : public VisualInstance {
- enum BakeMode {
+ GDCLASS( Light, VisualInstance );
+ OBJ_CATEGORY("3D Light Nodes");
- BAKE_MODE_DISABLED,
- BAKE_MODE_INDIRECT,
- BAKE_MODE_INDIRECT_AND_SHADOWS,
- BAKE_MODE_FULL
+public:
+ enum Param {
+ PARAM_ENERGY = VS::LIGHT_PARAM_ENERGY,
+ PARAM_SPECULAR = VS::LIGHT_PARAM_SPECULAR,
+ PARAM_RANGE = VS::LIGHT_PARAM_RANGE,
+ PARAM_ATTENUATION = VS::LIGHT_PARAM_ATTENUATION,
+ PARAM_SPOT_ANGLE = VS::LIGHT_PARAM_SPOT_ANGLE,
+ PARAM_SPOT_ATTENUATION = VS::LIGHT_PARAM_SPOT_ATTENUATION,
+ PARAM_SHADOW_MAX_DISTANCE = VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE,
+ PARAM_SHADOW_SPLIT_1_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
+ PARAM_SHADOW_SPLIT_2_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
+ 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
};
-
- enum Operator {
-
- OPERATOR_ADD,
- OPERATOR_SUB
- };
private:
-
- Ref<Texture> projector;
- float vars[PARAM_MAX];
- Color colors[3];
-
-
- BakeMode bake_mode;
- VisualServer::LightType type;
- bool shadows;
- bool enabled;
+ Color color;
+ float param[PARAM_MAX];
+ Color shadow_color;
+ bool shadow;
+ bool negative;
+ uint32_t cull_mask;
+ VS::LightType type;
bool editor_only;
- Operator op;
-
void _update_visibility();
+
+ BakedLight *baked_light;
// bind helpers
protected:
@@ -103,8 +85,7 @@ protected:
RID light;
virtual bool _can_gizmo_scale() const;
- virtual RES _get_gizmo_geometry() const;
-
+
static void _bind_methods();
void _notification(int p_what);
@@ -114,67 +95,56 @@ public:
VS::LightType get_light_type() const { return type; }
- void set_parameter(Parameter p_var, float p_value);
- float get_parameter(Parameter p_var) const;
-
- void set_color(LightColor p_color,const Color& p_value);
- Color get_color(LightColor p_color) const;
+ void set_editor_only(bool p_editor_only);
+ bool is_editor_only() const;
- void set_project_shadows(bool p_enabled);
- bool has_project_shadows() const;
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
- void set_projector(const Ref<Texture>& p_projector);
- Ref<Texture> get_projector() const;
+ void set_shadow(bool p_enable);
+ bool has_shadow() const;
- void set_operator(Operator p_op);
- Operator get_operator() const;
+ void set_negative(bool p_enable);
+ bool is_negative() const;
- void set_bake_mode(BakeMode p_bake_mode);
- BakeMode get_bake_mode() const;
+ void set_cull_mask(uint32_t p_cull_mask);
+ uint32_t get_cull_mask() const;
- void set_enabled(bool p_enabled);
- bool is_enabled() const;
+ void set_color(const Color& p_color);
+ Color get_color() const;
- void set_editor_only(bool p_editor_only);
- bool is_editor_only() const;
+ void set_shadow_color(const Color& p_shadow_color);
+ Color get_shadow_color() const;
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- void approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic, float p_radius_treshold=0.5);
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
Light();
~Light();
};
-VARIANT_ENUM_CAST( Light::Parameter );
-VARIANT_ENUM_CAST( Light::LightColor );
-VARIANT_ENUM_CAST( Light::Operator );
-VARIANT_ENUM_CAST( Light::BakeMode);
+VARIANT_ENUM_CAST(Light::Param);
class DirectionalLight : public Light {
- OBJ_TYPE( DirectionalLight, Light );
+ GDCLASS( DirectionalLight, Light );
public:
enum ShadowMode {
SHADOW_ORTHOGONAL,
- SHADOW_PERSPECTIVE,
SHADOW_PARALLEL_2_SPLITS,
SHADOW_PARALLEL_4_SPLITS
};
- enum ShadowParam {
- SHADOW_PARAM_MAX_DISTANCE,
- SHADOW_PARAM_PSSM_SPLIT_WEIGHT,
- SHADOW_PARAM_PSSM_ZOFFSET_SCALE
- };
private:
+
+ bool blend_splits;
ShadowMode shadow_mode;
- float shadow_param[3];
+
protected:
static void _bind_methods();
public:
@@ -182,33 +152,54 @@ public:
void set_shadow_mode(ShadowMode p_mode);
ShadowMode get_shadow_mode() const;
- void set_shadow_max_distance(float p_distance);
- float get_shadow_max_distance() const;
- void set_shadow_param(ShadowParam p_param, float p_value);
- float get_shadow_param(ShadowParam p_param) const;
+ void set_blend_splits(bool p_enable);
+ bool is_blend_splits_enabled() const;
DirectionalLight();
};
-VARIANT_ENUM_CAST( DirectionalLight::ShadowMode );
-VARIANT_ENUM_CAST( DirectionalLight::ShadowParam );
-
+VARIANT_ENUM_CAST(DirectionalLight::ShadowMode)
class OmniLight : public Light {
- OBJ_TYPE( OmniLight, Light );
+ GDCLASS( OmniLight, Light );
+public:
+ // omni light
+ enum ShadowMode {
+ SHADOW_DUAL_PARABOLOID,
+ SHADOW_CUBE,
+ };
+
+ // omni light
+ enum ShadowDetail {
+ SHADOW_DETAIL_VERTICAL,
+ SHADOW_DETAIL_HORIZONTAL
+ };
+
+private:
+
+ ShadowMode shadow_mode;
+ ShadowDetail shadow_detail;
protected:
static void _bind_methods();
public:
+ void set_shadow_mode(ShadowMode p_mode);
+ ShadowMode get_shadow_mode() const;
- OmniLight() : Light( VisualServer::LIGHT_OMNI ) { set_parameter(PARAM_SHADOW_Z_OFFSET,0.001);}
+ void set_shadow_detail(ShadowDetail p_detail);
+ ShadowDetail get_shadow_detail() const;
+
+ OmniLight();
};
+VARIANT_ENUM_CAST(OmniLight::ShadowMode)
+VARIANT_ENUM_CAST(OmniLight::ShadowDetail)
+
class SpotLight : public Light {
- OBJ_TYPE( SpotLight, Light );
+ GDCLASS( SpotLight, Light );
protected:
static void _bind_methods();
public:
diff --git a/scene/3d/listener.cpp b/scene/3d/listener.cpp
index bf42a5c92e..0aa1128bdb 100644
--- a/scene/3d/listener.cpp
+++ b/scene/3d/listener.cpp
@@ -146,16 +146,17 @@ RES Listener::_get_gizmo_geometry() const {
void Listener::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("make_current"),&Listener::make_current );
- ObjectTypeDB::bind_method( _MD("clear_current"),&Listener::clear_current );
- ObjectTypeDB::bind_method( _MD("is_current"),&Listener::is_current );
- ObjectTypeDB::bind_method( _MD("get_listener_transform"),&Listener::get_listener_transform );
+ ClassDB::bind_method( _MD("make_current"),&Listener::make_current );
+ ClassDB::bind_method( _MD("clear_current"),&Listener::clear_current );
+ ClassDB::bind_method( _MD("is_current"),&Listener::is_current );
+ ClassDB::bind_method( _MD("get_listener_transform"),&Listener::get_listener_transform );
}
Listener::Listener() {
current=false;
force_change=false;
+ set_notify_transform(true);
//active=false;
}
diff --git a/scene/3d/listener.h b/scene/3d/listener.h
index bf0281a8e0..be1b793716 100644
--- a/scene/3d/listener.h
+++ b/scene/3d/listener.h
@@ -7,7 +7,7 @@
class Listener : public Spatial {
- OBJ_TYPE(Listener, Spatial);
+ GDCLASS(Listener, Spatial);
private:
bool force_change;
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index ef956e8ad9..764aff1c08 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,10 +42,10 @@ bool MeshInstance::_set(const StringName& p_name, const Variant& p_value) {
return false;
- Map<StringName,MorphTrack>::Element *E = morph_tracks.find(p_name);
+ Map<StringName,BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
E->get().value=p_value;
- VisualServer::get_singleton()->instance_set_morph_target_weight(get_instance(),E->get().idx,E->get().value);
+ VisualServer::get_singleton()->instance_set_blend_shape_weight(get_instance(),E->get().idx,E->get().value);
return true;
}
@@ -67,7 +67,7 @@ bool MeshInstance::_get(const StringName& p_name,Variant &r_ret) const {
if (!get_instance().is_valid())
return false;
- const Map<StringName,MorphTrack>::Element *E = morph_tracks.find(p_name);
+ const Map<StringName,BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
r_ret = E->get().value;
return true;
@@ -86,7 +86,7 @@ bool MeshInstance::_get(const StringName& p_name,Variant &r_ret) const {
void MeshInstance::_get_property_list( List<PropertyInfo> *p_list) const {
List<String> ls;
- for(const Map<StringName,MorphTrack>::Element *E=morph_tracks.front();E;E=E->next()) {
+ for(const Map<StringName,BlendShapeTrack>::Element *E=blend_shape_tracks.front();E;E=E->next()) {
ls.push_back(E->key());
}
@@ -119,16 +119,16 @@ void MeshInstance::set_mesh(const Ref<Mesh>& p_mesh) {
mesh=p_mesh;
- morph_tracks.clear();
+ blend_shape_tracks.clear();
if (mesh.is_valid()) {
- for(int i=0;i<mesh->get_morph_target_count();i++) {
+ for(int i=0;i<mesh->get_blend_shape_count();i++) {
- MorphTrack mt;
+ BlendShapeTrack mt;
mt.idx=i;
mt.value=0;
- morph_tracks["morph/"+String(mesh->get_morph_target_name(i))]=mt;
+ blend_shape_tracks["blend_shapes/"+String(mesh->get_blend_shape_name(i))]=mt;
}
mesh->connect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_mesh_changed);
@@ -169,21 +169,21 @@ NodePath MeshInstance::get_skeleton_path() {
return skeleton_path;
}
-AABB MeshInstance::get_aabb() const {
+Rect3 MeshInstance::get_aabb() const {
if (!mesh.is_null())
return mesh->get_aabb();
- return AABB();
+ return Rect3();
}
-DVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
if (!(p_usage_flags&(FACES_SOLID|FACES_ENCLOSING)))
- return DVector<Face3>();
+ return PoolVector<Face3>();
if (mesh.is_null())
- return DVector<Face3>();
+ return PoolVector<Face3>();
return mesh->get_faces();
}
@@ -294,18 +294,19 @@ void MeshInstance::_mesh_changed() {
void MeshInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MeshInstance::set_mesh);
- ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MeshInstance::get_mesh);
- ObjectTypeDB::bind_method(_MD("set_skeleton_path","skeleton_path:NodePath"),&MeshInstance::set_skeleton_path);
- ObjectTypeDB::bind_method(_MD("get_skeleton_path:NodePath"),&MeshInstance::get_skeleton_path);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&MeshInstance::get_aabb);
- ObjectTypeDB::bind_method(_MD("create_trimesh_collision"),&MeshInstance::create_trimesh_collision);
- ObjectTypeDB::set_method_flags("MeshInstance","create_trimesh_collision",METHOD_FLAGS_DEFAULT);
- ObjectTypeDB::bind_method(_MD("create_convex_collision"),&MeshInstance::create_convex_collision);
- ObjectTypeDB::set_method_flags("MeshInstance","create_convex_collision",METHOD_FLAGS_DEFAULT);
- ObjectTypeDB::bind_method(_MD("_mesh_changed"),&MeshInstance::_mesh_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "mesh/mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh" ), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY( PropertyInfo (Variant::NODE_PATH, "mesh/skeleton"), _SCS("set_skeleton_path"), _SCS("get_skeleton_path"));
+ ClassDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MeshInstance::set_mesh);
+ ClassDB::bind_method(_MD("get_mesh:Mesh"),&MeshInstance::get_mesh);
+ ClassDB::bind_method(_MD("set_skeleton_path","skeleton_path:NodePath"),&MeshInstance::set_skeleton_path);
+ ClassDB::bind_method(_MD("get_skeleton_path:NodePath"),&MeshInstance::get_skeleton_path);
+
+ ClassDB::bind_method(_MD("create_trimesh_collision"),&MeshInstance::create_trimesh_collision);
+ ClassDB::set_method_flags("MeshInstance","create_trimesh_collision",METHOD_FLAGS_DEFAULT);
+ ClassDB::bind_method(_MD("create_convex_collision"),&MeshInstance::create_convex_collision);
+ ClassDB::set_method_flags("MeshInstance","create_convex_collision",METHOD_FLAGS_DEFAULT);
+ ClassDB::bind_method(_MD("_mesh_changed"),&MeshInstance::_mesh_changed);
+
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh" ), _SCS("set_mesh"), _SCS("get_mesh"));
+ ADD_PROPERTY( PropertyInfo (Variant::NODE_PATH, "skeleton"), _SCS("set_skeleton_path"), _SCS("get_skeleton_path"));
}
MeshInstance::MeshInstance()
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index fd8faf38b4..2d1af46980 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,19 +37,19 @@
*/
class MeshInstance : public GeometryInstance {
- OBJ_TYPE( MeshInstance, GeometryInstance );
+ GDCLASS( MeshInstance, GeometryInstance );
Ref<Mesh> mesh;
NodePath skeleton_path;
- struct MorphTrack {
+ struct BlendShapeTrack {
int idx;
float value;
- MorphTrack() { idx=0; value=0; }
+ BlendShapeTrack() { idx=0; value=0; }
};
- Map<StringName,MorphTrack> morph_tracks;
+ Map<StringName,BlendShapeTrack> blend_shape_tracks;
Vector<Ref<Material> > materials;
void _mesh_changed();
@@ -80,8 +80,8 @@ public:
Node* create_convex_collision_node();
void create_convex_collision();
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
MeshInstance();
~MeshInstance();
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index 0e97a97943..31843fadaa 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,8 +34,8 @@
void MultiMeshInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_multimesh","multimesh"),&MultiMeshInstance::set_multimesh);
- ObjectTypeDB::bind_method(_MD("get_multimesh"),&MultiMeshInstance::get_multimesh);
+ ClassDB::bind_method(_MD("set_multimesh","multimesh"),&MultiMeshInstance::set_multimesh);
+ ClassDB::bind_method(_MD("get_multimesh"),&MultiMeshInstance::get_multimesh);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"multimesh",PROPERTY_HINT_RESOURCE_TYPE,"MultiMesh"), _SCS("set_multimesh"), _SCS("get_multimesh"));
@@ -58,15 +58,15 @@ Ref<MultiMesh> MultiMeshInstance::get_multimesh() const {
-DVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+ return PoolVector<Face3>();
}
-AABB MultiMeshInstance::get_aabb() const {
+Rect3 MultiMeshInstance::get_aabb() const {
if (multimesh.is_null())
- return AABB();
+ return Rect3();
else
return multimesh->get_aabb();
}
diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h
index 7cd9a8ea82..535e4275a3 100644
--- a/scene/3d/multimesh_instance.h
+++ b/scene/3d/multimesh_instance.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class MultiMeshInstance : public GeometryInstance {
- OBJ_TYPE( MultiMeshInstance, GeometryInstance );
+ GDCLASS( MultiMeshInstance, GeometryInstance );
Ref<MultiMesh> multimesh;
@@ -49,12 +49,12 @@ protected:
public:
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_multimesh(const Ref<MultiMesh>& p_multimesh);
Ref<MultiMesh> get_multimesh() const;
- virtual AABB get_aabb() const;
+ virtual Rect3 get_aabb() const;
MultiMeshInstance();
~MultiMeshInstance();
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index 74f83b67da..9bb19880bf 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,12 +36,12 @@ void Navigation::_navmesh_link(int p_id) {
print_line("LINK");
- DVector<Vector3> vertices=nm.navmesh->get_vertices();
+ PoolVector<Vector3> vertices=nm.navmesh->get_vertices();
int len = vertices.size();
if (len==0)
return;
- DVector<Vector3>::Read r=vertices.read();
+ PoolVector<Vector3>::Read r=vertices.read();
for(int i=0;i<nm.navmesh->get_polygon_count();i++) {
@@ -368,7 +368,7 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector
while(!found_route) {
if (open_list.size()==0) {
- // print_line("NOU OPEN LIST");
+ //print_line("NOU OPEN LIST");
break;
}
//check open list
@@ -730,18 +730,18 @@ Vector3 Navigation::get_up_vector() const{
void Navigation::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("navmesh_create","mesh:NavigationMesh","xform","owner"),&Navigation::navmesh_create,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("navmesh_set_transform","id","xform"),&Navigation::navmesh_set_transform);
- ObjectTypeDB::bind_method(_MD("navmesh_remove","id"),&Navigation::navmesh_remove);
+ ClassDB::bind_method(_MD("navmesh_create","mesh:NavigationMesh","xform","owner"),&Navigation::navmesh_create,DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("navmesh_set_transform","id","xform"),&Navigation::navmesh_set_transform);
+ ClassDB::bind_method(_MD("navmesh_remove","id"),&Navigation::navmesh_remove);
- ObjectTypeDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation::get_simple_path,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("get_closest_point_to_segment","start","end","use_collision"),&Navigation::get_closest_point_to_segment,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_closest_point","to_point"),&Navigation::get_closest_point);
- ObjectTypeDB::bind_method(_MD("get_closest_point_normal","to_point"),&Navigation::get_closest_point_normal);
- ObjectTypeDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation::get_closest_point_owner);
+ ClassDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation::get_simple_path,DEFVAL(true));
+ ClassDB::bind_method(_MD("get_closest_point_to_segment","start","end","use_collision"),&Navigation::get_closest_point_to_segment,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_closest_point","to_point"),&Navigation::get_closest_point);
+ ClassDB::bind_method(_MD("get_closest_point_normal","to_point"),&Navigation::get_closest_point_normal);
+ ClassDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation::get_closest_point_owner);
- ObjectTypeDB::bind_method(_MD("set_up_vector","up"),&Navigation::set_up_vector);
- ObjectTypeDB::bind_method(_MD("get_up_vector"),&Navigation::get_up_vector);
+ ClassDB::bind_method(_MD("set_up_vector","up"),&Navigation::set_up_vector);
+ ClassDB::bind_method(_MD("get_up_vector"),&Navigation::get_up_vector);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"up_vector"),_SCS("set_up_vector"),_SCS("get_up_vector"));
}
diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h
index 1cfc416fc9..771e12466a 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Navigation : public Spatial {
- OBJ_TYPE( Navigation, Spatial);
+ GDCLASS( Navigation, Spatial);
union Point {
diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp
index 386a0fab57..4018045390 100644
--- a/scene/3d/navigation_mesh.cpp
+++ b/scene/3d/navigation_mesh.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
void NavigationMesh::create_from_mesh(const Ref<Mesh>& p_mesh) {
- vertices=DVector<Vector3>();
+ vertices=PoolVector<Vector3>();
clear_polygons();
for(int i=0;i<p_mesh->get_surface_count();i++) {
@@ -41,15 +41,15 @@ void NavigationMesh::create_from_mesh(const Ref<Mesh>& p_mesh) {
if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
continue;
Array arr = p_mesh->surface_get_arrays(i);
- DVector<Vector3> varr = arr[Mesh::ARRAY_VERTEX];
- DVector<int> iarr = arr[Mesh::ARRAY_INDEX];
+ PoolVector<Vector3> varr = arr[Mesh::ARRAY_VERTEX];
+ PoolVector<int> iarr = arr[Mesh::ARRAY_INDEX];
if (varr.size()==0 || iarr.size()==0)
continue;
int from = vertices.size();
vertices.append_array(varr);
int rlen = iarr.size();
- DVector<int>::Read r = iarr.read();
+ PoolVector<int>::Read r = iarr.read();
for(int j=0;j<rlen;j+=3) {
Vector<int> vi;
@@ -63,12 +63,12 @@ void NavigationMesh::create_from_mesh(const Ref<Mesh>& p_mesh) {
}
}
-void NavigationMesh::set_vertices(const DVector<Vector3>& p_vertices) {
+void NavigationMesh::set_vertices(const PoolVector<Vector3>& p_vertices) {
vertices=p_vertices;
}
-DVector<Vector3> NavigationMesh::get_vertices() const{
+PoolVector<Vector3> NavigationMesh::get_vertices() const{
return vertices;
}
@@ -122,8 +122,8 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
- DVector<Vector3> vertices = get_vertices();
- DVector<Vector3>::Read vr=vertices.read();
+ PoolVector<Vector3> vertices = get_vertices();
+ PoolVector<Vector3>::Read vr=vertices.read();
List<Face3> faces;
for(int i=0;i<get_polygon_count();i++) {
Vector<int> p = get_polygon(i);
@@ -140,11 +140,11 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
Map<_EdgeKey,bool> edge_map;
- DVector<Vector3> tmeshfaces;
+ PoolVector<Vector3> tmeshfaces;
tmeshfaces.resize(faces.size()*3);
{
- DVector<Vector3>::Write tw=tmeshfaces.write();
+ PoolVector<Vector3>::Write tw=tmeshfaces.write();
int tidx=0;
@@ -185,10 +185,10 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
}
}
- DVector<Vector3> varr;
+ PoolVector<Vector3> varr;
varr.resize(lines.size());
{
- DVector<Vector3>::Write w = varr.write();
+ PoolVector<Vector3>::Write w = varr.write();
int idx=0;
for(List<Vector3>::Element *E=lines.front();E;E=E->next()) {
w[idx++]=E->get();
@@ -201,25 +201,25 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
arr.resize(Mesh::ARRAY_MAX);
arr[Mesh::ARRAY_VERTEX]=varr;
- debug_mesh->add_surface(Mesh::PRIMITIVE_LINES,arr);
+ debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,arr);
return debug_mesh;
}
void NavigationMesh::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_vertices","vertices"),&NavigationMesh::set_vertices);
- ObjectTypeDB::bind_method(_MD("get_vertices"),&NavigationMesh::get_vertices);
+ ClassDB::bind_method(_MD("set_vertices","vertices"),&NavigationMesh::set_vertices);
+ ClassDB::bind_method(_MD("get_vertices"),&NavigationMesh::get_vertices);
- ObjectTypeDB::bind_method(_MD("add_polygon","polygon"),&NavigationMesh::add_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon_count"),&NavigationMesh::get_polygon_count);
- ObjectTypeDB::bind_method(_MD("get_polygon","idx"),&NavigationMesh::get_polygon);
- ObjectTypeDB::bind_method(_MD("clear_polygons"),&NavigationMesh::clear_polygons);
+ ClassDB::bind_method(_MD("add_polygon","polygon"),&NavigationMesh::add_polygon);
+ ClassDB::bind_method(_MD("get_polygon_count"),&NavigationMesh::get_polygon_count);
+ ClassDB::bind_method(_MD("get_polygon","idx"),&NavigationMesh::get_polygon);
+ ClassDB::bind_method(_MD("clear_polygons"),&NavigationMesh::clear_polygons);
- ObjectTypeDB::bind_method(_MD("_set_polygons","polygons"),&NavigationMesh::_set_polygons);
- ObjectTypeDB::bind_method(_MD("_get_polygons"),&NavigationMesh::_get_polygons);
+ ClassDB::bind_method(_MD("_set_polygons","polygons"),&NavigationMesh::_set_polygons);
+ ClassDB::bind_method(_MD("_get_polygons"),&NavigationMesh::_get_polygons);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons"));
}
@@ -356,6 +356,11 @@ void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh>& p_na
if (navigation && navmesh.is_valid() && enabled) {
nav_id = navigation->navmesh_create(navmesh,get_relative_transform(navigation),this);
}
+
+ if (debug_view && navmesh.is_valid()) {
+ debug_view->cast_to<MeshInstance>()->set_mesh( navmesh->get_debug_mesh() );
+ }
+
update_gizmo();
update_configuration_warning();
@@ -368,7 +373,7 @@ Ref<NavigationMesh> NavigationMeshInstance::get_navigation_mesh() const{
String NavigationMeshInstance::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!navmesh.is_valid()) {
@@ -389,11 +394,11 @@ String NavigationMeshInstance::get_configuration_warning() const {
void NavigationMeshInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_navigation_mesh","navmesh"),&NavigationMeshInstance::set_navigation_mesh);
- ObjectTypeDB::bind_method(_MD("get_navigation_mesh"),&NavigationMeshInstance::get_navigation_mesh);
+ ClassDB::bind_method(_MD("set_navigation_mesh","navmesh"),&NavigationMeshInstance::set_navigation_mesh);
+ ClassDB::bind_method(_MD("get_navigation_mesh"),&NavigationMeshInstance::get_navigation_mesh);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&NavigationMeshInstance::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&NavigationMeshInstance::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enabled"),&NavigationMeshInstance::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&NavigationMeshInstance::is_enabled);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navmesh",PROPERTY_HINT_RESOURCE_TYPE,"NavigationMesh"),_SCS("set_navigation_mesh"),_SCS("get_navigation_mesh"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
@@ -405,5 +410,6 @@ NavigationMeshInstance::NavigationMeshInstance() {
navigation=NULL;
nav_id=-1;
enabled=true;
+ set_notify_transform(true);
}
diff --git a/scene/3d/navigation_mesh.h b/scene/3d/navigation_mesh.h
index c49965cd85..e025b7ce8b 100644
--- a/scene/3d/navigation_mesh.h
+++ b/scene/3d/navigation_mesh.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,9 +36,9 @@ class Mesh;
class NavigationMesh : public Resource {
- OBJ_TYPE( NavigationMesh, Resource );
+ GDCLASS( NavigationMesh, Resource );
- DVector<Vector3> vertices;
+ PoolVector<Vector3> vertices;
struct Polygon {
Vector<int> indices;
};
@@ -65,8 +65,8 @@ public:
void create_from_mesh(const Ref<Mesh>& p_mesh);
- void set_vertices(const DVector<Vector3>& p_vertices);
- DVector<Vector3> get_vertices() const;
+ void set_vertices(const PoolVector<Vector3>& p_vertices);
+ PoolVector<Vector3> get_vertices() const;
void add_polygon(const Vector<int>& p_polygon);
int get_polygon_count() const;
@@ -83,7 +83,7 @@ class Navigation;
class NavigationMeshInstance : public Spatial {
- OBJ_TYPE(NavigationMeshInstance,Spatial);
+ GDCLASS(NavigationMeshInstance,Spatial);
bool enabled;
int nav_id;
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 3ac5d8ed7b..72fab4cccc 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,6 +30,7 @@
#include "servers/visual_server.h"
#include "scene/resources/surface_tool.h"
+#if 0
/*
static const char* _var_names[Particles::VAR_MAX]={
"vars/lifetime",
@@ -87,9 +88,9 @@ AABB Particles::get_aabb() const {
return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
}
-DVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+ return PoolVector<Face3>();
}
@@ -129,16 +130,16 @@ AABB Particles::get_visibility_aabb() const {
}
-void Particles::set_emission_points(const DVector<Vector3>& p_points) {
+void Particles::set_emission_points(const PoolVector<Vector3>& p_points) {
using_points = p_points.size();
VisualServer::get_singleton()->particles_set_emission_points(particles,p_points);
}
-DVector<Vector3> Particles::get_emission_points() const {
+PoolVector<Vector3> Particles::get_emission_points() const {
if (!using_points)
- return DVector<Vector3>();
+ return PoolVector<Vector3>();
return VisualServer::get_singleton()->particles_get_emission_points(particles);
@@ -318,13 +319,13 @@ RES Particles::_get_gizmo_geometry() const {
Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<FixedSpatialMaterial> mat( memnew( FixedSpatialMaterial ));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.0,0.6,0.7,0.2) );
- mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
+ mat->set_parameter( FixedSpatialMaterial::PARAM_DIFFUSE,Color(0.0,0.6,0.7,0.2) );
+ mat->set_parameter( FixedSpatialMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
mat->set_blend_mode( Material::BLEND_MODE_ADD );
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ //mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
@@ -333,7 +334,7 @@ RES Particles::_get_gizmo_geometry() const {
int sides=16;
int sections=24;
-// float len=1;
+ //float len=1;
float deg=Math::deg2rad(var[VAR_SPREAD]*180);
if (deg==180)
deg=179.5;
@@ -381,9 +382,9 @@ RES Particles::_get_gizmo_geometry() const {
Ref<Mesh> mesh = surface_tool->commit();
- Ref<FixedMaterial> mat_aabb( memnew( FixedMaterial ));
+ Ref<FixedSpatialMaterial> mat_aabb( memnew( FixedSpatialMaterial ));
- mat_aabb->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.8,0.8,0.9,0.7) );
+ mat_aabb->set_parameter( FixedSpatialMaterial::PARAM_DIFFUSE,Color(0.8,0.8,0.9,0.7) );
mat_aabb->set_line_width(3);
mat_aabb->set_flag( Material::FLAG_UNSHADED, true );
@@ -405,39 +406,39 @@ RES Particles::_get_gizmo_geometry() const {
void Particles::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_amount","amount"),&Particles::set_amount);
- ObjectTypeDB::bind_method(_MD("get_amount"),&Particles::get_amount);
- ObjectTypeDB::bind_method(_MD("set_emitting","enabled"),&Particles::set_emitting);
- ObjectTypeDB::bind_method(_MD("is_emitting"),&Particles::is_emitting);
- ObjectTypeDB::bind_method(_MD("set_visibility_aabb","aabb"),&Particles::set_visibility_aabb);
- ObjectTypeDB::bind_method(_MD("get_visibility_aabb"),&Particles::get_visibility_aabb);
- ObjectTypeDB::bind_method(_MD("set_emission_half_extents","half_extents"),&Particles::set_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("get_emission_half_extents"),&Particles::get_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("set_emission_base_velocity","base_velocity"),&Particles::set_emission_base_velocity);
- ObjectTypeDB::bind_method(_MD("get_emission_base_velocity"),&Particles::get_emission_base_velocity);
- ObjectTypeDB::bind_method(_MD("set_emission_points","points"),&Particles::set_emission_points);
- ObjectTypeDB::bind_method(_MD("get_emission_points"),&Particles::get_emission_points);
- ObjectTypeDB::bind_method(_MD("set_gravity_normal","normal"),&Particles::set_gravity_normal);
- ObjectTypeDB::bind_method(_MD("get_gravity_normal"),&Particles::get_gravity_normal);
- ObjectTypeDB::bind_method(_MD("set_variable","variable","value"),&Particles::set_variable);
- ObjectTypeDB::bind_method(_MD("get_variable","variable"),&Particles::get_variable);
- ObjectTypeDB::bind_method(_MD("set_randomness","variable","randomness"),&Particles::set_randomness);
- ObjectTypeDB::bind_method(_MD("get_randomness","variable"),&Particles::get_randomness);
- ObjectTypeDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles::set_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles::get_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles::set_color_phase_color);
- ObjectTypeDB::bind_method(_MD("get_color_phase_color","phase"),&Particles::get_color_phase_color);
- ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&Particles::set_material);
- ObjectTypeDB::bind_method(_MD("get_material:Material"),&Particles::get_material);
- ObjectTypeDB::bind_method(_MD("set_emit_timeout","timeout"),&Particles::set_emit_timeout);
- ObjectTypeDB::bind_method(_MD("get_emit_timeout"),&Particles::get_emit_timeout);
- ObjectTypeDB::bind_method(_MD("set_height_from_velocity","enable"),&Particles::set_height_from_velocity);
- ObjectTypeDB::bind_method(_MD("has_height_from_velocity"),&Particles::has_height_from_velocity);
- ObjectTypeDB::bind_method(_MD("set_use_local_coordinates","enable"),&Particles::set_use_local_coordinates);
- ObjectTypeDB::bind_method(_MD("is_using_local_coordinates"),&Particles::is_using_local_coordinates);
-
- ObjectTypeDB::bind_method(_MD("set_color_phases","count"),&Particles::set_color_phases);
- ObjectTypeDB::bind_method(_MD("get_color_phases"),&Particles::get_color_phases);
+ ClassDB::bind_method(_MD("set_amount","amount"),&Particles::set_amount);
+ ClassDB::bind_method(_MD("get_amount"),&Particles::get_amount);
+ ClassDB::bind_method(_MD("set_emitting","enabled"),&Particles::set_emitting);
+ ClassDB::bind_method(_MD("is_emitting"),&Particles::is_emitting);
+ ClassDB::bind_method(_MD("set_visibility_aabb","aabb"),&Particles::set_visibility_aabb);
+ ClassDB::bind_method(_MD("get_visibility_aabb"),&Particles::get_visibility_aabb);
+ ClassDB::bind_method(_MD("set_emission_half_extents","half_extents"),&Particles::set_emission_half_extents);
+ ClassDB::bind_method(_MD("get_emission_half_extents"),&Particles::get_emission_half_extents);
+ ClassDB::bind_method(_MD("set_emission_base_velocity","base_velocity"),&Particles::set_emission_base_velocity);
+ ClassDB::bind_method(_MD("get_emission_base_velocity"),&Particles::get_emission_base_velocity);
+ ClassDB::bind_method(_MD("set_emission_points","points"),&Particles::set_emission_points);
+ ClassDB::bind_method(_MD("get_emission_points"),&Particles::get_emission_points);
+ ClassDB::bind_method(_MD("set_gravity_normal","normal"),&Particles::set_gravity_normal);
+ ClassDB::bind_method(_MD("get_gravity_normal"),&Particles::get_gravity_normal);
+ ClassDB::bind_method(_MD("set_variable","variable","value"),&Particles::set_variable);
+ ClassDB::bind_method(_MD("get_variable","variable"),&Particles::get_variable);
+ ClassDB::bind_method(_MD("set_randomness","variable","randomness"),&Particles::set_randomness);
+ ClassDB::bind_method(_MD("get_randomness","variable"),&Particles::get_randomness);
+ ClassDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles::set_color_phase_pos);
+ ClassDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles::get_color_phase_pos);
+ ClassDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles::set_color_phase_color);
+ ClassDB::bind_method(_MD("get_color_phase_color","phase"),&Particles::get_color_phase_color);
+ ClassDB::bind_method(_MD("set_material","material:Material"),&Particles::set_material);
+ ClassDB::bind_method(_MD("get_material:Material"),&Particles::get_material);
+ ClassDB::bind_method(_MD("set_emit_timeout","timeout"),&Particles::set_emit_timeout);
+ ClassDB::bind_method(_MD("get_emit_timeout"),&Particles::get_emit_timeout);
+ ClassDB::bind_method(_MD("set_height_from_velocity","enable"),&Particles::set_height_from_velocity);
+ ClassDB::bind_method(_MD("has_height_from_velocity"),&Particles::has_height_from_velocity);
+ ClassDB::bind_method(_MD("set_use_local_coordinates","enable"),&Particles::set_use_local_coordinates);
+ ClassDB::bind_method(_MD("is_using_local_coordinates"),&Particles::is_using_local_coordinates);
+
+ ClassDB::bind_method(_MD("set_color_phases","count"),&Particles::set_color_phases);
+ ClassDB::bind_method(_MD("get_color_phases"),&Particles::get_color_phases);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material" ), _SCS("set_material"), _SCS("get_material") );
@@ -557,3 +558,4 @@ Particles::~Particles() {
VisualServer::get_singleton()->free(particles);
}
+#endif
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 42d27c41d7..b96bd4e69e 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
+#if 0
class Particles : public GeometryInstance {
public:
@@ -60,7 +60,7 @@ public:
};
private:
- OBJ_TYPE( Particles, GeometryInstance );
+ GDCLASS( Particles, GeometryInstance );
RID particles;
@@ -103,7 +103,7 @@ public:
AABB get_aabb() const;
- DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_amount(int p_amount);
int get_amount() const;
@@ -120,8 +120,8 @@ public:
void set_emission_base_velocity(const Vector3& p_base_velocity);
Vector3 get_emission_base_velocity() const;
- void set_emission_points(const DVector<Vector3>& p_points);
- DVector<Vector3> get_emission_points() const;
+ void set_emission_points(const PoolVector<Vector3>& p_points);
+ PoolVector<Vector3> get_emission_points() const;
void set_gravity_normal(const Vector3& p_normal);
Vector3 get_gravity_normal() const;
@@ -163,3 +163,4 @@ public:
VARIANT_ENUM_CAST( Particles::Variable );
#endif
+#endif
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index d6cd3da7c3..5e8ded3867 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -80,9 +80,9 @@ Ref<Curve3D> Path::get_curve() const{
void Path::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve3D"),&Path::set_curve);
- ObjectTypeDB::bind_method(_MD("get_curve:Curve3D","curve"),&Path::get_curve);
- ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path::_curve_changed);
+ ClassDB::bind_method(_MD("set_curve","curve:Curve3D"),&Path::set_curve);
+ ClassDB::bind_method(_MD("get_curve:Curve3D","curve"),&Path::get_curve);
+ ClassDB::bind_method(_MD("_curve_changed"),&Path::_curve_changed);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), _SCS("set_curve"),_SCS("get_curve"));
}
@@ -137,7 +137,7 @@ void PathFollow::_update_transform() {
float tilt = c->interpolate_baked_tilt(o);
if (tilt!=0) {
- Matrix3 rot(-n,tilt); //remember.. lookat will be znegative.. znegative!! we abide by opengl clan.
+ Basis rot(-n,tilt); //remember.. lookat will be znegative.. znegative!! we abide by opengl clan.
up=rot.xform(up);
}
}
@@ -257,26 +257,26 @@ void PathFollow::_get_property_list( List<PropertyInfo> *p_list) const{
void PathFollow::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&PathFollow::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&PathFollow::get_offset);
- ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow::set_h_offset);
- ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow::get_h_offset);
+ ClassDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow::set_h_offset);
+ ClassDB::bind_method(_MD("get_h_offset"),&PathFollow::get_h_offset);
- ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow::set_v_offset);
- ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow::get_v_offset);
+ ClassDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow::set_v_offset);
+ ClassDB::bind_method(_MD("get_v_offset"),&PathFollow::get_v_offset);
- ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset);
- ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow::get_unit_offset);
+ ClassDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset);
+ ClassDB::bind_method(_MD("get_unit_offset"),&PathFollow::get_unit_offset);
- ObjectTypeDB::bind_method(_MD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode);
- ObjectTypeDB::bind_method(_MD("get_rotation_mode"),&PathFollow::get_rotation_mode);
+ ClassDB::bind_method(_MD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode);
+ ClassDB::bind_method(_MD("get_rotation_mode"),&PathFollow::get_rotation_mode);
- ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation);
- ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation);
+ ClassDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation);
+ ClassDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation);
- ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow::has_loop);
+ ClassDB::bind_method(_MD("set_loop","loop"),&PathFollow::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&PathFollow::has_loop);
BIND_CONSTANT( ROTATION_NONE );
BIND_CONSTANT( ROTATION_Y );
diff --git a/scene/3d/path.h b/scene/3d/path.h
index 2e3573df3e..ab6f459ba9 100644
--- a/scene/3d/path.h
+++ b/scene/3d/path.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Path : public Spatial {
- OBJ_TYPE( Path, Spatial );
+ GDCLASS( Path, Spatial );
Ref<Curve3D> curve;
@@ -56,7 +56,7 @@ public:
class PathFollow : public Spatial {
- OBJ_TYPE(PathFollow,Spatial);
+ GDCLASS(PathFollow,Spatial);
public:
enum RotationMode {
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 116f967bd2..0a44ad9c3d 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -58,13 +58,13 @@ float PhysicsBody::get_inverse_mass() const {
}
-void PhysicsBody::set_layer_mask(uint32_t p_mask) {
+void PhysicsBody::set_collision_layer(uint32_t p_mask) {
layer_mask=p_mask;
PhysicsServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask);
}
-uint32_t PhysicsBody::get_layer_mask() const {
+uint32_t PhysicsBody::get_collision_layer() const {
return layer_mask;
}
@@ -97,20 +97,20 @@ bool PhysicsBody::get_collision_mask_bit(int p_bit) const{
}
-void PhysicsBody::set_layer_mask_bit(int p_bit, bool p_value) {
+void PhysicsBody::set_collision_layer_bit(int p_bit, bool p_value) {
- uint32_t mask = get_layer_mask();
+ uint32_t mask = get_collision_layer();
if (p_value)
mask|=1<<p_bit;
else
mask&=~(1<<p_bit);
- set_layer_mask(mask);
+ set_collision_layer(mask);
}
-bool PhysicsBody::get_layer_mask_bit(int p_bit) const{
+bool PhysicsBody::get_collision_layer_bit(int p_bit) const{
- return get_layer_mask()&(1<<p_bit);
+ return get_collision_layer()&(1<<p_bit);
}
void PhysicsBody::add_collision_exception_with(Node* p_node) {
@@ -137,34 +137,34 @@ void PhysicsBody::remove_collision_exception_with(Node* p_node) {
}
void PhysicsBody::_set_layers(uint32_t p_mask) {
- set_layer_mask(p_mask);
+ set_collision_layer(p_mask);
set_collision_mask(p_mask);
}
uint32_t PhysicsBody::_get_layers() const{
- return get_layer_mask();
+ return get_collision_layer();
}
void PhysicsBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody::get_layer_mask);
+ ClassDB::bind_method(_MD("set_collision_layer","layer"),&PhysicsBody::set_collision_layer);
+ ClassDB::bind_method(_MD("get_collision_layer"),&PhysicsBody::get_collision_layer);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody::get_collision_mask);
+ ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody::set_collision_mask);
+ ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody::get_collision_mask_bit);
+ ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody::set_collision_mask_bit);
+ ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody::get_layer_mask_bit);
+ ClassDB::bind_method(_MD("set_collision_layer_bit","bit","value"),&PhysicsBody::set_collision_layer_bit);
+ ClassDB::bind_method(_MD("get_collision_layer_bit","bit"),&PhysicsBody::get_collision_layer_bit);
- ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody::_set_layers);
- ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody::_get_layers);
+ ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody::_set_layers);
+ ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody::_get_layers);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_GROUP("Collision","collision_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layer",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
}
@@ -230,19 +230,19 @@ Vector3 StaticBody::get_constant_angular_velocity() const {
void StaticBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody::set_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody::set_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody::get_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody::get_constant_angular_velocity);
+ ClassDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody::set_constant_linear_velocity);
+ ClassDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody::set_constant_angular_velocity);
+ ClassDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody::get_constant_linear_velocity);
+ ClassDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody::get_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&StaticBody::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&StaticBody::get_friction);
+ ClassDB::bind_method(_MD("set_friction","friction"),&StaticBody::set_friction);
+ ClassDB::bind_method(_MD("get_friction"),&StaticBody::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&StaticBody::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&StaticBody::get_bounce);
+ ClassDB::bind_method(_MD("set_bounce","bounce"),&StaticBody::set_bounce);
+ ClassDB::bind_method(_MD("get_bounce"),&StaticBody::get_bounce);
- ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody"),&PhysicsBody::add_collision_exception_with);
- ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody"),&PhysicsBody::remove_collision_exception_with);
+ ClassDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody"),&PhysicsBody::add_collision_exception_with);
+ ClassDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody"),&PhysicsBody::remove_collision_exception_with);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
@@ -279,11 +279,11 @@ void RigidBody::_body_enter_tree(ObjectID p_id) {
contact_monitor->locked=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
}
contact_monitor->locked=false;
@@ -303,11 +303,11 @@ void RigidBody::_body_exit_tree(ObjectID p_id) {
contact_monitor->locked=true;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,node);
for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
}
contact_monitor->locked=false;
@@ -333,10 +333,10 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
//E->get().rc=0;
E->get().in_tree=node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_entered,node);
}
}
@@ -347,7 +347,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_entered,objid,node,p_body_shape,p_local_shape);
}
} else {
@@ -362,17 +362,17 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
if (E->get().shapes.empty()) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree);
if (in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exited,obj);
}
contact_monitor->body_map.erase(E);
}
if (node && in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_shape_exited,objid,obj,p_body_shape,p_local_shape);
}
}
@@ -437,7 +437,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
-// bool found=false;
+ //bool found=false;
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
if (!E) {
@@ -800,66 +800,66 @@ Array RigidBody::get_colliding_bodies() const {
void RigidBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&RigidBody::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&RigidBody::get_mode);
+ ClassDB::bind_method(_MD("set_mode","mode"),&RigidBody::set_mode);
+ ClassDB::bind_method(_MD("get_mode"),&RigidBody::get_mode);
- ObjectTypeDB::bind_method(_MD("set_mass","mass"),&RigidBody::set_mass);
- ObjectTypeDB::bind_method(_MD("get_mass"),&RigidBody::get_mass);
+ ClassDB::bind_method(_MD("set_mass","mass"),&RigidBody::set_mass);
+ ClassDB::bind_method(_MD("get_mass"),&RigidBody::get_mass);
- ObjectTypeDB::bind_method(_MD("set_weight","weight"),&RigidBody::set_weight);
- ObjectTypeDB::bind_method(_MD("get_weight"),&RigidBody::get_weight);
+ ClassDB::bind_method(_MD("set_weight","weight"),&RigidBody::set_weight);
+ ClassDB::bind_method(_MD("get_weight"),&RigidBody::get_weight);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&RigidBody::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&RigidBody::get_friction);
+ ClassDB::bind_method(_MD("set_friction","friction"),&RigidBody::set_friction);
+ ClassDB::bind_method(_MD("get_friction"),&RigidBody::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&RigidBody::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&RigidBody::get_bounce);
+ ClassDB::bind_method(_MD("set_bounce","bounce"),&RigidBody::set_bounce);
+ ClassDB::bind_method(_MD("get_bounce"),&RigidBody::get_bounce);
- ObjectTypeDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody::set_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&RigidBody::get_linear_velocity);
+ ClassDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody::set_linear_velocity);
+ ClassDB::bind_method(_MD("get_linear_velocity"),&RigidBody::get_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody::set_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&RigidBody::get_angular_velocity);
+ ClassDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody::set_angular_velocity);
+ ClassDB::bind_method(_MD("get_angular_velocity"),&RigidBody::get_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody::set_gravity_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_scale"),&RigidBody::get_gravity_scale);
+ ClassDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody::set_gravity_scale);
+ ClassDB::bind_method(_MD("get_gravity_scale"),&RigidBody::get_gravity_scale);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&RigidBody::get_linear_damp);
+ ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody::set_linear_damp);
+ ClassDB::bind_method(_MD("get_linear_damp"),&RigidBody::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&RigidBody::get_angular_damp);
+ ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody::set_angular_damp);
+ ClassDB::bind_method(_MD("get_angular_damp"),&RigidBody::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody::set_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody::get_max_contacts_reported);
+ ClassDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody::set_max_contacts_reported);
+ ClassDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody::get_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody::set_use_custom_integrator);
- ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody::is_using_custom_integrator);
+ ClassDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody::set_use_custom_integrator);
+ ClassDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody::is_using_custom_integrator);
- ObjectTypeDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody::set_contact_monitor);
- ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody::is_contact_monitor_enabled);
+ ClassDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody::set_contact_monitor);
+ ClassDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody::is_contact_monitor_enabled);
- ObjectTypeDB::bind_method(_MD("set_use_continuous_collision_detection","enable"),&RigidBody::set_use_continuous_collision_detection);
- ObjectTypeDB::bind_method(_MD("is_using_continuous_collision_detection"),&RigidBody::is_using_continuous_collision_detection);
+ ClassDB::bind_method(_MD("set_use_continuous_collision_detection","enable"),&RigidBody::set_use_continuous_collision_detection);
+ ClassDB::bind_method(_MD("is_using_continuous_collision_detection"),&RigidBody::is_using_continuous_collision_detection);
- ObjectTypeDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody::set_axis_velocity);
- ObjectTypeDB::bind_method(_MD("apply_impulse","pos","impulse"),&RigidBody::apply_impulse);
+ ClassDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody::set_axis_velocity);
+ ClassDB::bind_method(_MD("apply_impulse","pos","impulse"),&RigidBody::apply_impulse);
- ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody::set_sleeping);
- ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody::is_sleeping);
+ ClassDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody::set_sleeping);
+ ClassDB::bind_method(_MD("is_sleeping"),&RigidBody::is_sleeping);
- ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody::set_can_sleep);
- ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody::is_able_to_sleep);
+ ClassDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody::set_can_sleep);
+ ClassDB::bind_method(_MD("is_able_to_sleep"),&RigidBody::is_able_to_sleep);
- ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&RigidBody::_direct_state_changed);
- ObjectTypeDB::bind_method(_MD("_body_enter_tree"),&RigidBody::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree"),&RigidBody::_body_exit_tree);
+ ClassDB::bind_method(_MD("_direct_state_changed"),&RigidBody::_direct_state_changed);
+ ClassDB::bind_method(_MD("_body_enter_tree"),&RigidBody::_body_enter_tree);
+ ClassDB::bind_method(_MD("_body_exit_tree"),&RigidBody::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("set_axis_lock","axis_lock"),&RigidBody::set_axis_lock);
- ObjectTypeDB::bind_method(_MD("get_axis_lock"),&RigidBody::get_axis_lock);
+ ClassDB::bind_method(_MD("set_axis_lock","axis_lock"),&RigidBody::set_axis_lock);
+ ClassDB::bind_method(_MD("get_axis_lock"),&RigidBody::get_axis_lock);
- ObjectTypeDB::bind_method(_MD("get_colliding_bodies"),&RigidBody::get_colliding_bodies);
+ ClassDB::bind_method(_MD("get_colliding_bodies"),&RigidBody::get_colliding_bodies);
BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:PhysicsDirectBodyState")));
@@ -876,15 +876,17 @@ void RigidBody::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"axis_lock",PROPERTY_HINT_ENUM,"Disabled,Lock X,Lock Y,Lock Z"),_SCS("set_axis_lock"),_SCS("get_axis_lock"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/linear",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/angular",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
-
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
+ ADD_GROUP("Linear","linear_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"linear_velocity"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
+ ADD_GROUP("Angular","angular_");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"angular_velocity"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+
+ ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
+ ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
+ ADD_SIGNAL( MethodInfo("body_entered",PropertyInfo(Variant::OBJECT,"body")));
+ ADD_SIGNAL( MethodInfo("body_exited",PropertyInfo(Variant::OBJECT,"body")));
ADD_SIGNAL( MethodInfo("sleeping_state_changed"));
BIND_CONSTANT( MODE_STATIC );
@@ -998,7 +1000,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
if (collide_character)
mask|=PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-// print_line("motion: "+p_motion+" margin: "+rtos(margin));
+ //print_line("motion: "+p_motion+" margin: "+rtos(margin));
//print_line("margin: "+rtos(margin));
@@ -1013,7 +1015,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
if (is_shape_set_as_trigger(i))
continue;
- if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),m,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask)) {
+ if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),m,sr,max_shapes,res_shapes,exclude,get_collision_layer(),mask)) {
collided=true;
}
@@ -1036,10 +1038,10 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
#if 0
float d = a.distance_to(b);
- //if (d<margin)
- /// continue;
- ///
- ///
+ /*
+ if (d<margin)
+ continue;
+ */
recover_motion+=(b-a)*0.2;
#else
float dist = a.distance_to(b);
@@ -1095,7 +1097,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
float lsafe,lunsafe;
PhysicsDirectSpaceState::ShapeRestInfo lrest;
- bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion,0, lsafe,lunsafe,exclude,get_layer_mask(),mask,&lrest);
+ bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion,0, lsafe,lunsafe,exclude,get_collision_layer(),mask,&lrest);
//print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
if (!valid) {
safe=0;
@@ -1136,13 +1138,13 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
ugt.origin+=p_motion*unsafe;
PhysicsDirectSpaceState::ShapeRestInfo rest_info;
- bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), m,&rest,exclude,get_layer_mask(),mask);
+ bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), m,&rest,exclude,get_collision_layer(),mask);
if (!c2) {
//should not happen, but floating point precision is so weird..
colliding=false;
}
- // print_line("Rest Travel: "+rest.normal);
+ //print_line("Rest Travel: "+rest.normal);
}
@@ -1157,8 +1159,10 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
}
Vector3 motion=p_motion*safe;
- //if (colliding)
- // motion+=normal*0.001;
+ /*
+ if (colliding)
+ motion+=normal*0.001;
+ */
Transform gt = get_global_transform();
gt.origin+=motion;
set_global_transform(gt);
@@ -1199,7 +1203,7 @@ bool KinematicBody::can_teleport_to(const Vector3& p_position) {
if (is_shape_set_as_trigger(i))
continue;
- bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,1,exclude,get_layer_mask(),mask);
+ bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,1,exclude,get_collision_layer(),mask);
if (col)
return false;
}
@@ -1294,34 +1298,34 @@ float KinematicBody::get_collision_margin() const{
void KinematicBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("move","rel_vec"),&KinematicBody::move);
- ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody::move_to);
+ ClassDB::bind_method(_MD("move","rel_vec"),&KinematicBody::move);
+ ClassDB::bind_method(_MD("move_to","position"),&KinematicBody::move_to);
- ObjectTypeDB::bind_method(_MD("can_teleport_to","position"),&KinematicBody::can_teleport_to);
+ ClassDB::bind_method(_MD("can_teleport_to","position"),&KinematicBody::can_teleport_to);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody::is_colliding);
+ ClassDB::bind_method(_MD("is_colliding"),&KinematicBody::is_colliding);
- ObjectTypeDB::bind_method(_MD("get_collision_pos"),&KinematicBody::get_collision_pos);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&KinematicBody::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody::get_collider_velocity);
- ObjectTypeDB::bind_method(_MD("get_collider:Object"),&KinematicBody::_get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody::get_collider_shape);
+ ClassDB::bind_method(_MD("get_collision_pos"),&KinematicBody::get_collision_pos);
+ ClassDB::bind_method(_MD("get_collision_normal"),&KinematicBody::get_collision_normal);
+ ClassDB::bind_method(_MD("get_collider_velocity"),&KinematicBody::get_collider_velocity);
+ ClassDB::bind_method(_MD("get_collider:Variant"),&KinematicBody::_get_collider);
+ ClassDB::bind_method(_MD("get_collider_shape"),&KinematicBody::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("set_collide_with_static_bodies","enable"),&KinematicBody::set_collide_with_static_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_static_bodies"),&KinematicBody::can_collide_with_static_bodies);
+ ClassDB::bind_method(_MD("set_collide_with_static_bodies","enable"),&KinematicBody::set_collide_with_static_bodies);
+ ClassDB::bind_method(_MD("can_collide_with_static_bodies"),&KinematicBody::can_collide_with_static_bodies);
- ObjectTypeDB::bind_method(_MD("set_collide_with_kinematic_bodies","enable"),&KinematicBody::set_collide_with_kinematic_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_kinematic_bodies"),&KinematicBody::can_collide_with_kinematic_bodies);
+ ClassDB::bind_method(_MD("set_collide_with_kinematic_bodies","enable"),&KinematicBody::set_collide_with_kinematic_bodies);
+ ClassDB::bind_method(_MD("can_collide_with_kinematic_bodies"),&KinematicBody::can_collide_with_kinematic_bodies);
- ObjectTypeDB::bind_method(_MD("set_collide_with_rigid_bodies","enable"),&KinematicBody::set_collide_with_rigid_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_rigid_bodies"),&KinematicBody::can_collide_with_rigid_bodies);
+ ClassDB::bind_method(_MD("set_collide_with_rigid_bodies","enable"),&KinematicBody::set_collide_with_rigid_bodies);
+ ClassDB::bind_method(_MD("can_collide_with_rigid_bodies"),&KinematicBody::can_collide_with_rigid_bodies);
- ObjectTypeDB::bind_method(_MD("set_collide_with_character_bodies","enable"),&KinematicBody::set_collide_with_character_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_character_bodies"),&KinematicBody::can_collide_with_character_bodies);
+ ClassDB::bind_method(_MD("set_collide_with_character_bodies","enable"),&KinematicBody::set_collide_with_character_bodies);
+ ClassDB::bind_method(_MD("can_collide_with_character_bodies"),&KinematicBody::can_collide_with_character_bodies);
- ObjectTypeDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody::set_collision_margin);
- ObjectTypeDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody::get_collision_margin);
+ ClassDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody::set_collision_margin);
+ ClassDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody::get_collision_margin);
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/static"),_SCS("set_collide_with_static_bodies"),_SCS("can_collide_with_static_bodies"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/kinematic"),_SCS("set_collide_with_kinematic_bodies"),_SCS("can_collide_with_kinematic_bodies"));
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index f95b4f017f..86be98f81e 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
class PhysicsBody : public CollisionObject {
- OBJ_TYPE(PhysicsBody,CollisionObject);
+ GDCLASS(PhysicsBody,CollisionObject);
uint32_t layer_mask;
uint32_t collision_mask;
@@ -55,14 +55,14 @@ public:
virtual Vector3 get_angular_velocity() const;
virtual float get_inverse_mass() const;
- void set_layer_mask(uint32_t p_mask);
- uint32_t get_layer_mask() const;
+ void set_collision_layer(uint32_t p_mask);
+ uint32_t get_collision_layer() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
- void set_layer_mask_bit(int p_bit, bool p_value);
- bool get_layer_mask_bit(int p_bit) const;
+ void set_collision_layer_bit(int p_bit, bool p_value);
+ bool get_collision_layer_bit(int p_bit) const;
void set_collision_mask_bit(int p_bit, bool p_value);
bool get_collision_mask_bit(int p_bit) const;
@@ -78,7 +78,7 @@ public:
class StaticBody : public PhysicsBody {
- OBJ_TYPE(StaticBody,PhysicsBody);
+ GDCLASS(StaticBody,PhysicsBody);
Vector3 constant_linear_velocity;
Vector3 constant_angular_velocity;
@@ -114,7 +114,7 @@ public:
class RigidBody : public PhysicsBody {
- OBJ_TYPE(RigidBody,PhysicsBody);
+ GDCLASS(RigidBody,PhysicsBody);
public:
enum Mode {
@@ -284,7 +284,7 @@ VARIANT_ENUM_CAST(RigidBody::AxisLock);
class KinematicBody : public PhysicsBody {
- OBJ_TYPE(KinematicBody,PhysicsBody);
+ GDCLASS(KinematicBody,PhysicsBody);
float margin;
bool collide_static;
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index 084d96975f..f2668480f5 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -167,17 +167,17 @@ bool Joint::get_exclude_nodes_from_collision() const{
void Joint::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("set_node_a","node"), &Joint::set_node_a );
- ObjectTypeDB::bind_method( _MD("get_node_a"), &Joint::get_node_a );
+ ClassDB::bind_method( _MD("set_node_a","node"), &Joint::set_node_a );
+ ClassDB::bind_method( _MD("get_node_a"), &Joint::get_node_a );
- ObjectTypeDB::bind_method( _MD("set_node_b","node"), &Joint::set_node_b );
- ObjectTypeDB::bind_method( _MD("get_node_b"), &Joint::get_node_b );
+ ClassDB::bind_method( _MD("set_node_b","node"), &Joint::set_node_b );
+ ClassDB::bind_method( _MD("get_node_b"), &Joint::get_node_b );
- ObjectTypeDB::bind_method( _MD("set_solver_priority","priority"), &Joint::set_solver_priority );
- ObjectTypeDB::bind_method( _MD("get_solver_priority"), &Joint::get_solver_priority );
+ ClassDB::bind_method( _MD("set_solver_priority","priority"), &Joint::set_solver_priority );
+ ClassDB::bind_method( _MD("get_solver_priority"), &Joint::get_solver_priority );
- ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision );
- ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision );
+ ClassDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision );
+ ClassDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
@@ -195,6 +195,7 @@ Joint::Joint() {
exclude_from_collision=true;
solver_priority=1;
+ set_notify_transform(true);
}
@@ -202,8 +203,8 @@ Joint::Joint() {
void PinJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&PinJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&PinJoint::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&PinJoint::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&PinJoint::get_param);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/damping",PROPERTY_HINT_RANGE,"0.01,8.0,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_DAMPING );
@@ -291,17 +292,17 @@ float HingeJoint::_get_lower_limit() const {
void HingeJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&HingeJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&HingeJoint::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&HingeJoint::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&HingeJoint::get_param);
- ObjectTypeDB::bind_method(_MD("set_flag","flag","enabled"),&HingeJoint::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"),&HingeJoint::get_flag);
+ ClassDB::bind_method(_MD("set_flag","flag","enabled"),&HingeJoint::set_flag);
+ ClassDB::bind_method(_MD("get_flag","flag"),&HingeJoint::get_flag);
- ObjectTypeDB::bind_method(_MD("_set_upper_limit","upper_limit"),&HingeJoint::_set_upper_limit);
- ObjectTypeDB::bind_method(_MD("_get_upper_limit"),&HingeJoint::_get_upper_limit);
+ ClassDB::bind_method(_MD("_set_upper_limit","upper_limit"),&HingeJoint::_set_upper_limit);
+ ClassDB::bind_method(_MD("_get_upper_limit"),&HingeJoint::_get_upper_limit);
- ObjectTypeDB::bind_method(_MD("_set_lower_limit","lower_limit"),&HingeJoint::_set_lower_limit);
- ObjectTypeDB::bind_method(_MD("_get_lower_limit"),&HingeJoint::_get_lower_limit);
+ ClassDB::bind_method(_MD("_set_lower_limit","lower_limit"),&HingeJoint::_set_lower_limit);
+ ClassDB::bind_method(_MD("_get_lower_limit"),&HingeJoint::_get_lower_limit);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
@@ -446,15 +447,15 @@ float SliderJoint::_get_lower_limit_angular() const {
void SliderJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SliderJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SliderJoint::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&SliderJoint::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&SliderJoint::get_param);
- ObjectTypeDB::bind_method(_MD("_set_upper_limit_angular","upper_limit_angular"),&SliderJoint::_set_upper_limit_angular);
- ObjectTypeDB::bind_method(_MD("_get_upper_limit_angular"),&SliderJoint::_get_upper_limit_angular);
+ ClassDB::bind_method(_MD("_set_upper_limit_angular","upper_limit_angular"),&SliderJoint::_set_upper_limit_angular);
+ ClassDB::bind_method(_MD("_get_upper_limit_angular"),&SliderJoint::_get_upper_limit_angular);
- ObjectTypeDB::bind_method(_MD("_set_lower_limit_angular","lower_limit_angular"),&SliderJoint::_set_lower_limit_angular);
- ObjectTypeDB::bind_method(_MD("_get_lower_limit_angular"),&SliderJoint::_get_lower_limit_angular);
+ ClassDB::bind_method(_MD("_set_lower_limit_angular","lower_limit_angular"),&SliderJoint::_set_lower_limit_angular);
+ ClassDB::bind_method(_MD("_get_lower_limit_angular"),&SliderJoint::_get_lower_limit_angular);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/upper_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_UPPER);
@@ -611,15 +612,15 @@ float ConeTwistJoint::_get_twist_span() const {
void ConeTwistJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&ConeTwistJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&ConeTwistJoint::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&ConeTwistJoint::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&ConeTwistJoint::get_param);
- ObjectTypeDB::bind_method(_MD("_set_swing_span","swing_span"),&ConeTwistJoint::_set_swing_span);
- ObjectTypeDB::bind_method(_MD("_get_swing_span"),&ConeTwistJoint::_get_swing_span);
+ ClassDB::bind_method(_MD("_set_swing_span","swing_span"),&ConeTwistJoint::_set_swing_span);
+ ClassDB::bind_method(_MD("_get_swing_span"),&ConeTwistJoint::_get_swing_span);
- ObjectTypeDB::bind_method(_MD("_set_twist_span","twist_span"),&ConeTwistJoint::_set_twist_span);
- ObjectTypeDB::bind_method(_MD("_get_twist_span"),&ConeTwistJoint::_get_twist_span);
+ ClassDB::bind_method(_MD("_set_twist_span","twist_span"),&ConeTwistJoint::_set_twist_span);
+ ClassDB::bind_method(_MD("_get_twist_span"),&ConeTwistJoint::_get_twist_span);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"swing_span",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_swing_span"),_SCS("_get_swing_span") );
@@ -770,41 +771,41 @@ float Generic6DOFJoint::_get_angular_lo_limit_z() const{
void Generic6DOFJoint::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_x","angle"),&Generic6DOFJoint::_set_angular_hi_limit_x);
- ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_x"),&Generic6DOFJoint::_get_angular_hi_limit_x);
+ ClassDB::bind_method(_MD("_set_angular_hi_limit_x","angle"),&Generic6DOFJoint::_set_angular_hi_limit_x);
+ ClassDB::bind_method(_MD("_get_angular_hi_limit_x"),&Generic6DOFJoint::_get_angular_hi_limit_x);
- ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_x","angle"),&Generic6DOFJoint::_set_angular_lo_limit_x);
- ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_x"),&Generic6DOFJoint::_get_angular_lo_limit_x);
+ ClassDB::bind_method(_MD("_set_angular_lo_limit_x","angle"),&Generic6DOFJoint::_set_angular_lo_limit_x);
+ ClassDB::bind_method(_MD("_get_angular_lo_limit_x"),&Generic6DOFJoint::_get_angular_lo_limit_x);
- ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_y","angle"),&Generic6DOFJoint::_set_angular_hi_limit_y);
- ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_y"),&Generic6DOFJoint::_get_angular_hi_limit_y);
+ ClassDB::bind_method(_MD("_set_angular_hi_limit_y","angle"),&Generic6DOFJoint::_set_angular_hi_limit_y);
+ ClassDB::bind_method(_MD("_get_angular_hi_limit_y"),&Generic6DOFJoint::_get_angular_hi_limit_y);
- ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_y","angle"),&Generic6DOFJoint::_set_angular_lo_limit_y);
- ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_y"),&Generic6DOFJoint::_get_angular_lo_limit_y);
+ ClassDB::bind_method(_MD("_set_angular_lo_limit_y","angle"),&Generic6DOFJoint::_set_angular_lo_limit_y);
+ ClassDB::bind_method(_MD("_get_angular_lo_limit_y"),&Generic6DOFJoint::_get_angular_lo_limit_y);
- ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_z","angle"),&Generic6DOFJoint::_set_angular_hi_limit_z);
- ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_z"),&Generic6DOFJoint::_get_angular_hi_limit_z);
+ ClassDB::bind_method(_MD("_set_angular_hi_limit_z","angle"),&Generic6DOFJoint::_set_angular_hi_limit_z);
+ ClassDB::bind_method(_MD("_get_angular_hi_limit_z"),&Generic6DOFJoint::_get_angular_hi_limit_z);
- ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_z","angle"),&Generic6DOFJoint::_set_angular_lo_limit_z);
- ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_z"),&Generic6DOFJoint::_get_angular_lo_limit_z);
+ ClassDB::bind_method(_MD("_set_angular_lo_limit_z","angle"),&Generic6DOFJoint::_set_angular_lo_limit_z);
+ ClassDB::bind_method(_MD("_get_angular_lo_limit_z"),&Generic6DOFJoint::_get_angular_lo_limit_z);
- ObjectTypeDB::bind_method(_MD("set_param_x","param","value"),&Generic6DOFJoint::set_param_x);
- ObjectTypeDB::bind_method(_MD("get_param_x","param"),&Generic6DOFJoint::get_param_x);
+ ClassDB::bind_method(_MD("set_param_x","param","value"),&Generic6DOFJoint::set_param_x);
+ ClassDB::bind_method(_MD("get_param_x","param"),&Generic6DOFJoint::get_param_x);
- ObjectTypeDB::bind_method(_MD("set_param_y","param","value"),&Generic6DOFJoint::set_param_y);
- ObjectTypeDB::bind_method(_MD("get_param_y","param"),&Generic6DOFJoint::get_param_y);
+ ClassDB::bind_method(_MD("set_param_y","param","value"),&Generic6DOFJoint::set_param_y);
+ ClassDB::bind_method(_MD("get_param_y","param"),&Generic6DOFJoint::get_param_y);
- ObjectTypeDB::bind_method(_MD("set_param_z","param","value"),&Generic6DOFJoint::set_param_z);
- ObjectTypeDB::bind_method(_MD("get_param_z","param"),&Generic6DOFJoint::get_param_z);
+ ClassDB::bind_method(_MD("set_param_z","param","value"),&Generic6DOFJoint::set_param_z);
+ ClassDB::bind_method(_MD("get_param_z","param"),&Generic6DOFJoint::get_param_z);
- ObjectTypeDB::bind_method(_MD("set_flag_x","flag","value"),&Generic6DOFJoint::set_flag_x);
- ObjectTypeDB::bind_method(_MD("get_flag_x","flag"),&Generic6DOFJoint::get_flag_x);
+ ClassDB::bind_method(_MD("set_flag_x","flag","value"),&Generic6DOFJoint::set_flag_x);
+ ClassDB::bind_method(_MD("get_flag_x","flag"),&Generic6DOFJoint::get_flag_x);
- ObjectTypeDB::bind_method(_MD("set_flag_y","flag","value"),&Generic6DOFJoint::set_flag_y);
- ObjectTypeDB::bind_method(_MD("get_flag_y","flag"),&Generic6DOFJoint::get_flag_y);
+ ClassDB::bind_method(_MD("set_flag_y","flag","value"),&Generic6DOFJoint::set_flag_y);
+ ClassDB::bind_method(_MD("get_flag_y","flag"),&Generic6DOFJoint::get_flag_y);
- ObjectTypeDB::bind_method(_MD("set_flag_z","flag","value"),&Generic6DOFJoint::set_flag_z);
- ObjectTypeDB::bind_method(_MD("get_flag_z","flag"),&Generic6DOFJoint::get_flag_z);
+ ClassDB::bind_method(_MD("set_flag_z","flag","value"),&Generic6DOFJoint::set_flag_z);
+ ClassDB::bind_method(_MD("get_flag_z","flag"),&Generic6DOFJoint::get_flag_z);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_LINEAR_LIMIT);
@@ -1170,22 +1171,22 @@ RID PhysicsJoint::_get_visual_instance_rid() const {
void PhysicsJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid);
- ObjectTypeDB::bind_method(_MD("set_body_A","path"),&PhysicsJoint::set_body_A);
- ObjectTypeDB::bind_method(_MD("set_body_B"),&PhysicsJoint::set_body_B);
- ObjectTypeDB::bind_method(_MD("get_body_A","path"),&PhysicsJoint::get_body_A);
- ObjectTypeDB::bind_method(_MD("get_body_B"),&PhysicsJoint::get_body_B);
+ ClassDB::bind_method(_MD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid);
+ ClassDB::bind_method(_MD("set_body_A","path"),&PhysicsJoint::set_body_A);
+ ClassDB::bind_method(_MD("set_body_B"),&PhysicsJoint::set_body_B);
+ ClassDB::bind_method(_MD("get_body_A","path"),&PhysicsJoint::get_body_A);
+ ClassDB::bind_method(_MD("get_body_B"),&PhysicsJoint::get_body_B);
- ObjectTypeDB::bind_method(_MD("set_active","active"),&PhysicsJoint::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&PhysicsJoint::is_active);
+ ClassDB::bind_method(_MD("set_active","active"),&PhysicsJoint::set_active);
+ ClassDB::bind_method(_MD("is_active"),&PhysicsJoint::is_active);
- ObjectTypeDB::bind_method(_MD("set_disable_collision","disable"),&PhysicsJoint::set_disable_collision);
- ObjectTypeDB::bind_method(_MD("has_disable_collision"),&PhysicsJoint::has_disable_collision);
+ ClassDB::bind_method(_MD("set_disable_collision","disable"),&PhysicsJoint::set_disable_collision);
+ ClassDB::bind_method(_MD("has_disable_collision"),&PhysicsJoint::has_disable_collision);
- ObjectTypeDB::bind_method("reconnect",&PhysicsJoint::reconnect);
+ ClassDB::bind_method("reconnect",&PhysicsJoint::reconnect);
- ObjectTypeDB::bind_method(_MD("get_rid"),&PhysicsJoint::get_rid);
+ ClassDB::bind_method(_MD("get_rid"),&PhysicsJoint::get_rid);
}
diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h
index 55c26f296e..5debe87d38 100644
--- a/scene/3d/physics_joint.h
+++ b/scene/3d/physics_joint.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class Joint : public Spatial {
- OBJ_TYPE(Joint,Spatial);
+ GDCLASS(Joint,Spatial);
RID ba,bb;
@@ -81,7 +81,7 @@ public:
class PinJoint : public Joint {
- OBJ_TYPE(PinJoint,Joint);
+ GDCLASS(PinJoint,Joint);
public:
enum Param {
@@ -108,7 +108,7 @@ VARIANT_ENUM_CAST(PinJoint::Param);
class HingeJoint : public Joint {
- OBJ_TYPE(HingeJoint,Joint);
+ GDCLASS(HingeJoint,Joint);
public:
enum Param {
@@ -161,7 +161,7 @@ VARIANT_ENUM_CAST(HingeJoint::Flag);
class SliderJoint : public Joint {
- OBJ_TYPE(SliderJoint,Joint);
+ GDCLASS(SliderJoint,Joint);
public:
enum Param {
@@ -221,7 +221,7 @@ VARIANT_ENUM_CAST(SliderJoint::Param);
class ConeTwistJoint : public Joint {
- OBJ_TYPE(ConeTwistJoint,Joint);
+ GDCLASS(ConeTwistJoint,Joint);
public:
enum Param {
@@ -260,7 +260,7 @@ VARIANT_ENUM_CAST(ConeTwistJoint::Param);
class Generic6DOFJoint : public Joint {
- OBJ_TYPE(Generic6DOFJoint,Joint);
+ GDCLASS(Generic6DOFJoint,Joint);
public:
enum Param {
@@ -351,7 +351,7 @@ VARIANT_ENUM_CAST(Generic6DOFJoint::Flag);
#if 0
class PhysicsJoint : public Spatial {
- OBJ_TYPE(PhysicsJoint,Spatial);
+ GDCLASS(PhysicsJoint,Spatial);
OBJ_CATEGORY("3D Physics Nodes");
NodePath body_A;
@@ -404,7 +404,7 @@ public:
class PhysicsJointPin : public PhysicsJoint {
- OBJ_TYPE( PhysicsJointPin, PhysicsJoint );
+ GDCLASS( PhysicsJointPin, PhysicsJoint );
protected:
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 23bc64615d..054b61a4ed 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
bool Portal::_set(const StringName& p_name, const Variant& p_value) {
if (p_name=="shape") {
- DVector<float> src_coords=p_value;
+ PoolVector<float> src_coords=p_value;
Vector<Point2> points;
int src_coords_size = src_coords.size();
ERR_FAIL_COND_V(src_coords_size%2,false);
@@ -63,7 +63,7 @@ bool Portal::_get(const StringName& p_name,Variant &r_ret) const {
if (p_name=="shape") {
Vector<Point2> points=get_shape();
- DVector<float> dst_coords;
+ PoolVector<float> dst_coords;
dst_coords.resize(points.size()*2);
for (int i=0;i<points.size();i++) {
@@ -88,7 +88,7 @@ bool Portal::_get(const StringName& p_name,Variant &r_ret) const {
void Portal::_get_property_list( List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::REAL_ARRAY, "shape" ) );
+ p_list->push_back( PropertyInfo( Variant::POOL_REAL_ARRAY, "shape" ) );
p_list->push_back( PropertyInfo( Variant::BOOL, "enabled" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "disable_distance",PROPERTY_HINT_RANGE,"0,4096,0.01" ) );
p_list->push_back( PropertyInfo( Variant::COLOR, "disabled_color") );
@@ -96,59 +96,20 @@ void Portal::_get_property_list( List<PropertyInfo> *p_list) const {
}
-RES Portal::_get_gizmo_geometry() const {
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.8,0.8,0.7) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
-// mat->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
- Vector<Point2> shape = get_shape();
-
- Vector2 center;
- for (int i=0;i<shape.size();i++) {
-
- int n=(i+1)%shape.size();
- Vector<Vector3> points;
- surface_tool->add_vertex( Vector3( shape[i].x, shape[i].y,0 ));
- surface_tool->add_vertex( Vector3( shape[n].x, shape[n].y,0 ));
- center+=shape[i];
-
- }
-
- if (shape.size()>0) {
-
- center/=shape.size();
- Vector<Vector3> points;
- surface_tool->add_vertex( Vector3( center.x, center.y,0 ));
- surface_tool->add_vertex( Vector3( center.x, center.y,1.0 ));
- }
-
- return surface_tool->commit();
-}
-
-
-
-AABB Portal::get_aabb() const {
+Rect3 Portal::get_aabb() const {
return aabb;
}
-DVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
if (!(p_usage_flags&FACES_ENCLOSING))
- return DVector<Face3>();
+ return PoolVector<Face3>();
Vector<Point2> shape = get_shape();
if (shape.size()==0)
- return DVector<Face3>();
+ return PoolVector<Face3>();
Vector2 center;
for (int i=0;i<shape.size();i++) {
@@ -157,7 +118,7 @@ DVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
}
- DVector<Face3> ret;
+ PoolVector<Face3> ret;
center/=shape.size();
for (int i=0;i<shape.size();i++) {
@@ -178,18 +139,19 @@ void Portal::set_shape(const Vector<Point2>& p_shape) {
VisualServer::get_singleton()->portal_set_shape(portal, p_shape);
+ shape=p_shape;
update_gizmo();
}
Vector<Point2> Portal::get_shape() const {
- return VisualServer::get_singleton()->portal_get_shape(portal);
+ return shape;
}
void Portal::set_connect_range(float p_range) {
connect_range=p_range;
- VisualServer::get_singleton()->portal_set_connect_range(portal,p_range);
+ //VisualServer::get_singleton()->portal_set_connect_range(portal,p_range);
}
float Portal::get_connect_range() const {
@@ -235,20 +197,20 @@ Color Portal::get_disabled_color() const {
void Portal::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shape","points"),&Portal::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&Portal::get_shape);
+ ClassDB::bind_method(_MD("set_shape","points"),&Portal::set_shape);
+ ClassDB::bind_method(_MD("get_shape"),&Portal::get_shape);
- ObjectTypeDB::bind_method(_MD("set_enabled","enable"),&Portal::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&Portal::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enable"),&Portal::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&Portal::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_disable_distance","distance"),&Portal::set_disable_distance);
- ObjectTypeDB::bind_method(_MD("get_disable_distance"),&Portal::get_disable_distance);
+ ClassDB::bind_method(_MD("set_disable_distance","distance"),&Portal::set_disable_distance);
+ ClassDB::bind_method(_MD("get_disable_distance"),&Portal::get_disable_distance);
- ObjectTypeDB::bind_method(_MD("set_disabled_color","color"),&Portal::set_disabled_color);
- ObjectTypeDB::bind_method(_MD("get_disabled_color"),&Portal::get_disabled_color);
+ ClassDB::bind_method(_MD("set_disabled_color","color"),&Portal::set_disabled_color);
+ ClassDB::bind_method(_MD("get_disabled_color"),&Portal::get_disabled_color);
- ObjectTypeDB::bind_method(_MD("set_connect_range","range"),&Portal::set_connect_range);
- ObjectTypeDB::bind_method(_MD("get_connect_range"),&Portal::get_connect_range);
+ ClassDB::bind_method(_MD("set_connect_range","range"),&Portal::set_connect_range);
+ ClassDB::bind_method(_MD("get_connect_range"),&Portal::get_connect_range);
}
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 149a56900f..077924c7e8 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -44,18 +44,18 @@
class Portal : public VisualInstance {
- OBJ_TYPE(Portal, VisualInstance);
+ GDCLASS(Portal, VisualInstance);
RID portal;
+ Vector<Point2> shape;
bool enabled;
float disable_distance;
Color disabled_color;
float connect_range;
- AABB aabb;
+ Rect3 aabb;
- virtual RES _get_gizmo_geometry() const;
protected:
@@ -67,8 +67,8 @@ protected:
public:
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_enabled(bool p_enabled);
bool is_enabled() const;
diff --git a/scene/3d/position_3d.cpp b/scene/3d/position_3d.cpp
index 27130cbe6a..e7403053b2 100644
--- a/scene/3d/position_3d.cpp
+++ b/scene/3d/position_3d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,37 +29,6 @@
#include "position_3d.h"
#include "scene/resources/mesh.h"
-RES Position3D::_get_gizmo_geometry() const {
-
-
- Ref<Mesh> mesh = memnew( Mesh );
-
- DVector<Vector3> cursor_points;
- DVector<Color> cursor_colors;
- float cs = 0.25;
- cursor_points.push_back(Vector3(+cs,0,0));
- cursor_points.push_back(Vector3(-cs,0,0));
- cursor_points.push_back(Vector3(0,+cs,0));
- cursor_points.push_back(Vector3(0,-cs,0));
- cursor_points.push_back(Vector3(0,0,+cs));
- cursor_points.push_back(Vector3(0,0,-cs));
- cursor_colors.push_back(Color(1,0.5,0.5,1));
- cursor_colors.push_back(Color(1,0.5,0.5,1));
- cursor_colors.push_back(Color(0.5,1,0.5,1));
- cursor_colors.push_back(Color(0.5,1,0.5,1));
- cursor_colors.push_back(Color(0.5,0.5,1,1));
- cursor_colors.push_back(Color(0.5,0.5,1,1));
-
- Ref<FixedMaterial> mat = memnew( FixedMaterial );
- mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_line_width(3);
- Array d;
- d[Mesh::ARRAY_VERTEX]=cursor_points;
- d[Mesh::ARRAY_COLOR]=cursor_colors;
- mesh->add_surface(Mesh::PRIMITIVE_LINES,d);
- mesh->surface_set_material(0,mat);
- return mesh;
-}
Position3D::Position3D()
{
diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h
index 6bac540fcb..e732c5321e 100644
--- a/scene/3d/position_3d.h
+++ b/scene/3d/position_3d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,9 +33,8 @@
class Position3D : public Spatial {
- OBJ_TYPE(Position3D,Spatial);
+ GDCLASS(Position3D,Spatial);
- virtual RES _get_gizmo_geometry() const;
public:
diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp
index a2182302a0..9f4b5c7a03 100644
--- a/scene/3d/proximity_group.cpp
+++ b/scene/3d/proximity_group.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -135,7 +135,7 @@ void ProximityGroup::broadcast(String p_name, Variant p_params) {
E = groups.front();
while (E) {
- get_tree()->call_group(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params);
E = E->next();
};
@@ -171,12 +171,12 @@ Vector3 ProximityGroup::get_grid_radius() const {
void ProximityGroup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_group_name","name"), &ProximityGroup::set_group_name);
- ObjectTypeDB::bind_method(_MD("broadcast","name", "parameters"), &ProximityGroup::broadcast);
- ObjectTypeDB::bind_method(_MD("set_dispatch_mode","mode"), &ProximityGroup::set_dispatch_mode);
- ObjectTypeDB::bind_method(_MD("_proximity_group_broadcast","name","params"), &ProximityGroup::_proximity_group_broadcast);
- ObjectTypeDB::bind_method(_MD("set_grid_radius","radius"), &ProximityGroup::set_grid_radius);
- ObjectTypeDB::bind_method(_MD("get_grid_radius"), &ProximityGroup::get_grid_radius);
+ ClassDB::bind_method(_MD("set_group_name","name"), &ProximityGroup::set_group_name);
+ ClassDB::bind_method(_MD("broadcast","name", "parameters"), &ProximityGroup::broadcast);
+ ClassDB::bind_method(_MD("set_dispatch_mode","mode"), &ProximityGroup::set_dispatch_mode);
+ ClassDB::bind_method(_MD("_proximity_group_broadcast","name","params"), &ProximityGroup::_proximity_group_broadcast);
+ ClassDB::bind_method(_MD("set_grid_radius","radius"), &ProximityGroup::set_grid_radius);
+ ClassDB::bind_method(_MD("get_grid_radius"), &ProximityGroup::get_grid_radius);
ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "grid_radius"), _SCS("set_grid_radius"), _SCS("get_grid_radius"));
@@ -190,6 +190,7 @@ ProximityGroup::ProximityGroup() {
dispatch_mode = MODE_PROXY;
grid_radius = Vector3(1, 1, 1);
+ set_notify_transform(true);
};
diff --git a/scene/3d/proximity_group.h b/scene/3d/proximity_group.h
index 6d5c703827..58d2436975 100644
--- a/scene/3d/proximity_group.h
+++ b/scene/3d/proximity_group.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ProximityGroup : public Spatial {
- OBJ_TYPE( ProximityGroup, Spatial );
+ GDCLASS( ProximityGroup, Spatial );
OBJ_CATEGORY("3D");
public:
diff --git a/scene/3d/quad.cpp b/scene/3d/quad.cpp
index 1a7eeef180..d1cef0e851 100644
--- a/scene/3d/quad.cpp
+++ b/scene/3d/quad.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -44,9 +44,9 @@ void Quad::_update() {
- DVector<Vector3> points;
+ PoolVector<Vector3> points;
points.resize(4);
- DVector<Vector3>::Write pointsw = points.write();
+ PoolVector<Vector3>::Write pointsw = points.write();
Vector2 s2 = size*0.5;
Vector2 o = offset;
@@ -66,38 +66,38 @@ void Quad::_update() {
pointsw[3][a2]=-s2.y+offset.y;
- aabb=AABB(pointsw[0],Vector3());
+ aabb=Rect3(pointsw[0],Vector3());
for(int i=1;i<4;i++)
aabb.expand_to(pointsw[i]);
- pointsw = DVector<Vector3>::Write();
+ pointsw = PoolVector<Vector3>::Write();
- DVector<Vector3> normals;
+ PoolVector<Vector3> normals;
normals.resize(4);
- DVector<Vector3>::Write normalsw = normals.write();
+ PoolVector<Vector3>::Write normalsw = normals.write();
for(int i=0;i<4;i++)
normalsw[i]=normal;
- normalsw=DVector<Vector3>::Write();
+ normalsw=PoolVector<Vector3>::Write();
- DVector<Vector2> uvs;
+ PoolVector<Vector2> uvs;
uvs.resize(4);
- DVector<Vector2>::Write uvsw = uvs.write();
+ PoolVector<Vector2>::Write uvsw = uvs.write();
uvsw[0]=Vector2(0,0);
uvsw[1]=Vector2(1,0);
uvsw[2]=Vector2(1,1);
uvsw[3]=Vector2(0,1);
- uvsw = DVector<Vector2>::Write();
+ uvsw = PoolVector<Vector2>::Write();
- DVector<int> indices;
+ PoolVector<int> indices;
indices.resize(6);
- DVector<int>::Write indicesw = indices.write();
+ PoolVector<int>::Write indicesw = indices.write();
indicesw[0]=0;
indicesw[1]=1;
indicesw[2]=2;
@@ -105,7 +105,7 @@ void Quad::_update() {
indicesw[4]=3;
indicesw[5]=0;
- indicesw=DVector<int>::Write();
+ indicesw=PoolVector<int>::Write();
Array arr;
arr.resize(VS::ARRAY_MAX);
@@ -120,7 +120,7 @@ void Quad::_update() {
} else {
configured=true;
}
- VS::get_singleton()->mesh_add_surface(mesh,VS::PRIMITIVE_TRIANGLES,arr);
+ VS::get_singleton()->mesh_add_surface_from_arrays(mesh,VS::PRIMITIVE_TRIANGLES,arr);
pending_update=false;
}
@@ -187,34 +187,34 @@ void Quad::_notification(int p_what) {
}
}
-DVector<Face3> Quad::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> Quad::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+ return PoolVector<Face3>();
}
-AABB Quad::get_aabb() const {
+Rect3 Quad::get_aabb() const {
return aabb;
}
void Quad::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_axis","axis"),&Quad::set_axis);
- ObjectTypeDB::bind_method(_MD("get_axis"),&Quad::get_axis);
+ ClassDB::bind_method(_MD("set_axis","axis"),&Quad::set_axis);
+ ClassDB::bind_method(_MD("get_axis"),&Quad::get_axis);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&Quad::set_size);
- ObjectTypeDB::bind_method(_MD("get_size"),&Quad::get_size);
+ ClassDB::bind_method(_MD("set_size","size"),&Quad::set_size);
+ ClassDB::bind_method(_MD("get_size"),&Quad::get_size);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&Quad::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&Quad::is_centered);
+ ClassDB::bind_method(_MD("set_centered","centered"),&Quad::set_centered);
+ ClassDB::bind_method(_MD("is_centered"),&Quad::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Quad::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Quad::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&Quad::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&Quad::get_offset);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "quad/axis", PROPERTY_HINT_ENUM,"X,Y,Z" ), _SCS("set_axis"), _SCS("get_axis"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "quad/size" ), _SCS("set_size"), _SCS("get_size"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "quad/offset" ), _SCS("set_offset"), _SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "quad/centered" ), _SCS("set_centered"), _SCS("is_centered"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "axis", PROPERTY_HINT_ENUM,"X,Y,Z" ), _SCS("set_axis"), _SCS("get_axis"));
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "size" ), _SCS("set_size"), _SCS("get_size"));
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset" ), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered" ), _SCS("set_centered"), _SCS("is_centered"));
}
@@ -230,3 +230,7 @@ Quad::Quad() {
configured=false;
}
+
+Quad::~Quad() {
+ VisualServer::get_singleton()->free(mesh);
+}
diff --git a/scene/3d/quad.h b/scene/3d/quad.h
index be55b0d1c9..af91d7a1f5 100644
--- a/scene/3d/quad.h
+++ b/scene/3d/quad.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,14 +35,14 @@
class Quad : public GeometryInstance {
- OBJ_TYPE(Quad,GeometryInstance);
+ GDCLASS(Quad,GeometryInstance);
Vector3::Axis axis;
bool centered;
Vector2 offset;
Vector2 size;
- AABB aabb;
+ Rect3 aabb;
bool configured;
bool pending_update;
RID mesh;
@@ -67,10 +67,11 @@ public:
void set_centered(bool p_enabled);
bool is_centered() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- virtual AABB get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
Quad();
+ ~Quad();
};
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 1acda8d1f8..8216d7295f 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -134,39 +134,44 @@ void RayCast::_notification(int p_what) {
if (!enabled)
break;
+ _update_raycast_state();
- Ref<World> w3d = get_world();
- ERR_BREAK( w3d.is_null() );
-
- PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
- ERR_BREAK( !dss );
-
- Transform gt = get_global_transform();
+ } break;
+ }
+}
- Vector3 to = cast_to;
- if (to==Vector3())
- to=Vector3(0,0.01,0);
+void RayCast::_update_raycast_state(){
+ Ref<World> w3d = get_world();
+ ERR_FAIL_COND( w3d.is_null() );
- PhysicsDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
+ ERR_FAIL_COND( !dss );
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
+ Transform gt = get_global_transform();
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
- } else {
- collided=false;
- }
+ Vector3 to = cast_to;
+ if (to==Vector3())
+ to=Vector3(0,0.01,0);
+ PhysicsDirectSpaceState::RayResult rr;
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
- } break;
+ collided=true;
+ against=rr.collider_id;
+ collision_point=rr.position;
+ collision_normal=rr.normal;
+ against_shape=rr.shape;
+ } else {
+ collided=false;
}
}
+void RayCast::force_raycast_update() {
+ _update_raycast_state();
+}
+
void RayCast::add_exception_rid(const RID& p_rid) {
exclude.insert(p_rid);
@@ -205,36 +210,37 @@ void RayCast::clear_exceptions(){
void RayCast::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&RayCast::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&RayCast::is_enabled);
+ ClassDB::bind_method(_MD("set_enabled","enabled"),&RayCast::set_enabled);
+ ClassDB::bind_method(_MD("is_enabled"),&RayCast::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_cast_to","local_point"),&RayCast::set_cast_to);
- ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast::get_cast_to);
+ ClassDB::bind_method(_MD("set_cast_to","local_point"),&RayCast::set_cast_to);
+ ClassDB::bind_method(_MD("get_cast_to"),&RayCast::get_cast_to);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast::is_colliding);
+ ClassDB::bind_method(_MD("is_colliding"),&RayCast::is_colliding);
+ ClassDB::bind_method(_MD("force_raycast_update"),&RayCast::force_raycast_update);
- ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast::get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_point"),&RayCast::get_collision_point);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&RayCast::get_collision_normal);
+ ClassDB::bind_method(_MD("get_collider"),&RayCast::get_collider);
+ ClassDB::bind_method(_MD("get_collider_shape"),&RayCast::get_collider_shape);
+ ClassDB::bind_method(_MD("get_collision_point"),&RayCast::get_collision_point);
+ ClassDB::bind_method(_MD("get_collision_normal"),&RayCast::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("add_exception_rid","rid"),&RayCast::add_exception_rid);
- ObjectTypeDB::bind_method(_MD("add_exception","node"),&RayCast::add_exception);
+ ClassDB::bind_method(_MD("add_exception_rid","rid"),&RayCast::add_exception_rid);
+ ClassDB::bind_method(_MD("add_exception","node"),&RayCast::add_exception);
- ObjectTypeDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast::remove_exception_rid);
- ObjectTypeDB::bind_method(_MD("remove_exception","node"),&RayCast::remove_exception);
+ ClassDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast::remove_exception_rid);
+ ClassDB::bind_method(_MD("remove_exception","node"),&RayCast::remove_exception);
- ObjectTypeDB::bind_method(_MD("clear_exceptions"),&RayCast::clear_exceptions);
+ ClassDB::bind_method(_MD("clear_exceptions"),&RayCast::clear_exceptions);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&RayCast::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&RayCast::get_layer_mask);
+ ClassDB::bind_method(_MD("set_layer_mask","mask"),&RayCast::set_layer_mask);
+ ClassDB::bind_method(_MD("get_layer_mask"),&RayCast::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_type_mask","mask"),&RayCast::set_type_mask);
- ObjectTypeDB::bind_method(_MD("get_type_mask"),&RayCast::get_type_mask);
+ ClassDB::bind_method(_MD("set_type_mask","mask"),&RayCast::set_type_mask);
+ ClassDB::bind_method(_MD("get_type_mask"),&RayCast::get_type_mask);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
}
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index 4f6514e61b..32d24cc962 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class RayCast : public Spatial {
- OBJ_TYPE(RayCast,Spatial);
+ GDCLASS(RayCast,Spatial);
bool enabled;
@@ -53,6 +53,7 @@ class RayCast : public Spatial {
protected:
void _notification(int p_what);
+ void _update_raycast_state();
static void _bind_methods();
public:
@@ -68,6 +69,7 @@ public:
void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const;
+ void force_raycast_update();
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
new file mode 100644
index 0000000000..d9592d9484
--- /dev/null
+++ b/scene/3d/reflection_probe.cpp
@@ -0,0 +1,268 @@
+#include "reflection_probe.h"
+
+
+void ReflectionProbe::set_intensity(float p_intensity) {
+
+ intensity=p_intensity;
+ VS::get_singleton()->reflection_probe_set_intensity(probe,p_intensity);
+}
+
+float ReflectionProbe::get_intensity() const{
+
+ return intensity;
+}
+
+
+void ReflectionProbe::set_interior_ambient(Color p_ambient) {
+
+ interior_ambient=p_ambient;
+ VS::get_singleton()->reflection_probe_set_interior_ambient(probe,p_ambient);
+}
+
+void ReflectionProbe::set_interior_ambient_energy(float p_energy) {
+ interior_ambient_energy=p_energy;
+ VS::get_singleton()->reflection_probe_set_interior_ambient_energy(probe,p_energy);
+}
+
+float ReflectionProbe::get_interior_ambient_energy() const{
+ return interior_ambient_energy;
+}
+
+
+Color ReflectionProbe::get_interior_ambient() const{
+
+ return interior_ambient;
+}
+
+void ReflectionProbe::set_interior_ambient_probe_contribution(float p_contribution) {
+
+ interior_ambient_probe_contribution=p_contribution;
+ VS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe,p_contribution);
+}
+
+float ReflectionProbe::get_interior_ambient_probe_contribution() const{
+
+ return interior_ambient_probe_contribution;
+}
+
+
+void ReflectionProbe::set_max_distance(float p_distance){
+
+ max_distance=p_distance;
+ VS::get_singleton()->reflection_probe_set_max_distance(probe,p_distance);
+}
+float ReflectionProbe::get_max_distance() const{
+
+ return max_distance;
+}
+
+
+void ReflectionProbe::set_extents(const Vector3& p_extents){
+
+ extents=p_extents;
+
+ for(int i=0;i<3;i++) {
+ if (extents[i]<0.01) {
+ extents[i]=0.01;
+ }
+
+ if (extents[i]-0.01<ABS(origin_offset[i])) {
+ origin_offset[i]=SGN(origin_offset[i])*(extents[i]-0.01);
+ _change_notify("origin_offset");
+ }
+ }
+
+ VS::get_singleton()->reflection_probe_set_extents(probe,extents);
+ VS::get_singleton()->reflection_probe_set_origin_offset(probe,origin_offset);
+ _change_notify("extents");
+ update_gizmo();
+
+}
+Vector3 ReflectionProbe::get_extents() const{
+
+ return extents;
+}
+
+void ReflectionProbe::set_origin_offset(const Vector3& p_extents){
+
+ origin_offset=p_extents;
+
+ for(int i=0;i<3;i++) {
+
+ if (extents[i]-0.01<ABS(origin_offset[i])) {
+ origin_offset[i]=SGN(origin_offset[i])*(extents[i]-0.01);
+
+ }
+ }
+ VS::get_singleton()->reflection_probe_set_extents(probe,extents);
+ VS::get_singleton()->reflection_probe_set_origin_offset(probe,origin_offset);
+
+ _change_notify("origin_offset");
+ update_gizmo();
+}
+Vector3 ReflectionProbe::get_origin_offset() const{
+
+ return origin_offset;
+}
+
+void ReflectionProbe::set_enable_box_projection(bool p_enable){
+
+ box_projection=p_enable;
+ VS::get_singleton()->reflection_probe_set_enable_box_projection(probe,p_enable);
+
+}
+bool ReflectionProbe::is_box_projection_enabled() const{
+
+ return box_projection;
+}
+
+
+void ReflectionProbe::set_as_interior(bool p_enable) {
+
+ interior=p_enable;
+ VS::get_singleton()->reflection_probe_set_as_interior(probe,interior);
+ _change_notify();
+
+}
+
+bool ReflectionProbe::is_set_as_interior() const {
+
+ return interior;
+}
+
+
+
+void ReflectionProbe::set_enable_shadows(bool p_enable) {
+
+ enable_shadows=p_enable;
+ VS::get_singleton()->reflection_probe_set_enable_shadows(probe,p_enable);
+}
+bool ReflectionProbe::are_shadows_enabled() const {
+
+ return enable_shadows;
+}
+
+void ReflectionProbe::set_cull_mask(uint32_t p_layers) {
+
+ cull_mask=p_layers;
+ VS::get_singleton()->reflection_probe_set_enable_shadows(probe,p_layers);
+}
+uint32_t ReflectionProbe::get_cull_mask() const {
+
+ return cull_mask;
+}
+
+void ReflectionProbe::set_update_mode(UpdateMode p_mode) {
+ update_mode=p_mode;
+ VS::get_singleton()->reflection_probe_set_update_mode(probe,VS::ReflectionProbeUpdateMode(p_mode));
+}
+
+ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
+ return update_mode;
+}
+
+
+Rect3 ReflectionProbe::get_aabb() const {
+
+ Rect3 aabb;
+ aabb.pos=-origin_offset;
+ aabb.size=origin_offset+extents;
+ return aabb;
+}
+PoolVector<Face3> ReflectionProbe::get_faces(uint32_t p_usage_flags) const {
+
+ return PoolVector<Face3>();
+}
+
+void ReflectionProbe::_validate_property(PropertyInfo& property) const {
+
+ if (property.name=="interior/ambient_color" || property.name=="interior/ambient_energy" || property.name=="interior/ambient_contrib") {
+ if (!interior) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+}
+
+void ReflectionProbe::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_intensity","intensity"),&ReflectionProbe::set_intensity);
+ ClassDB::bind_method(_MD("get_intensity"),&ReflectionProbe::get_intensity);
+
+ ClassDB::bind_method(_MD("set_interior_ambient","ambient"),&ReflectionProbe::set_interior_ambient);
+ ClassDB::bind_method(_MD("get_interior_ambient"),&ReflectionProbe::get_interior_ambient);
+
+ ClassDB::bind_method(_MD("set_interior_ambient_energy","ambient_energy"),&ReflectionProbe::set_interior_ambient_energy);
+ ClassDB::bind_method(_MD("get_interior_ambient_energy"),&ReflectionProbe::get_interior_ambient_energy);
+
+ ClassDB::bind_method(_MD("set_interior_ambient_probe_contribution","ambient_probe_contribution"),&ReflectionProbe::set_interior_ambient_probe_contribution);
+ ClassDB::bind_method(_MD("get_interior_ambient_probe_contribution"),&ReflectionProbe::get_interior_ambient_probe_contribution);
+
+ ClassDB::bind_method(_MD("set_max_distance","max_distance"),&ReflectionProbe::set_max_distance);
+ ClassDB::bind_method(_MD("get_max_distance"),&ReflectionProbe::get_max_distance);
+
+ ClassDB::bind_method(_MD("set_extents","extents"),&ReflectionProbe::set_extents);
+ ClassDB::bind_method(_MD("get_extents"),&ReflectionProbe::get_extents);
+
+ ClassDB::bind_method(_MD("set_origin_offset","origin_offset"),&ReflectionProbe::set_origin_offset);
+ ClassDB::bind_method(_MD("get_origin_offset"),&ReflectionProbe::get_origin_offset);
+
+ ClassDB::bind_method(_MD("set_as_interior","enable"),&ReflectionProbe::set_as_interior);
+ ClassDB::bind_method(_MD("is_set_as_interior"),&ReflectionProbe::is_set_as_interior);
+
+ ClassDB::bind_method(_MD("set_enable_box_projection","enable"),&ReflectionProbe::set_enable_box_projection);
+ ClassDB::bind_method(_MD("is_box_projection_enabled"),&ReflectionProbe::is_box_projection_enabled);
+
+
+ ClassDB::bind_method(_MD("set_enable_shadows","enable"),&ReflectionProbe::set_enable_shadows);
+ ClassDB::bind_method(_MD("are_shadows_enabled"),&ReflectionProbe::are_shadows_enabled);
+
+ ClassDB::bind_method(_MD("set_cull_mask","layers"),&ReflectionProbe::set_cull_mask);
+ ClassDB::bind_method(_MD("get_cull_mask"),&ReflectionProbe::get_cull_mask);
+
+ ClassDB::bind_method(_MD("set_update_mode","mode"),&ReflectionProbe::set_update_mode);
+ ClassDB::bind_method(_MD("get_update_mode"),&ReflectionProbe::get_update_mode);
+
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"update_mode",PROPERTY_HINT_ENUM,"Once,Always"),_SCS("set_update_mode"),_SCS("get_update_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"intensity",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_intensity"),_SCS("get_intensity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"max_distance",PROPERTY_HINT_RANGE,"0,16384,0.1"),_SCS("set_max_distance"),_SCS("get_max_distance"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"extents"),_SCS("set_extents"),_SCS("get_extents"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"origin_offset"),_SCS("set_origin_offset"),_SCS("get_origin_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"box_projection"),_SCS("set_enable_box_projection"),_SCS("is_box_projection_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enable_shadows"),_SCS("set_enable_shadows"),_SCS("are_shadows_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER),_SCS("set_cull_mask"),_SCS("get_cull_mask"));
+
+ ADD_GROUP("Interior","interior_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior_enable"),_SCS("set_as_interior"),_SCS("is_set_as_interior"));
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"interior_ambient_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_interior_ambient"),_SCS("get_interior_ambient"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"interior_ambient_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_interior_ambient_energy"),_SCS("get_interior_ambient_energy"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"interior_ambient_contrib",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_interior_ambient_probe_contribution"),_SCS("get_interior_ambient_probe_contribution"));
+
+
+ BIND_CONSTANT( UPDATE_ONCE );
+ BIND_CONSTANT( UPDATE_ALWAYS );
+
+}
+
+ReflectionProbe::ReflectionProbe() {
+
+ intensity=1.0;
+ interior_ambient=Color(0,0,0);
+ interior_ambient_probe_contribution=0;
+ interior_ambient_energy=1.0;
+ max_distance=0;
+ extents=Vector3(1,1,1);
+ origin_offset=Vector3(0,0,0);
+ box_projection=false;
+ interior=false;
+ enable_shadows=false;
+ cull_mask=(1<<20)-1;
+ update_mode=UPDATE_ONCE;
+
+ probe=VisualServer::get_singleton()->reflection_probe_create();
+ VS::get_singleton()->instance_set_base(get_instance(),probe);
+}
+
+ReflectionProbe::~ReflectionProbe() {
+
+ VS::get_singleton()->free(probe);
+}
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
new file mode 100644
index 0000000000..410f590431
--- /dev/null
+++ b/scene/3d/reflection_probe.h
@@ -0,0 +1,92 @@
+#ifndef REFLECTIONPROBE_H
+#define REFLECTIONPROBE_H
+
+#include "scene/3d/visual_instance.h"
+#include "scene/resources/texture.h"
+#include "scene/resources/sky_box.h"
+#include "servers/visual_server.h"
+
+class ReflectionProbe : public VisualInstance {
+ GDCLASS(ReflectionProbe,VisualInstance);
+
+public:
+
+ enum UpdateMode {
+ UPDATE_ONCE,
+ UPDATE_ALWAYS,
+ };
+
+
+private:
+
+ RID probe;
+ float intensity;
+ float max_distance;
+ Vector3 extents;
+ Vector3 origin_offset;
+ bool box_projection;
+ bool enable_shadows;
+ bool interior;
+ Color interior_ambient;
+ float interior_ambient_energy;
+ float interior_ambient_probe_contribution;
+
+ uint32_t cull_mask;
+ UpdateMode update_mode;
+
+protected:
+
+ static void _bind_methods();
+ void _validate_property(PropertyInfo& property) const;
+
+public:
+
+ void set_intensity(float p_intensity);
+ float get_intensity() const;
+
+ void set_interior_ambient(Color p_ambient);
+ Color get_interior_ambient() const;
+
+ void set_interior_ambient_energy(float p_energy);
+ float get_interior_ambient_energy() const;
+
+ void set_interior_ambient_probe_contribution(float p_contribution);
+ float get_interior_ambient_probe_contribution() const;
+
+ void set_max_distance(float p_distance);
+ float get_max_distance() const;
+
+ void set_extents(const Vector3& p_extents);
+ Vector3 get_extents() const;
+
+ void set_origin_offset(const Vector3& p_extents);
+ Vector3 get_origin_offset() const;
+
+ void set_as_interior(bool p_enable);
+ bool is_set_as_interior() const;
+
+ void set_enable_box_projection(bool p_enable);
+ bool is_box_projection_enabled() const;
+
+ void set_enable_shadows(bool p_enable);
+ bool are_shadows_enabled() const;
+
+ void set_cull_mask(uint32_t p_layers);
+ uint32_t get_cull_mask() const;
+
+ void set_update_mode(UpdateMode p_mode);
+ UpdateMode get_update_mode() const;
+
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
+
+
+
+ ReflectionProbe();
+ ~ReflectionProbe();
+};
+
+
+VARIANT_ENUM_CAST( ReflectionProbe::UpdateMode );
+
+#endif // REFLECTIONPROBE_H
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
index d43870417a..b91d90ae8e 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform.cpp
@@ -6,7 +6,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -118,8 +118,8 @@ String RemoteTransform::get_configuration_warning() const {
void RemoteTransform::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform::set_remote_node);
- ObjectTypeDB::bind_method(_MD("get_remote_node"),&RemoteTransform::get_remote_node);
+ ClassDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform::set_remote_node);
+ ClassDB::bind_method(_MD("get_remote_node"),&RemoteTransform::get_remote_node);
ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node"));
}
@@ -127,6 +127,7 @@ void RemoteTransform::_bind_methods() {
RemoteTransform::RemoteTransform() {
cache=0;
+ set_notify_transform(true);
}
diff --git a/scene/3d/remote_transform.h b/scene/3d/remote_transform.h
index 78f0fec1e9..e7aa95ad6e 100644
--- a/scene/3d/remote_transform.h
+++ b/scene/3d/remote_transform.h
@@ -5,7 +5,7 @@
class RemoteTransform : public Spatial
{
- OBJ_TYPE(RemoteTransform,Spatial);
+ GDCLASS(RemoteTransform,Spatial);
NodePath remote_node;
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 9e6867d2a2..cdca54cd84 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -75,63 +75,20 @@ void Room::_notification(int p_what) {
}
-RES Room::_get_gizmo_geometry() const {
- DVector<Face3> faces;
- if (!room.is_null())
- faces=room->get_geometry_hint();
- int count=faces.size();
- if (count==0)
- return RES();
- DVector<Face3>::Read facesr=faces.read();
-
- const Face3* facesptr=facesr.ptr();
-
- DVector<Vector3> points;
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.2,0.8,0.9,0.3) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
- for (int i=0;i<count;i++) {
-
- surface_tool->add_vertex(facesptr[i].vertex[0]);
- surface_tool->add_vertex(facesptr[i].vertex[1]);
-
- surface_tool->add_vertex(facesptr[i].vertex[1]);
- surface_tool->add_vertex(facesptr[i].vertex[2]);
-
- surface_tool->add_vertex(facesptr[i].vertex[2]);
- surface_tool->add_vertex(facesptr[i].vertex[0]);
-
- }
-
- return surface_tool->commit();
-}
-
-
-
-AABB Room::get_aabb() const {
+Rect3 Room::get_aabb() const {
if (room.is_null())
- return AABB();
+ return Rect3();
- return room->get_bounds().get_aabb();
+ return Rect3();
}
-DVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
+
+ return PoolVector<Face3>();
}
@@ -154,9 +111,6 @@ void Room::set_room( const Ref<RoomBounds>& p_room ) {
propagate_notification(NOTIFICATION_AREA_CHANGED);
update_gizmo();
- if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_bounds(sound_room,room->get_bounds());
-
}
@@ -165,21 +119,21 @@ Ref<RoomBounds> Room::get_room() const {
return room;
}
-void Room::_parse_node_faces(DVector<Face3> &all_faces,const Node *p_node) const {
+void Room::_parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) const {
const VisualInstance *vi=p_node->cast_to<VisualInstance>();
if (vi) {
- DVector<Face3> faces=vi->get_faces(FACES_ENCLOSING);
+ PoolVector<Face3> faces=vi->get_faces(FACES_ENCLOSING);
if (faces.size()) {
int old_len=all_faces.size();
all_faces.resize( all_faces.size() + faces.size() );
int new_len=all_faces.size();
- DVector<Face3>::Write all_facesw=all_faces.write();
+ PoolVector<Face3>::Write all_facesw=all_faces.write();
Face3 * all_facesptr=all_facesw.ptr();
- DVector<Face3>::Read facesr=faces.read();
+ PoolVector<Face3>::Read facesr=faces.read();
const Face3 * facesptr=facesr.ptr();
Transform tr=vi->get_relative_transform(this);
@@ -202,32 +156,6 @@ void Room::_parse_node_faces(DVector<Face3> &all_faces,const Node *p_node) const
}
-void Room::compute_room_from_subtree() {
-
-
- DVector<Face3> all_faces;
- _parse_node_faces(all_faces,this);
-
-
- if (all_faces.size()==0)
- return;
- float error;
- DVector<Face3> wrapped_faces = Geometry::wrap_geometry(all_faces,&error);
-
-
- if (wrapped_faces.size()==0)
- return;
-
- BSP_Tree tree(wrapped_faces,error);
-
- Ref<RoomBounds> room( memnew( RoomBounds ) );
- room->set_bounds(tree);
- room->set_geometry_hint(wrapped_faces);
-
- set_room(room);
-
-}
-
void Room::set_simulate_acoustics(bool p_enable) {
@@ -266,14 +194,13 @@ RID Room::get_sound_room() const {
void Room::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_room","room:Room"),&Room::set_room );
- ObjectTypeDB::bind_method(_MD("get_room:Room"),&Room::get_room );
- ObjectTypeDB::bind_method(_MD("compute_room_from_subtree"),&Room::compute_room_from_subtree);
+ ClassDB::bind_method(_MD("set_room","room:Room"),&Room::set_room );
+ ClassDB::bind_method(_MD("get_room:Room"),&Room::get_room );
- ObjectTypeDB::bind_method(_MD("set_simulate_acoustics","enable"),&Room::set_simulate_acoustics );
- ObjectTypeDB::bind_method(_MD("is_simulating_acoustics"),&Room::is_simulating_acoustics );
+ ClassDB::bind_method(_MD("set_simulate_acoustics","enable"),&Room::set_simulate_acoustics );
+ ClassDB::bind_method(_MD("is_simulating_acoustics"),&Room::is_simulating_acoustics );
@@ -289,6 +216,7 @@ Room::Room() {
level=0;
+
}
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index c7df4ceadd..145589a780 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,9 +45,11 @@
*/
+
+
class Room : public VisualInstance {
- OBJ_TYPE( Room, VisualInstance );
+ GDCLASS( Room, VisualInstance );
public:
@@ -61,11 +63,11 @@ private:
bool sound_enabled;
int level;
- void _parse_node_faces(DVector<Face3> &all_faces,const Node *p_node) const;
+ void _parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) const;
void _bounds_changed();
- virtual RES _get_gizmo_geometry() const;
+
protected:
@@ -80,8 +82,8 @@ public:
NOTIFICATION_AREA_CHANGED=60
};
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_room( const Ref<RoomBounds>& p_room );
Ref<RoomBounds> get_room() const;
@@ -89,7 +91,6 @@ public:
void set_simulate_acoustics(bool p_enable);
bool is_simulating_acoustics() const;
- void compute_room_from_subtree();
RID get_sound_room() const;
diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp
index f01c2263fb..bda7d43570 100644
--- a/scene/3d/scenario_fx.cpp
+++ b/scene/3d/scenario_fx.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -83,7 +83,7 @@ Ref<Environment> WorldEnvironment::get_environment() const {
String WorldEnvironment::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree() || !environment.is_valid())
+ if (!is_visible_in_tree() || !is_inside_tree() || !environment.is_valid())
return String();
List<Node*> nodes;
@@ -99,8 +99,8 @@ String WorldEnvironment::get_configuration_warning() const {
void WorldEnvironment::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&WorldEnvironment::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&WorldEnvironment::get_environment);
+ ClassDB::bind_method(_MD("set_environment","env:Environment"),&WorldEnvironment::set_environment);
+ ClassDB::bind_method(_MD("get_environment:Environment"),&WorldEnvironment::get_environment);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
}
diff --git a/scene/3d/scenario_fx.h b/scene/3d/scenario_fx.h
index a73c455918..ef5b70039c 100644
--- a/scene/3d/scenario_fx.h
+++ b/scene/3d/scenario_fx.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@
class WorldEnvironment : public Spatial {
- OBJ_TYPE(WorldEnvironment,Spatial );
+ GDCLASS(WorldEnvironment,Spatial );
Ref<Environment> environment;
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index c996a8123c..f2e339604e 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -163,7 +163,7 @@ void Skeleton::_notification(int p_what) {
Bone *bonesptr=&bones[0];
int len=bones.size();
- vs->skeleton_resize( skeleton, len ); // if same size, nothin really happens
+ vs->skeleton_allocate( skeleton, len ); // if same size, nothin really happens
// pose changed, rebuild cache of inverses
if (rest_global_inverse_dirty) {
@@ -482,7 +482,7 @@ Transform Skeleton::get_bone_pose(int p_bone) const {
void Skeleton::set_bone_custom_pose(int p_bone, const Transform& p_custom_pose) {
ERR_FAIL_INDEX( p_bone, bones.size() );
-// ERR_FAIL_COND( !is_inside_scene() );
+ //ERR_FAIL_COND( !is_inside_scene() );
bones[p_bone].custom_pose_enable=(p_custom_pose!=Transform());
@@ -513,51 +513,6 @@ void Skeleton::_make_dirty() {
}
-RES Skeleton::_get_gizmo_geometry() const {
-
- if (!GLOBAL_DEF("debug/draw_skeleton", true))
- return RES();
-
- if (bones.size()==0)
- return RES();
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.6,1.0,0.3,0.1) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_flag(Material::FLAG_ONTOP,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
-
- const Bone *bonesptr=&bones[0];
- int len=bones.size();
-
- for (int i=0;i<len;i++) {
-
- const Bone &b=bonesptr[i];
-
- Transform t;
- if (b.parent<0)
- continue;
-
- Vector3 v1=(bonesptr[b.parent].pose_global * bonesptr[b.parent].rest_global_inverse).xform(bonesptr[b.parent].rest_global_inverse.affine_inverse().origin);
- Vector3 v2=(b.pose_global * b.rest_global_inverse).xform(b.rest_global_inverse.affine_inverse().origin);
-
- surface_tool->add_vertex(v1);
- surface_tool->add_vertex(v2);
-
- }
-
- return surface_tool->commit();
-
-}
void Skeleton::localize_rests() {
@@ -575,39 +530,39 @@ void Skeleton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_bone","name"),&Skeleton::add_bone);
- ObjectTypeDB::bind_method(_MD("find_bone","name"),&Skeleton::find_bone);
- ObjectTypeDB::bind_method(_MD("get_bone_name","bone_idx"),&Skeleton::get_bone_name);
+ ClassDB::bind_method(_MD("add_bone","name"),&Skeleton::add_bone);
+ ClassDB::bind_method(_MD("find_bone","name"),&Skeleton::find_bone);
+ ClassDB::bind_method(_MD("get_bone_name","bone_idx"),&Skeleton::get_bone_name);
- ObjectTypeDB::bind_method(_MD("get_bone_parent","bone_idx"),&Skeleton::get_bone_parent);
- ObjectTypeDB::bind_method(_MD("set_bone_parent","bone_idx","parent_idx"),&Skeleton::set_bone_parent);
+ ClassDB::bind_method(_MD("get_bone_parent","bone_idx"),&Skeleton::get_bone_parent);
+ ClassDB::bind_method(_MD("set_bone_parent","bone_idx","parent_idx"),&Skeleton::set_bone_parent);
- ObjectTypeDB::bind_method(_MD("get_bone_count"),&Skeleton::get_bone_count);
+ ClassDB::bind_method(_MD("get_bone_count"),&Skeleton::get_bone_count);
- ObjectTypeDB::bind_method(_MD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
+ ClassDB::bind_method(_MD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
- ObjectTypeDB::bind_method(_MD("get_bone_rest","bone_idx"),&Skeleton::get_bone_rest);
- ObjectTypeDB::bind_method(_MD("set_bone_rest","bone_idx","rest"),&Skeleton::set_bone_rest);
+ ClassDB::bind_method(_MD("get_bone_rest","bone_idx"),&Skeleton::get_bone_rest);
+ ClassDB::bind_method(_MD("set_bone_rest","bone_idx","rest"),&Skeleton::set_bone_rest);
- ObjectTypeDB::bind_method(_MD("set_bone_disable_rest","bone_idx","disable"),&Skeleton::set_bone_disable_rest);
- ObjectTypeDB::bind_method(_MD("is_bone_rest_disabled","bone_idx"),&Skeleton::is_bone_rest_disabled);
+ ClassDB::bind_method(_MD("set_bone_disable_rest","bone_idx","disable"),&Skeleton::set_bone_disable_rest);
+ ClassDB::bind_method(_MD("is_bone_rest_disabled","bone_idx"),&Skeleton::is_bone_rest_disabled);
- ObjectTypeDB::bind_method(_MD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
- ObjectTypeDB::bind_method(_MD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
- ObjectTypeDB::bind_method(_MD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
+ ClassDB::bind_method(_MD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
+ ClassDB::bind_method(_MD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
+ ClassDB::bind_method(_MD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
- ObjectTypeDB::bind_method(_MD("clear_bones"),&Skeleton::clear_bones);
+ ClassDB::bind_method(_MD("clear_bones"),&Skeleton::clear_bones);
- ObjectTypeDB::bind_method(_MD("get_bone_pose","bone_idx"),&Skeleton::get_bone_pose);
- ObjectTypeDB::bind_method(_MD("set_bone_pose","bone_idx","pose"),&Skeleton::set_bone_pose);
+ ClassDB::bind_method(_MD("get_bone_pose","bone_idx"),&Skeleton::get_bone_pose);
+ ClassDB::bind_method(_MD("set_bone_pose","bone_idx","pose"),&Skeleton::set_bone_pose);
- ObjectTypeDB::bind_method(_MD("set_bone_global_pose","bone_idx","pose"),&Skeleton::set_bone_global_pose);
- ObjectTypeDB::bind_method(_MD("get_bone_global_pose","bone_idx"),&Skeleton::get_bone_global_pose);
+ ClassDB::bind_method(_MD("set_bone_global_pose","bone_idx","pose"),&Skeleton::set_bone_global_pose);
+ ClassDB::bind_method(_MD("get_bone_global_pose","bone_idx"),&Skeleton::get_bone_global_pose);
- ObjectTypeDB::bind_method(_MD("get_bone_custom_pose","bone_idx"),&Skeleton::get_bone_custom_pose);
- ObjectTypeDB::bind_method(_MD("set_bone_custom_pose","bone_idx","custom_pose"),&Skeleton::set_bone_custom_pose);
+ ClassDB::bind_method(_MD("get_bone_custom_pose","bone_idx"),&Skeleton::get_bone_custom_pose);
+ ClassDB::bind_method(_MD("set_bone_custom_pose","bone_idx","custom_pose"),&Skeleton::set_bone_custom_pose);
- ObjectTypeDB::bind_method(_MD("get_bone_transform","bone_idx"),&Skeleton::get_bone_transform);
+ ClassDB::bind_method(_MD("get_bone_transform","bone_idx"),&Skeleton::get_bone_transform);
BIND_CONSTANT( NOTIFICATION_UPDATE_SKELETON );
}
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index bfdb1d1499..04eb3e9009 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class Skeleton : public Spatial {
- OBJ_TYPE( Skeleton, Spatial );
+ GDCLASS( Skeleton, Spatial );
struct Bone {
@@ -84,7 +84,6 @@ class Skeleton : public Spatial {
return bound;
}
- virtual RES _get_gizmo_geometry() const;
protected:
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 920e56130c..6843a7e9b3 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -74,7 +74,7 @@ SpatialGizmo::SpatialGizmo() {
void Spatial::_notify_dirty() {
- if (!data.ignore_notification && !xform_change.in_list()) {
+ if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change);
}
@@ -83,9 +83,9 @@ void Spatial::_notify_dirty() {
void Spatial::_update_local_transform() const {
-
- data.local_transform.basis.set_euler(data.rotation);
+ data.local_transform.basis = Basis();
data.local_transform.basis.scale(data.scale);
+ data.local_transform.basis.rotate(data.rotation);
data.dirty&=~DIRTY_LOCAL;
}
@@ -95,8 +95,10 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
return;
}
-// if (data.dirty&DIRTY_GLOBAL)
-// return; //already dirty
+ /*
+ if (data.dirty&DIRTY_GLOBAL)
+ return; //already dirty
+ */
data.children_lock++;
@@ -108,7 +110,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
}
- if (!data.ignore_notification && !xform_change.in_list()) {
+ if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change);
@@ -179,8 +181,8 @@ void Spatial::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (get_tree()->is_editor_hint()) {
-// get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
- get_tree()->call_group(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
+ //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
+ get_tree()->call_group_flags(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
if (!data.gizmo_disabled) {
if (data.gizmo.is_valid())
@@ -362,7 +364,7 @@ void Spatial::set_rotation(const Vector3& p_euler_rad){
}
-void Spatial::set_rotation_deg(const Vector3& p_euler_deg) {
+void Spatial::set_rotation_in_degrees(const Vector3& p_euler_deg) {
set_rotation(p_euler_deg * Math_PI / 180.0);
}
@@ -370,13 +372,13 @@ void Spatial::set_rotation_deg(const Vector3& p_euler_deg) {
void Spatial::_set_rotation_deg(const Vector3& p_euler_deg) {
WARN_PRINT("Deprecated method Spatial._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
- set_rotation_deg(p_euler_deg);
+ set_rotation_in_degrees(p_euler_deg);
}
void Spatial::set_scale(const Vector3& p_scale){
if (data.dirty&DIRTY_VECTORS) {
- data.rotation=data.local_transform.basis.get_euler();
+ data.rotation=data.local_transform.basis.get_rotation();
data.dirty&=~DIRTY_VECTORS;
}
@@ -398,14 +400,15 @@ Vector3 Spatial::get_rotation() const{
if (data.dirty&DIRTY_VECTORS) {
data.scale=data.local_transform.basis.get_scale();
- data.rotation=data.local_transform.basis.get_euler();
+ data.rotation=data.local_transform.basis.get_rotation();
+
data.dirty&=~DIRTY_VECTORS;
}
return data.rotation;
}
-Vector3 Spatial::get_rotation_deg() const {
+Vector3 Spatial::get_rotation_in_degrees() const {
return get_rotation() * 180.0 / Math_PI;
}
@@ -415,14 +418,15 @@ Vector3 Spatial::get_rotation_deg() const {
Vector3 Spatial::_get_rotation_deg() const {
WARN_PRINT("Deprecated method Spatial._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
- return get_rotation_deg();
+ return get_rotation_in_degrees();
}
Vector3 Spatial::get_scale() const{
if (data.dirty&DIRTY_VECTORS) {
data.scale=data.local_transform.basis.get_scale();
- data.rotation=data.local_transform.basis.get_euler();
+ data.rotation=data.local_transform.basis.get_rotation();
+
data.dirty&=~DIRTY_VECTORS;
}
@@ -480,7 +484,7 @@ void Spatial::_update_gizmo() {
data.gizmo_dirty=false;
if (data.gizmo.is_valid()) {
- if (is_visible())
+ if (is_visible_in_tree())
data.gizmo->redraw();
else
data.gizmo->clear();
@@ -571,7 +575,7 @@ void Spatial::show() {
if (!is_inside_tree())
return;
- if (!data.parent || is_visible()) {
+ if (!data.parent || is_visible_in_tree()) {
_propagate_visibility_changed();
}
@@ -582,7 +586,7 @@ void Spatial::hide(){
if (!data.visible)
return;
- bool was_visible = is_visible();
+ bool was_visible = is_visible_in_tree();
data.visible=false;
if (!data.parent || was_visible) {
@@ -591,7 +595,7 @@ void Spatial::hide(){
}
}
-bool Spatial::is_visible() const{
+bool Spatial::is_visible_in_tree() const{
const Spatial *s=this;
@@ -606,21 +610,7 @@ bool Spatial::is_visible() const{
}
-bool Spatial::is_hidden() const{
-
- return !data.visible;
-}
-
-void Spatial::set_hidden(bool p_hidden) {
-
- if (data.visible != p_hidden) {
- return;
- }
-
- _set_visible_(!p_hidden);
-}
-
-void Spatial::_set_visible_(bool p_visible) {
+void Spatial::set_visible(bool p_visible) {
if (p_visible)
show();
@@ -628,9 +618,9 @@ void Spatial::_set_visible_(bool p_visible) {
hide();
}
-bool Spatial::_is_visible_() const {
+bool Spatial::is_visible() const {
- return !is_hidden();
+ return !data.visible;
}
void Spatial::rotate(const Vector3& p_normal,float p_radians) {
@@ -680,7 +670,7 @@ void Spatial::scale(const Vector3& p_ratio){
}
void Spatial::global_rotate(const Vector3& p_normal,float p_radians){
- Matrix3 rotation(p_normal,p_radians);
+ Basis rotation(p_normal,p_radians);
Transform t = get_global_transform();
t.basis= rotation * t.basis;
set_global_transform(t);
@@ -734,6 +724,14 @@ void Spatial::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, con
}
+void Spatial::set_notify_transform(bool p_enable) {
+ data.notify_transform=p_enable;
+}
+
+bool Spatial::is_transform_notification_enabled() const {
+ return data.notify_transform;
+}
+
void Spatial::set_notify_local_transform(bool p_enable) {
data.notify_local_transform=p_enable;
}
@@ -744,50 +742,50 @@ bool Spatial::is_local_transform_notification_enabled() const {
void Spatial::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_transform","local"), &Spatial::set_transform);
- ObjectTypeDB::bind_method(_MD("get_transform"), &Spatial::get_transform);
- ObjectTypeDB::bind_method(_MD("set_translation","translation"), &Spatial::set_translation);
- ObjectTypeDB::bind_method(_MD("get_translation"), &Spatial::get_translation);
- ObjectTypeDB::bind_method(_MD("set_rotation","rotation_rad"), &Spatial::set_rotation);
- ObjectTypeDB::bind_method(_MD("get_rotation"), &Spatial::get_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotation_deg","rotation_deg"), &Spatial::set_rotation_deg);
- ObjectTypeDB::bind_method(_MD("get_rotation_deg"), &Spatial::get_rotation_deg);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"), &Spatial::set_scale);
- ObjectTypeDB::bind_method(_MD("get_scale"), &Spatial::get_scale);
- ObjectTypeDB::bind_method(_MD("set_global_transform","global"), &Spatial::set_global_transform);
- ObjectTypeDB::bind_method(_MD("get_global_transform"), &Spatial::get_global_transform);
- ObjectTypeDB::bind_method(_MD("get_parent_spatial"), &Spatial::get_parent_spatial);
- ObjectTypeDB::bind_method(_MD("set_ignore_transform_notification","enabled"), &Spatial::set_ignore_transform_notification);
- ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"), &Spatial::set_as_toplevel);
- ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
- ObjectTypeDB::bind_method(_MD("get_world:World"), &Spatial::get_world);
+ ClassDB::bind_method(_MD("set_transform","local"), &Spatial::set_transform);
+ ClassDB::bind_method(_MD("get_transform"), &Spatial::get_transform);
+ ClassDB::bind_method(_MD("set_translation","translation"), &Spatial::set_translation);
+ ClassDB::bind_method(_MD("get_translation"), &Spatial::get_translation);
+ ClassDB::bind_method(_MD("set_rotation","rotation_rad"), &Spatial::set_rotation);
+ ClassDB::bind_method(_MD("get_rotation"), &Spatial::get_rotation);
+ ClassDB::bind_method(_MD("set_rotation_deg","rotation_deg"), &Spatial::set_rotation_in_degrees);
+ ClassDB::bind_method(_MD("get_rotation_deg"), &Spatial::get_rotation_in_degrees);
+ ClassDB::bind_method(_MD("set_scale","scale"), &Spatial::set_scale);
+ ClassDB::bind_method(_MD("get_scale"), &Spatial::get_scale);
+ ClassDB::bind_method(_MD("set_global_transform","global"), &Spatial::set_global_transform);
+ ClassDB::bind_method(_MD("get_global_transform"), &Spatial::get_global_transform);
+ ClassDB::bind_method(_MD("get_parent_spatial"), &Spatial::get_parent_spatial);
+ ClassDB::bind_method(_MD("set_ignore_transform_notification","enabled"), &Spatial::set_ignore_transform_notification);
+ ClassDB::bind_method(_MD("set_as_toplevel","enable"), &Spatial::set_as_toplevel);
+ ClassDB::bind_method(_MD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
+ ClassDB::bind_method(_MD("get_world:World"), &Spatial::get_world);
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotation_deg","rotation_deg"), &Spatial::_set_rotation_deg);
- ObjectTypeDB::bind_method(_MD("_get_rotation_deg"), &Spatial::_get_rotation_deg);
+ ClassDB::bind_method(_MD("_set_rotation_deg","rotation_deg"), &Spatial::_set_rotation_deg);
+ ClassDB::bind_method(_MD("_get_rotation_deg"), &Spatial::_get_rotation_deg);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method(_MD("_update_gizmo"), &Spatial::_update_gizmo);
- ObjectTypeDB::bind_method(_MD("_set_import_transform"), &Spatial::set_import_transform);
- ObjectTypeDB::bind_method(_MD("_get_import_transform"), &Spatial::get_import_transform);
+ ClassDB::bind_method(_MD("_update_gizmo"), &Spatial::_update_gizmo);
+ ClassDB::bind_method(_MD("_set_import_transform"), &Spatial::set_import_transform);
+ ClassDB::bind_method(_MD("_get_import_transform"), &Spatial::get_import_transform);
ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"_import_transform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_transform"),_SCS("_get_import_transform"));
#endif
- ObjectTypeDB::bind_method(_MD("update_gizmo"), &Spatial::update_gizmo);
- ObjectTypeDB::bind_method(_MD("set_gizmo","gizmo:SpatialGizmo"), &Spatial::set_gizmo);
- ObjectTypeDB::bind_method(_MD("get_gizmo:SpatialGizmo"), &Spatial::get_gizmo);
+ ClassDB::bind_method(_MD("update_gizmo"), &Spatial::update_gizmo);
+ ClassDB::bind_method(_MD("set_gizmo","gizmo:SpatialGizmo"), &Spatial::set_gizmo);
+ ClassDB::bind_method(_MD("get_gizmo:SpatialGizmo"), &Spatial::get_gizmo);
- ObjectTypeDB::bind_method(_MD("show"), &Spatial::show);
- ObjectTypeDB::bind_method(_MD("hide"), &Spatial::hide);
- ObjectTypeDB::bind_method(_MD("is_visible"), &Spatial::is_visible);
- ObjectTypeDB::bind_method(_MD("is_hidden"), &Spatial::is_hidden);
- ObjectTypeDB::bind_method(_MD("set_hidden","hidden"), &Spatial::set_hidden);
+ ClassDB::bind_method(_MD("set_visible"), &Spatial::set_visible);
+ ClassDB::bind_method(_MD("is_visible"), &Spatial::is_visible);
+ ClassDB::bind_method(_MD("is_visible_in_tree"), &Spatial::is_visible_in_tree);
+ ClassDB::bind_method(_MD("show"), &Spatial::show);
+ ClassDB::bind_method(_MD("hide"), &Spatial::hide);
- ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_);
- ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_);
+ ClassDB::bind_method(_MD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform);
+ ClassDB::bind_method(_MD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
- ObjectTypeDB::bind_method(_MD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform);
- ObjectTypeDB::bind_method(_MD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
+ ClassDB::bind_method(_MD("set_notify_transform","enable"), &Spatial::set_notify_transform);
+ ClassDB::bind_method(_MD("is_transform_notification_enabled"), &Spatial::is_transform_notification_enabled);
void rotate(const Vector3& p_normal,float p_radians);
void rotate_x(float p_radians);
@@ -798,18 +796,18 @@ void Spatial::_bind_methods() {
void global_rotate(const Vector3& p_normal,float p_radians);
void global_translate(const Vector3& p_offset);
- ObjectTypeDB::bind_method( _MD("rotate","normal","radians"),&Spatial::rotate );
- ObjectTypeDB::bind_method( _MD("global_rotate","normal","radians"),&Spatial::global_rotate );
- ObjectTypeDB::bind_method( _MD("rotate_x","radians"),&Spatial::rotate_x );
- ObjectTypeDB::bind_method( _MD("rotate_y","radians"),&Spatial::rotate_y );
- ObjectTypeDB::bind_method( _MD("rotate_z","radians"),&Spatial::rotate_z );
- ObjectTypeDB::bind_method( _MD("translate","offset"),&Spatial::translate );
- ObjectTypeDB::bind_method( _MD("global_translate","offset"),&Spatial::global_translate );
- ObjectTypeDB::bind_method( _MD("orthonormalize"),&Spatial::orthonormalize );
- ObjectTypeDB::bind_method( _MD("set_identity"),&Spatial::set_identity );
+ ClassDB::bind_method( _MD("rotate","normal","radians"),&Spatial::rotate );
+ ClassDB::bind_method( _MD("global_rotate","normal","radians"),&Spatial::global_rotate );
+ ClassDB::bind_method( _MD("rotate_x","radians"),&Spatial::rotate_x );
+ ClassDB::bind_method( _MD("rotate_y","radians"),&Spatial::rotate_y );
+ ClassDB::bind_method( _MD("rotate_z","radians"),&Spatial::rotate_z );
+ ClassDB::bind_method( _MD("translate","offset"),&Spatial::translate );
+ ClassDB::bind_method( _MD("global_translate","offset"),&Spatial::global_translate );
+ ClassDB::bind_method( _MD("orthonormalize"),&Spatial::orthonormalize );
+ ClassDB::bind_method( _MD("set_identity"),&Spatial::set_identity );
- ObjectTypeDB::bind_method( _MD("look_at","target","up"),&Spatial::look_at );
- ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Spatial::look_at_from_pos );
+ ClassDB::bind_method( _MD("look_at","target","up"),&Spatial::look_at );
+ ClassDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Spatial::look_at_from_pos );
BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );
BIND_CONSTANT( NOTIFICATION_ENTER_WORLD );
@@ -817,12 +815,15 @@ void Spatial::_bind_methods() {
BIND_CONSTANT( NOTIFICATION_VISIBILITY_CHANGED );
//ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/global",PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ), _SCS("set_global_transform"), _SCS("get_global_transform") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"transform/local",PROPERTY_HINT_NONE,""), _SCS("set_transform"), _SCS("get_transform") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/translation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_translation"), _SCS("get_translation") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_rotation_deg"), _SCS("get_rotation_deg") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/rotation_rad",PROPERTY_HINT_NONE,"",0), _SCS("set_rotation"), _SCS("get_rotation") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/scale",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_scale"), _SCS("get_scale") );
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"), _SCS("_is_visible_") );
+ ADD_GROUP("Transform","");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"transform",PROPERTY_HINT_NONE,""), _SCS("set_transform"), _SCS("get_transform") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"global_transform",PROPERTY_HINT_NONE,"",0), _SCS("set_global_transform"), _SCS("get_global_transform") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"translation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_translation"), _SCS("get_translation") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"rotation_deg",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_rotation_deg"), _SCS("get_rotation_deg") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"rotation",PROPERTY_HINT_NONE,"",0), _SCS("set_rotation"), _SCS("get_rotation") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"scale",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_scale"), _SCS("get_scale") );
+ ADD_GROUP("Visibility","");
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("set_visible"), _SCS("is_visible") );
//ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/local"), _SCS("set_transform"), _SCS("get_transform") );
ADD_SIGNAL( MethodInfo("visibility_changed" ) );
@@ -843,11 +844,13 @@ Spatial::Spatial() : xform_change(this)
data.viewport=NULL;
data.inside_world=false;
data.visible=true;
+
#ifdef TOOLS_ENABLED
data.gizmo_disabled=false;
data.gizmo_dirty=false;
#endif
data.notify_local_transform=false;
+ data.notify_transform=false;
data.parent=NULL;
data.C=NULL;
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index fdc9f95f0b..72daa472bd 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
class SpatialGizmo : public Reference {
- OBJ_TYPE(SpatialGizmo,Reference);
+ GDCLASS(SpatialGizmo,Reference);
public:
@@ -55,7 +55,7 @@ public:
class Spatial : public Node {
- OBJ_TYPE( Spatial, Node );
+ GDCLASS( Spatial, Node );
OBJ_CATEGORY("3D");
enum TransformDirty {
@@ -92,6 +92,7 @@ class Spatial : public Node {
bool ignore_notification;
bool notify_local_transform;
+ bool notify_transform;
bool visible;
@@ -126,8 +127,6 @@ protected:
void _notification(int p_what);
static void _bind_methods();
- void _set_visible_(bool p_visible);
- bool _is_visible_() const;
public:
enum {
@@ -146,12 +145,12 @@ public:
void set_translation(const Vector3& p_translation);
void set_rotation(const Vector3& p_euler_rad);
- void set_rotation_deg(const Vector3& p_euler_deg);
+ void set_rotation_in_degrees(const Vector3& p_euler_deg);
void set_scale(const Vector3& p_scale);
Vector3 get_translation() const;
Vector3 get_rotation() const;
- Vector3 get_rotation_deg() const;
+ Vector3 get_rotation_in_degrees() const;
Vector3 get_scale() const;
void set_transform(const Transform& p_transform);
@@ -184,17 +183,20 @@ public:
void look_at(const Vector3& p_target, const Vector3& p_up_normal);
void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
+ void set_notify_transform(bool p_enable);
+ bool is_transform_notification_enabled() const;
+
void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const;
void orthonormalize();
void set_identity();
+ void set_visible(bool p_visible);
+ bool is_visible() const;
void show();
void hide();
- bool is_visible() const;
- bool is_hidden() const;
- void set_hidden(bool p_hidden);
+ bool is_visible_in_tree() const;
#ifdef TOOLS_ENABLED
void set_import_transform(const Transform& p_transform) ;
diff --git a/scene/3d/spatial_indexer.cpp b/scene/3d/spatial_indexer.cpp
index d5be36b2cb..0cc6d1abd0 100644
--- a/scene/3d/spatial_indexer.cpp
+++ b/scene/3d/spatial_indexer.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -112,7 +112,7 @@ void SpatialIndexer::_update_pairs() {
void SpatialIndexer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_update_pairs"),&SpatialIndexer::_update_pairs);
+ ClassDB::bind_method(_MD("_update_pairs"),&SpatialIndexer::_update_pairs);
}
diff --git a/scene/3d/spatial_indexer.h b/scene/3d/spatial_indexer.h
index 13ce8badea..94c579ba23 100644
--- a/scene/3d/spatial_indexer.h
+++ b/scene/3d/spatial_indexer.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@ class ProximityArea;
class SpatialIndexer : public Object {
- OBJ_TYPE( SpatialIndexer, Object );
+ GDCLASS( SpatialIndexer, Object );
template<class T>
struct TK {
diff --git a/scene/3d/spatial_player.cpp b/scene/3d/spatial_player.cpp
index c7cf03e284..6a368d771a 100644
--- a/scene/3d/spatial_player.cpp
+++ b/scene/3d/spatial_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -88,151 +88,11 @@ bool SpatialPlayer::_can_gizmo_scale() const {
return false;
}
-RES SpatialPlayer::_get_gizmo_geometry() const {
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.0,0.6,0.7,0.05) );
- mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
- mat->set_blend_mode( Material::BLEND_MODE_ADD );
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
-
- surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- surface_tool->set_material(mat);
-
- int sides=16;
- int sections=24;
-
-// float len=1;
- float deg=Math::deg2rad(params[PARAM_EMISSION_CONE_DEGREES]);
- if (deg==180)
- deg=179.5;
-
- Vector3 to=Vector3(0,0,-1);
-
- for(int j=0;j<sections;j++) {
-
- Vector3 p1=Matrix3(Vector3(1,0,0),deg*j/sections).xform(to);
- Vector3 p2=Matrix3(Vector3(1,0,0),deg*(j+1)/sections).xform(to);
-
- for(int i=0;i<sides;i++) {
-
- Vector3 p1r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p1);
- Vector3 p1s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p1);
- Vector3 p2s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p2);
- Vector3 p2r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p2);
-
- surface_tool->add_normal(p1r.normalized());
- surface_tool->add_vertex(p1r);
- surface_tool->add_normal(p1s.normalized());
- surface_tool->add_vertex(p1s);
- surface_tool->add_normal(p2s.normalized());
- surface_tool->add_vertex(p2s);
-
- surface_tool->add_normal(p1r.normalized());
- surface_tool->add_vertex(p1r);
- surface_tool->add_normal(p2s.normalized());
- surface_tool->add_vertex(p2s);
- surface_tool->add_normal(p2r.normalized());
- surface_tool->add_vertex(p2r);
-
- if (j==sections-1) {
-
- surface_tool->add_normal(p2r.normalized());
- surface_tool->add_vertex(p2r);
- surface_tool->add_normal(p2s.normalized());
- surface_tool->add_vertex(p2s);
- surface_tool->add_normal(Vector3(0,0,1));
- surface_tool->add_vertex(Vector3());
- }
- }
- }
-
-
- Ref<Mesh> mesh = surface_tool->commit();
-
- Ref<FixedMaterial> mat_speaker( memnew( FixedMaterial ));
-
- mat_speaker->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.3,0.3,0.6) );
- mat_speaker->set_parameter( FixedMaterial::PARAM_SPECULAR,Color(0.5,0.5,0.6) );
- //mat_speaker->set_blend_mode( Material::BLEND_MODE_MIX);
- //mat_speaker->set_flag(Material::FLAG_DOUBLE_SIDED,false);
- //mat_speaker->set_flag(Material::FLAG_UNSHADED,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- surface_tool->set_material(mat_speaker);
-
-// float radius=1;
-
-
- const int speaker_points=8;
- Vector3 speaker[speaker_points]={
- Vector3(0,0,1)*0.15,
- Vector3(1,1,1)*0.15,
- Vector3(1,1,0)*0.15,
- Vector3(2,2,-1)*0.15,
- Vector3(1,1,-1)*0.15,
- Vector3(0.8,0.8,-1.2)*0.15,
- Vector3(0.5,0.5,-1.4)*0.15,
- Vector3(0.0,0.0,-1.6)*0.15
- };
-
- int speaker_sides=10;
-
-
- for(int i = 0; i < speaker_sides ; i++) {
-
-
- Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/speaker_sides);
- Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/speaker_sides);
-
-
- for(int j=0;j<speaker_points-1;j++) {
-
- Vector3 points[4]={
- ma.xform(speaker[j]),
- mb.xform(speaker[j]),
- mb.xform(speaker[j+1]),
- ma.xform(speaker[j+1]),
- };
-
- Vector3 n = -Plane(points[0],points[1],points[2]).normal;
-
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[0]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[2]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[1]);
-
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[0]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[3]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[2]);
-
-
- }
-
-
- }
-
-
- return surface_tool->commit(mesh);
-
-}
-
-
void SpatialPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SpatialPlayer::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SpatialPlayer::get_param);
+ ClassDB::bind_method(_MD("set_param","param","value"),&SpatialPlayer::set_param);
+ ClassDB::bind_method(_MD("get_param","param"),&SpatialPlayer::get_param);
BIND_CONSTANT( PARAM_VOLUME_DB );
BIND_CONSTANT( PARAM_PITCH_SCALE );
@@ -243,13 +103,15 @@ void SpatialPlayer::_bind_methods() {
BIND_CONSTANT( PARAM_EMISSION_CONE_ATTENUATION_DB );
BIND_CONSTANT( PARAM_MAX );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/min_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/max_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/emission_cone/degrees",PROPERTY_HINT_RANGE, "0,180,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_DEGREES);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/emission_cone/attenuation_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_ATTENUATION_DB);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
+ ADD_GROUP("Attenuation","attenuation_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_min_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_max_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
+ ADD_GROUP("Emission Cone","emission_cone_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "emission_cone_degrees",PROPERTY_HINT_RANGE, "0,180,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_DEGREES);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "emission_cone_attenuation_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_ATTENUATION_DB);
}
@@ -263,6 +125,7 @@ SpatialPlayer::SpatialPlayer() {
params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
params[PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled
params[PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation
+ set_notify_transform(true);
}
diff --git a/scene/3d/spatial_player.h b/scene/3d/spatial_player.h
index 5a8687b854..16671a0cb5 100644
--- a/scene/3d/spatial_player.h
+++ b/scene/3d/spatial_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
class SpatialPlayer : public Spatial {
- OBJ_TYPE(SpatialPlayer,Spatial);
+ GDCLASS(SpatialPlayer,Spatial);
public:
@@ -60,7 +60,7 @@ private:
RID source_rid;
virtual bool _can_gizmo_scale() const;
- virtual RES _get_gizmo_geometry() const;
+
protected:
diff --git a/scene/3d/spatial_sample_player.cpp b/scene/3d/spatial_sample_player.cpp
index 4c5b2c240e..3e1c0e9947 100644
--- a/scene/3d/spatial_sample_player.cpp
+++ b/scene/3d/spatial_sample_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -204,26 +204,26 @@ String SpatialSamplePlayer::get_configuration_warning() const {
void SpatialSamplePlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SpatialSamplePlayer::set_sample_library);
- ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SpatialSamplePlayer::get_sample_library);
+ ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SpatialSamplePlayer::set_sample_library);
+ ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SpatialSamplePlayer::get_sample_library);
- ObjectTypeDB::bind_method(_MD("set_polyphony","voices"),&SpatialSamplePlayer::set_polyphony);
- ObjectTypeDB::bind_method(_MD("get_polyphony"),&SpatialSamplePlayer::get_polyphony);
+ ClassDB::bind_method(_MD("set_polyphony","voices"),&SpatialSamplePlayer::set_polyphony);
+ ClassDB::bind_method(_MD("get_polyphony"),&SpatialSamplePlayer::get_polyphony);
- ObjectTypeDB::bind_method(_MD("play","sample","voice"),&SpatialSamplePlayer::play,DEFVAL(NEXT_VOICE));
+ ClassDB::bind_method(_MD("play","sample","voice"),&SpatialSamplePlayer::play,DEFVAL(NEXT_VOICE));
//voices,DEV
- ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SpatialSamplePlayer::voice_set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SpatialSamplePlayer::voice_set_volume_scale_db);
+ ClassDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SpatialSamplePlayer::voice_set_pitch_scale);
+ ClassDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SpatialSamplePlayer::voice_set_volume_scale_db);
- ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SpatialSamplePlayer::is_voice_active);
- ObjectTypeDB::bind_method(_MD("stop_voice","voice"),&SpatialSamplePlayer::stop_voice);
- ObjectTypeDB::bind_method(_MD("stop_all"),&SpatialSamplePlayer::stop_all);
+ ClassDB::bind_method(_MD("is_voice_active","voice"),&SpatialSamplePlayer::is_voice_active);
+ ClassDB::bind_method(_MD("stop_voice","voice"),&SpatialSamplePlayer::stop_voice);
+ ClassDB::bind_method(_MD("stop_all"),&SpatialSamplePlayer::stop_all);
BIND_CONSTANT( INVALID_VOICE );
BIND_CONSTANT( NEXT_VOICE );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
}
diff --git a/scene/3d/spatial_sample_player.h b/scene/3d/spatial_sample_player.h
index 257f6d0dc3..d30ff6e908 100644
--- a/scene/3d/spatial_sample_player.h
+++ b/scene/3d/spatial_sample_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SpatialSamplePlayer : public SpatialPlayer {
- OBJ_TYPE(SpatialSamplePlayer,SpatialPlayer);
+ GDCLASS(SpatialSamplePlayer,SpatialPlayer);
public:
enum {
diff --git a/scene/3d/spatial_stream_player.cpp b/scene/3d/spatial_stream_player.cpp
index 11debb9bce..1f9765c1d3 100644
--- a/scene/3d/spatial_stream_player.cpp
+++ b/scene/3d/spatial_stream_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -153,10 +153,12 @@ void SpatialStreamPlayer::play(float p_from_offset) {
SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),&internal_stream);
-// AudioServer::get_singleton()->stream_set_active(stream_rid,true);
-// AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-// if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
-// set_idle_process(true);
+ /*
+ AudioServer::get_singleton()->stream_set_active(stream_rid,true);
+ AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
+ if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
+ set_idle_process(true);
+ */
}
@@ -289,8 +291,10 @@ bool SpatialStreamPlayer::has_autoplay() const {
void SpatialStreamPlayer::set_paused(bool p_paused) {
paused=p_paused;
- //if (stream.is_valid())
- // stream->set_paused(p_paused);
+ /*
+ if (stream.is_valid())
+ stream->set_paused(p_paused);
+ */
}
bool SpatialStreamPlayer::is_paused() const {
@@ -329,54 +333,54 @@ int SpatialStreamPlayer::get_buffering_msec() const{
void SpatialStreamPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:AudioStream"),&SpatialStreamPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:AudioStream"),&SpatialStreamPlayer::get_stream);
+ ClassDB::bind_method(_MD("set_stream","stream:AudioStream"),&SpatialStreamPlayer::set_stream);
+ ClassDB::bind_method(_MD("get_stream:AudioStream"),&SpatialStreamPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play","offset"),&SpatialStreamPlayer::play,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("stop"),&SpatialStreamPlayer::stop);
+ ClassDB::bind_method(_MD("play","offset"),&SpatialStreamPlayer::play,DEFVAL(0));
+ ClassDB::bind_method(_MD("stop"),&SpatialStreamPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&SpatialStreamPlayer::is_playing);
+ ClassDB::bind_method(_MD("is_playing"),&SpatialStreamPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&SpatialStreamPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&SpatialStreamPlayer::is_paused);
+ ClassDB::bind_method(_MD("set_paused","paused"),&SpatialStreamPlayer::set_paused);
+ ClassDB::bind_method(_MD("is_paused"),&SpatialStreamPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&SpatialStreamPlayer::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&SpatialStreamPlayer::has_loop);
+ ClassDB::bind_method(_MD("set_loop","enabled"),&SpatialStreamPlayer::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&SpatialStreamPlayer::has_loop);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&SpatialStreamPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&SpatialStreamPlayer::get_volume);
+ ClassDB::bind_method(_MD("set_volume","volume"),&SpatialStreamPlayer::set_volume);
+ ClassDB::bind_method(_MD("get_volume"),&SpatialStreamPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&SpatialStreamPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&SpatialStreamPlayer::get_volume_db);
+ ClassDB::bind_method(_MD("set_volume_db","db"),&SpatialStreamPlayer::set_volume_db);
+ ClassDB::bind_method(_MD("get_volume_db"),&SpatialStreamPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&SpatialStreamPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&SpatialStreamPlayer::get_buffering_msec);
+ ClassDB::bind_method(_MD("set_buffering_msec","msec"),&SpatialStreamPlayer::set_buffering_msec);
+ ClassDB::bind_method(_MD("get_buffering_msec"),&SpatialStreamPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("set_loop_restart_time","secs"),&SpatialStreamPlayer::set_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_loop_restart_time"),&SpatialStreamPlayer::get_loop_restart_time);
+ ClassDB::bind_method(_MD("set_loop_restart_time","secs"),&SpatialStreamPlayer::set_loop_restart_time);
+ ClassDB::bind_method(_MD("get_loop_restart_time"),&SpatialStreamPlayer::get_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&SpatialStreamPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&SpatialStreamPlayer::get_loop_count);
+ ClassDB::bind_method(_MD("get_stream_name"),&SpatialStreamPlayer::get_stream_name);
+ ClassDB::bind_method(_MD("get_loop_count"),&SpatialStreamPlayer::get_loop_count);
- ObjectTypeDB::bind_method(_MD("get_pos"),&SpatialStreamPlayer::get_pos);
- ObjectTypeDB::bind_method(_MD("seek_pos","time"),&SpatialStreamPlayer::seek_pos);
+ ClassDB::bind_method(_MD("get_pos"),&SpatialStreamPlayer::get_pos);
+ ClassDB::bind_method(_MD("seek_pos","time"),&SpatialStreamPlayer::seek_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&SpatialStreamPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&SpatialStreamPlayer::has_autoplay);
+ ClassDB::bind_method(_MD("set_autoplay","enabled"),&SpatialStreamPlayer::set_autoplay);
+ ClassDB::bind_method(_MD("has_autoplay"),&SpatialStreamPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("get_length"),&SpatialStreamPlayer::get_length);
+ ClassDB::bind_method(_MD("get_length"),&SpatialStreamPlayer::get_length);
- ObjectTypeDB::bind_method(_MD("_set_play","play"),&SpatialStreamPlayer::_set_play);
- ObjectTypeDB::bind_method(_MD("_get_play"),&SpatialStreamPlayer::_get_play);
+ ClassDB::bind_method(_MD("_set_play","play"),&SpatialStreamPlayer::_set_play);
+ ClassDB::bind_method(_MD("_get_play"),&SpatialStreamPlayer::_get_play);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
}
diff --git a/scene/3d/spatial_stream_player.h b/scene/3d/spatial_stream_player.h
index 0732b3fc10..27533d3f6e 100644
--- a/scene/3d/spatial_stream_player.h
+++ b/scene/3d/spatial_stream_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SpatialStreamPlayer : public SpatialPlayer {
- OBJ_TYPE(SpatialStreamPlayer,SpatialPlayer);
+ GDCLASS(SpatialStreamPlayer,SpatialPlayer);
_THREAD_SAFE_CLASS_
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 74cab30b17..9f0c91c4b8 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -207,13 +207,13 @@ void SpriteBase3D::_queue_update(){
}
-AABB SpriteBase3D::get_aabb() const {
+Rect3 SpriteBase3D::get_aabb() const {
return aabb;
}
-DVector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+ return PoolVector<Face3>();
}
@@ -246,41 +246,41 @@ SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const{
void SpriteBase3D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&SpriteBase3D::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&SpriteBase3D::is_centered);
+ ClassDB::bind_method(_MD("set_centered","centered"),&SpriteBase3D::set_centered);
+ ClassDB::bind_method(_MD("is_centered"),&SpriteBase3D::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&SpriteBase3D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&SpriteBase3D::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&SpriteBase3D::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&SpriteBase3D::get_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&SpriteBase3D::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&SpriteBase3D::is_flipped_h);
+ ClassDB::bind_method(_MD("set_flip_h","flip_h"),&SpriteBase3D::set_flip_h);
+ ClassDB::bind_method(_MD("is_flipped_h"),&SpriteBase3D::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&SpriteBase3D::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&SpriteBase3D::is_flipped_v);
+ ClassDB::bind_method(_MD("set_flip_v","flip_v"),&SpriteBase3D::set_flip_v);
+ ClassDB::bind_method(_MD("is_flipped_v"),&SpriteBase3D::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&SpriteBase3D::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&SpriteBase3D::get_modulate);
+ ClassDB::bind_method(_MD("set_modulate","modulate"),&SpriteBase3D::set_modulate);
+ ClassDB::bind_method(_MD("get_modulate"),&SpriteBase3D::get_modulate);
- ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&SpriteBase3D::set_opacity);
- ObjectTypeDB::bind_method(_MD("get_opacity"),&SpriteBase3D::get_opacity);
+ ClassDB::bind_method(_MD("set_opacity","opacity"),&SpriteBase3D::set_opacity);
+ ClassDB::bind_method(_MD("get_opacity"),&SpriteBase3D::get_opacity);
- ObjectTypeDB::bind_method(_MD("set_pixel_size","pixel_size"),&SpriteBase3D::set_pixel_size);
- ObjectTypeDB::bind_method(_MD("get_pixel_size"),&SpriteBase3D::get_pixel_size);
+ ClassDB::bind_method(_MD("set_pixel_size","pixel_size"),&SpriteBase3D::set_pixel_size);
+ ClassDB::bind_method(_MD("get_pixel_size"),&SpriteBase3D::get_pixel_size);
- ObjectTypeDB::bind_method(_MD("set_axis","axis"),&SpriteBase3D::set_axis);
- ObjectTypeDB::bind_method(_MD("get_axis"),&SpriteBase3D::get_axis);
+ ClassDB::bind_method(_MD("set_axis","axis"),&SpriteBase3D::set_axis);
+ ClassDB::bind_method(_MD("get_axis"),&SpriteBase3D::get_axis);
- ObjectTypeDB::bind_method(_MD("set_draw_flag","flag","enabled"),&SpriteBase3D::set_draw_flag);
- ObjectTypeDB::bind_method(_MD("get_draw_flag","flag"),&SpriteBase3D::get_draw_flag);
+ ClassDB::bind_method(_MD("set_draw_flag","flag","enabled"),&SpriteBase3D::set_draw_flag);
+ ClassDB::bind_method(_MD("get_draw_flag","flag"),&SpriteBase3D::get_draw_flag);
- ObjectTypeDB::bind_method(_MD("set_alpha_cut_mode","mode"),&SpriteBase3D::set_alpha_cut_mode);
- ObjectTypeDB::bind_method(_MD("get_alpha_cut_mode"),&SpriteBase3D::get_alpha_cut_mode);
+ ClassDB::bind_method(_MD("set_alpha_cut_mode","mode"),&SpriteBase3D::set_alpha_cut_mode);
+ ClassDB::bind_method(_MD("get_alpha_cut_mode"),&SpriteBase3D::get_alpha_cut_mode);
- ObjectTypeDB::bind_method(_MD("get_item_rect"),&SpriteBase3D::get_item_rect);
+ ClassDB::bind_method(_MD("get_item_rect"),&SpriteBase3D::get_item_rect);
- ObjectTypeDB::bind_method(_MD("_queue_update"),&SpriteBase3D::_queue_update);
- ObjectTypeDB::bind_method(_MD("_im_update"),&SpriteBase3D::_im_update);
+ ClassDB::bind_method(_MD("_queue_update"),&SpriteBase3D::_queue_update);
+ ClassDB::bind_method(_MD("_im_update"),&SpriteBase3D::_im_update);
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
@@ -291,9 +291,10 @@ void SpriteBase3D::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::REAL, "opacity",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity"));
ADD_PROPERTY( PropertyInfo( Variant::REAL, "pixel_size",PROPERTY_HINT_RANGE,"0.0001,128,0.0001"), _SCS("set_pixel_size"),_SCS("get_pixel_size"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "axis",PROPERTY_HINT_ENUM,"X-Axis,Y-Axis,Z-Axis"), _SCS("set_axis"),_SCS("get_axis"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "flags/transparent"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_TRANSPARENT);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "flags/shaded"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_SHADED);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "flags/alpha_cut",PROPERTY_HINT_ENUM,"Disabled,Discard,Opaque Pre-Pass"), _SCS("set_alpha_cut_mode"),_SCS("get_alpha_cut_mode"));
+ ADD_GROUP("Flags","");
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "transparent"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_TRANSPARENT);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "shaded"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_SHADED);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "alpha_cut",PROPERTY_HINT_ENUM,"Disabled,Discard,Opaque Pre-Pass"), _SCS("set_alpha_cut_mode"),_SCS("get_alpha_cut_mode"));
BIND_CONSTANT( FLAG_TRANSPARENT );
@@ -444,7 +445,7 @@ void Sprite3D::_draw() {
}
}
- AABB aabb;
+ Rect3 aabb;
for(int i=0;i<4;i++) {
VS::get_singleton()->immediate_normal(immediate,normal);
@@ -562,8 +563,10 @@ Rect2 Sprite3D::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
Size2i s;
@@ -598,23 +601,23 @@ void Sprite3D::_validate_property(PropertyInfo& property) const {
void Sprite3D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite3D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Sprite3D::get_texture);
+ ClassDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite3D::set_texture);
+ ClassDB::bind_method(_MD("get_texture:Texture"),&Sprite3D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_region","enabled"),&Sprite3D::set_region);
- ObjectTypeDB::bind_method(_MD("is_region"),&Sprite3D::is_region);
+ ClassDB::bind_method(_MD("set_region","enabled"),&Sprite3D::set_region);
+ ClassDB::bind_method(_MD("is_region"),&Sprite3D::is_region);
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Sprite3D::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Sprite3D::get_region_rect);
+ ClassDB::bind_method(_MD("set_region_rect","rect"),&Sprite3D::set_region_rect);
+ ClassDB::bind_method(_MD("get_region_rect"),&Sprite3D::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&Sprite3D::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&Sprite3D::get_frame);
+ ClassDB::bind_method(_MD("set_frame","frame"),&Sprite3D::set_frame);
+ ClassDB::bind_method(_MD("get_frame"),&Sprite3D::get_frame);
- ObjectTypeDB::bind_method(_MD("set_vframes","vframes"),&Sprite3D::set_vframes);
- ObjectTypeDB::bind_method(_MD("get_vframes"),&Sprite3D::get_vframes);
+ ClassDB::bind_method(_MD("set_vframes","vframes"),&Sprite3D::set_vframes);
+ ClassDB::bind_method(_MD("get_vframes"),&Sprite3D::get_vframes);
- ObjectTypeDB::bind_method(_MD("set_hframes","hframes"),&Sprite3D::set_hframes);
- ObjectTypeDB::bind_method(_MD("get_hframes"),&Sprite3D::get_hframes);
+ ClassDB::bind_method(_MD("set_hframes","hframes"),&Sprite3D::set_hframes);
+ ClassDB::bind_method(_MD("get_hframes"),&Sprite3D::get_hframes);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes"));
@@ -761,10 +764,10 @@ void AnimatedSprite3D::_draw() {
void AnimatedSprite3D::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
- ObjectTypeDB::bind_method(_MD("get_sprite_frames:Texture"),&AnimatedSprite3D::get_sprite_frames);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
+ ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
+ ClassDB::bind_method(_MD("get_sprite_frames:Texture"),&AnimatedSprite3D::get_sprite_frames);
+ ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
+ ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
@@ -960,7 +963,7 @@ void AnimatedSprite3D::_draw() {
}
}
- AABB aabb;
+ Rect3 aabb;
for(int i=0;i<4;i++) {
VS::get_singleton()->immediate_normal(immediate,normal);
@@ -1035,7 +1038,7 @@ void AnimatedSprite3D::_validate_property(PropertyInfo& property) const {
void AnimatedSprite3D::_notification(int p_what) {
switch(p_what) {
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (frames.is_null())
return;
@@ -1129,7 +1132,7 @@ void AnimatedSprite3D::_notification(int p_what) {
//texture->draw_rect(ci,dst_rect,false,modulate);
texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate);
-// VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
+ //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
} break;
#endif
@@ -1238,7 +1241,7 @@ void AnimatedSprite3D::_set_playing(bool p_playing) {
return;
playing=p_playing;
_reset_timeout();
- set_process(playing);
+ set_process_internal(playing);
}
bool AnimatedSprite3D::_is_playing() const {
@@ -1309,24 +1312,24 @@ String AnimatedSprite3D::get_configuration_warning() const {
void AnimatedSprite3D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
- ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite3D::get_sprite_frames);
+ ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
+ ClassDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite3D::get_sprite_frames);
- ObjectTypeDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite3D::set_animation);
- ObjectTypeDB::bind_method(_MD("get_animation"),&AnimatedSprite3D::get_animation);
+ ClassDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite3D::set_animation);
+ ClassDB::bind_method(_MD("get_animation"),&AnimatedSprite3D::get_animation);
- ObjectTypeDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite3D::_set_playing);
- ObjectTypeDB::bind_method(_MD("_is_playing"),&AnimatedSprite3D::_is_playing);
+ ClassDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite3D::_set_playing);
+ ClassDB::bind_method(_MD("_is_playing"),&AnimatedSprite3D::_is_playing);
- ObjectTypeDB::bind_method(_MD("play","anim"),&AnimatedSprite3D::play,DEFVAL(StringName()));
- ObjectTypeDB::bind_method(_MD("stop"),&AnimatedSprite3D::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AnimatedSprite3D::is_playing);
+ ClassDB::bind_method(_MD("play","anim"),&AnimatedSprite3D::play,DEFVAL(StringName()));
+ ClassDB::bind_method(_MD("stop"),&AnimatedSprite3D::stop);
+ ClassDB::bind_method(_MD("is_playing"),&AnimatedSprite3D::is_playing);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
+ ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
+ ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
- ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite3D::_res_changed);
+ ClassDB::bind_method(_MD("_res_changed"),&AnimatedSprite3D::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 31f8ec020f..a14ce40495 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SpriteBase3D : public GeometryInstance {
- OBJ_TYPE(SpriteBase3D,GeometryInstance);
+ GDCLASS(SpriteBase3D,GeometryInstance);
public:
enum DrawFlags {
@@ -73,7 +73,7 @@ private:
Vector3::Axis axis;
float pixel_size;
- AABB aabb;
+ Rect3 aabb;
RID immediate;
@@ -91,7 +91,7 @@ protected:
void _notification(int p_what);
static void _bind_methods();
virtual void _draw()=0;
- _FORCE_INLINE_ void set_aabb(const AABB& p_aabb) { aabb=p_aabb; }
+ _FORCE_INLINE_ void set_aabb(const Rect3& p_aabb) { aabb=p_aabb; }
_FORCE_INLINE_ RID& get_immediate() { return immediate; }
void _queue_update();
public:
@@ -134,8 +134,8 @@ public:
virtual Rect2 get_item_rect() const=0;
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
SpriteBase3D();
~SpriteBase3D();
@@ -144,7 +144,7 @@ public:
class Sprite3D : public SpriteBase3D {
- OBJ_TYPE(Sprite3D,SpriteBase3D);
+ GDCLASS(Sprite3D,SpriteBase3D);
Ref<Texture> texture;
@@ -185,13 +185,13 @@ public:
virtual Rect2 get_item_rect() const;
Sprite3D();
-// ~Sprite3D();
+ //~Sprite3D();
};
#if 0
class AnimatedSprite3D : public SpriteBase3D {
- OBJ_TYPE(AnimatedSprite3D,SpriteBase3D);
+ GDCLASS(AnimatedSprite3D,SpriteBase3D);
Ref<SpriteFrames> frames;
@@ -215,7 +215,7 @@ public:
virtual Rect2 get_item_rect() const;
AnimatedSprite3D();
-// ~AnimatedSprite3D();
+ //~AnimatedSprite3D();
};
#endif
@@ -224,7 +224,7 @@ public:
class AnimatedSprite3D : public SpriteBase3D {
- OBJ_TYPE(AnimatedSprite3D,SpriteBase3D);
+ GDCLASS(AnimatedSprite3D,SpriteBase3D);
Ref<SpriteFrames> frames;
bool playing;
diff --git a/scene/3d/test_cube.cpp b/scene/3d/test_cube.cpp
index 6440d95d55..c52e596032 100644
--- a/scene/3d/test_cube.cpp
+++ b/scene/3d/test_cube.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,13 +31,13 @@
-AABB TestCube::get_aabb() const {
+Rect3 TestCube::get_aabb() const {
- return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
+ return Rect3( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
}
-DVector<Face3> TestCube::get_faces(uint32_t p_usage_flags) const {
+PoolVector<Face3> TestCube::get_faces(uint32_t p_usage_flags) const {
- return DVector<Face3>();
+ return PoolVector<Face3>();
}
diff --git a/scene/3d/test_cube.h b/scene/3d/test_cube.h
index 332276ab89..4860bacd8d 100644
--- a/scene/3d/test_cube.h
+++ b/scene/3d/test_cube.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,15 +39,15 @@
*/
class TestCube : public GeometryInstance {
- OBJ_TYPE( TestCube, GeometryInstance );
+ GDCLASS( TestCube, GeometryInstance );
RID instance;
public:
- virtual AABB get_aabb() const;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Rect3 get_aabb() const;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
TestCube();
~TestCube();
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index 7c7957640f..a3f05f719d 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,8 +47,8 @@ public:
btVehicleJacobianEntry() {};
//constraint between two different rigidbodies
btVehicleJacobianEntry(
- const Matrix3& world2A,
- const Matrix3& world2B,
+ const Basis& world2A,
+ const Basis& world2B,
const Vector3& rel_pos1,
const Vector3& rel_pos2,
const Vector3& jointAxis,
@@ -232,48 +232,52 @@ float VehicleWheel::get_friction_slip() const{
void VehicleWheel::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","length"),&VehicleWheel::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&VehicleWheel::get_radius);
+ ClassDB::bind_method(_MD("set_radius","length"),&VehicleWheel::set_radius);
+ ClassDB::bind_method(_MD("get_radius"),&VehicleWheel::get_radius);
- ObjectTypeDB::bind_method(_MD("set_suspension_rest_length","length"),&VehicleWheel::set_suspension_rest_length);
- ObjectTypeDB::bind_method(_MD("get_suspension_rest_length"),&VehicleWheel::get_suspension_rest_length);
+ ClassDB::bind_method(_MD("set_suspension_rest_length","length"),&VehicleWheel::set_suspension_rest_length);
+ ClassDB::bind_method(_MD("get_suspension_rest_length"),&VehicleWheel::get_suspension_rest_length);
- ObjectTypeDB::bind_method(_MD("set_suspension_travel","length"),&VehicleWheel::set_suspension_travel);
- ObjectTypeDB::bind_method(_MD("get_suspension_travel"),&VehicleWheel::get_suspension_travel);
+ ClassDB::bind_method(_MD("set_suspension_travel","length"),&VehicleWheel::set_suspension_travel);
+ ClassDB::bind_method(_MD("get_suspension_travel"),&VehicleWheel::get_suspension_travel);
- ObjectTypeDB::bind_method(_MD("set_suspension_stiffness","length"),&VehicleWheel::set_suspension_stiffness);
- ObjectTypeDB::bind_method(_MD("get_suspension_stiffness"),&VehicleWheel::get_suspension_stiffness);
+ ClassDB::bind_method(_MD("set_suspension_stiffness","length"),&VehicleWheel::set_suspension_stiffness);
+ ClassDB::bind_method(_MD("get_suspension_stiffness"),&VehicleWheel::get_suspension_stiffness);
- ObjectTypeDB::bind_method(_MD("set_suspension_max_force","length"),&VehicleWheel::set_suspension_max_force);
- ObjectTypeDB::bind_method(_MD("get_suspension_max_force"),&VehicleWheel::get_suspension_max_force);
+ ClassDB::bind_method(_MD("set_suspension_max_force","length"),&VehicleWheel::set_suspension_max_force);
+ ClassDB::bind_method(_MD("get_suspension_max_force"),&VehicleWheel::get_suspension_max_force);
- ObjectTypeDB::bind_method(_MD("set_damping_compression","length"),&VehicleWheel::set_damping_compression);
- ObjectTypeDB::bind_method(_MD("get_damping_compression"),&VehicleWheel::get_damping_compression);
+ ClassDB::bind_method(_MD("set_damping_compression","length"),&VehicleWheel::set_damping_compression);
+ ClassDB::bind_method(_MD("get_damping_compression"),&VehicleWheel::get_damping_compression);
- ObjectTypeDB::bind_method(_MD("set_damping_relaxation","length"),&VehicleWheel::set_damping_relaxation);
- ObjectTypeDB::bind_method(_MD("get_damping_relaxation"),&VehicleWheel::get_damping_relaxation);
+ ClassDB::bind_method(_MD("set_damping_relaxation","length"),&VehicleWheel::set_damping_relaxation);
+ ClassDB::bind_method(_MD("get_damping_relaxation"),&VehicleWheel::get_damping_relaxation);
- ObjectTypeDB::bind_method(_MD("set_use_as_traction","enable"),&VehicleWheel::set_use_as_traction);
- ObjectTypeDB::bind_method(_MD("is_used_as_traction"),&VehicleWheel::is_used_as_traction);
+ ClassDB::bind_method(_MD("set_use_as_traction","enable"),&VehicleWheel::set_use_as_traction);
+ ClassDB::bind_method(_MD("is_used_as_traction"),&VehicleWheel::is_used_as_traction);
- ObjectTypeDB::bind_method(_MD("set_use_as_steering","enable"),&VehicleWheel::set_use_as_steering);
- ObjectTypeDB::bind_method(_MD("is_used_as_steering"),&VehicleWheel::is_used_as_steering);
+ ClassDB::bind_method(_MD("set_use_as_steering","enable"),&VehicleWheel::set_use_as_steering);
+ ClassDB::bind_method(_MD("is_used_as_steering"),&VehicleWheel::is_used_as_steering);
- ObjectTypeDB::bind_method(_MD("set_friction_slip","length"),&VehicleWheel::set_friction_slip);
- ObjectTypeDB::bind_method(_MD("get_friction_slip"),&VehicleWheel::get_friction_slip);
+ ClassDB::bind_method(_MD("set_friction_slip","length"),&VehicleWheel::set_friction_slip);
+ ClassDB::bind_method(_MD("get_friction_slip"),&VehicleWheel::get_friction_slip);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"type/traction"),_SCS("set_use_as_traction"),_SCS("is_used_as_traction"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"type/steering"),_SCS("set_use_as_steering"),_SCS("is_used_as_steering"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel/radius"),_SCS("set_radius"),_SCS("get_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel/rest_length"),_SCS("set_suspension_rest_length"),_SCS("get_suspension_rest_length"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel/friction_slip"),_SCS("set_friction_slip"),_SCS("get_friction_slip"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension/travel"),_SCS("set_suspension_travel"),_SCS("get_suspension_travel"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension/stiffness"),_SCS("set_suspension_stiffness"),_SCS("get_suspension_stiffness"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension/max_force"),_SCS("set_suspension_max_force"),_SCS("get_suspension_max_force"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping/compression"),_SCS("set_damping_compression"),_SCS("get_damping_compression"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping/relaxation"),_SCS("set_damping_relaxation"),_SCS("get_damping_relaxation"));
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_as_traction"),_SCS("set_use_as_traction"),_SCS("is_used_as_traction"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_as_steering"),_SCS("set_use_as_steering"),_SCS("is_used_as_steering"));
+ ADD_GROUP("Wheel","wheel_");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_radius"),_SCS("set_radius"),_SCS("get_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_rest_length"),_SCS("set_suspension_rest_length"),_SCS("get_suspension_rest_length"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_friction_slip"),_SCS("set_friction_slip"),_SCS("get_friction_slip"));
+ ADD_GROUP("Suspension","suspension_");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_travel"),_SCS("set_suspension_travel"),_SCS("get_suspension_travel"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_stiffness"),_SCS("set_suspension_stiffness"),_SCS("get_suspension_stiffness"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_max_force"),_SCS("set_suspension_max_force"),_SCS("get_suspension_max_force"));
+ ADD_GROUP("Damping","damping_");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping_compression"),_SCS("set_damping_compression"),_SCS("get_damping_compression"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping_relaxation"),_SCS("set_damping_relaxation"),_SCS("get_damping_relaxation"));
}
@@ -336,10 +340,11 @@ void VehicleBody::_update_wheel_transform(VehicleWheel& wheel ,PhysicsDirectBody
wheel.m_raycastInfo.m_isInContact = false;
Transform chassisTrans = s->get_transform();
- //if (interpolatedTransform && (getRigidBody()->getMotionState()))
- //{
- // getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
- //}
+ /*
+ if (interpolatedTransform && (getRigidBody()->getMotionState())) {
+ getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
+ }
+ */
wheel.m_raycastInfo.m_hardPointWS = chassisTrans.xform( wheel.m_chassisConnectionPointCS );
//wheel.m_raycastInfo.m_hardPointWS+=s->get_linear_velocity()*s->get_step();
@@ -356,21 +361,23 @@ void VehicleBody::_update_wheel(int p_idx,PhysicsDirectBodyState *s) {
const Vector3& right = wheel.m_raycastInfo.m_wheelAxleWS;
Vector3 fwd = up.cross(right);
fwd = fwd.normalized();
-// up = right.cross(fwd);
-// up.normalize();
+ //up = right.cross(fwd);
+ //up.normalize();
//rotate around steering over de wheelAxleWS
real_t steering = wheel.steers?m_steeringValue:0.0;
//print_line(itos(p_idx)+": "+rtos(steering));
- Matrix3 steeringMat(up,steering);
+ Basis steeringMat(up,steering);
- Matrix3 rotatingMat(right,-wheel.m_rotation);
+ Basis rotatingMat(right,-wheel.m_rotation);
-// if (p_idx==1)
-// print_line("steeringMat " +steeringMat);
+ /*
+ if (p_idx==1)
+ print_line("steeringMat " +steeringMat);
+ */
- Matrix3 basis2(
+ Basis basis2(
right[0],up[0],fwd[0],
right[1],up[1],fwd[1],
right[2],up[2],fwd[2]
@@ -498,7 +505,7 @@ void VehicleBody::_update_suspension(PhysicsDirectBodyState *s)
if ( wheel_info.m_raycastInfo.m_isInContact )
{
real_t force;
- // Spring
+ //Spring
{
real_t susp_length = wheel_info.m_suspensionRestLength;
real_t current_length = wheel_info.m_raycastInfo.m_suspensionLength;
@@ -570,7 +577,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
Vector3 vel = vel1 - vel2;
- Matrix3 b2trans;
+ Basis b2trans;
float b2invmass=0;
Vector3 b2lv;
Vector3 b2av;
@@ -590,7 +597,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
rel_pos1,
rel_pos2,
normal,
- s->get_inverse_inertia(),
+ s->get_inverse_inertia_tensor().get_main_diagonal(),
1.0/mass,
b2invinertia,
b2invmass);
@@ -724,7 +731,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
//const btTransform& wheelTrans = getWheelTransformWS( i );
- Matrix3 wheelBasis0 = wheelInfo.m_worldTransform.basis;//get_global_transform().basis;
+ Basis wheelBasis0 = wheelInfo.m_worldTransform.basis;//get_global_transform().basis;
m_axle[i] = wheelBasis0.get_axis(Vector3::AXIS_X);
//m_axle[i] = wheelInfo.m_raycastInfo.m_wheelAxleWS;
@@ -1019,30 +1026,32 @@ Vector3 VehicleBody::get_linear_velocity() const
void VehicleBody::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_mass","mass"),&VehicleBody::set_mass);
- ObjectTypeDB::bind_method(_MD("get_mass"),&VehicleBody::get_mass);
+ ClassDB::bind_method(_MD("set_mass","mass"),&VehicleBody::set_mass);
+ ClassDB::bind_method(_MD("get_mass"),&VehicleBody::get_mass);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&VehicleBody::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&VehicleBody::get_friction);
+ ClassDB::bind_method(_MD("set_friction","friction"),&VehicleBody::set_friction);
+ ClassDB::bind_method(_MD("get_friction"),&VehicleBody::get_friction);
- ObjectTypeDB::bind_method(_MD("set_engine_force","engine_force"),&VehicleBody::set_engine_force);
- ObjectTypeDB::bind_method(_MD("get_engine_force"),&VehicleBody::get_engine_force);
+ ClassDB::bind_method(_MD("set_engine_force","engine_force"),&VehicleBody::set_engine_force);
+ ClassDB::bind_method(_MD("get_engine_force"),&VehicleBody::get_engine_force);
- ObjectTypeDB::bind_method(_MD("set_brake","brake"),&VehicleBody::set_brake);
- ObjectTypeDB::bind_method(_MD("get_brake"),&VehicleBody::get_brake);
+ ClassDB::bind_method(_MD("set_brake","brake"),&VehicleBody::set_brake);
+ ClassDB::bind_method(_MD("get_brake"),&VehicleBody::get_brake);
- ObjectTypeDB::bind_method(_MD("set_steering","steering"),&VehicleBody::set_steering);
- ObjectTypeDB::bind_method(_MD("get_steering"),&VehicleBody::get_steering);
+ ClassDB::bind_method(_MD("set_steering","steering"),&VehicleBody::set_steering);
+ ClassDB::bind_method(_MD("get_steering"),&VehicleBody::get_steering);
- ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&VehicleBody::get_linear_velocity);
+ ClassDB::bind_method(_MD("get_linear_velocity"),&VehicleBody::get_linear_velocity);
- ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&VehicleBody::_direct_state_changed);
+ ClassDB::bind_method(_MD("_direct_state_changed"),&VehicleBody::_direct_state_changed);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/engine_force",PROPERTY_HINT_RANGE,"0.00,1024.0,0.01"),_SCS("set_engine_force"),_SCS("get_engine_force"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/brake",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_brake"),_SCS("get_brake"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/steering",PROPERTY_HINT_RANGE,"-180,180.0,0.01"),_SCS("set_steering"),_SCS("get_steering"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"body/mass",PROPERTY_HINT_RANGE,"0.01,65536,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"body/friction",PROPERTY_HINT_RANGE,"0.01,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
+ ADD_GROUP("Motion","");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"engine_force",PROPERTY_HINT_RANGE,"0.00,1024.0,0.01"),_SCS("set_engine_force"),_SCS("get_engine_force"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"brake",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_brake"),_SCS("get_brake"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"steering",PROPERTY_HINT_RANGE,"-180,180.0,0.01"),_SCS("set_steering"),_SCS("get_steering"));
+ ADD_GROUP("Mass","");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_RANGE,"0.01,65536,0.01"),_SCS("set_mass"),_SCS("get_mass"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0.01,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
}
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index 3a516be716..273e63d741 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@ class VehicleBody;
class VehicleWheel : public Spatial {
- OBJ_TYPE(VehicleWheel,Spatial);
+ GDCLASS(VehicleWheel,Spatial);
friend class VehicleBody;
@@ -63,7 +63,7 @@ friend class VehicleBody;
VehicleBody *body;
-// btVector3 m_wheelAxleCS; // const or modified by steering ?
+ //btVector3 m_wheelAxleCS; // const or modified by steering ?
real_t m_steering;
real_t m_rotation;
@@ -136,7 +136,7 @@ public:
class VehicleBody : public PhysicsBody {
- OBJ_TYPE(VehicleBody,PhysicsBody);
+ GDCLASS(VehicleBody,PhysicsBody);
real_t mass;
real_t friction;
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index f3b5cde0eb..c7c083732e 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,10 +38,10 @@ void VisibilityNotifier::_enter_camera(Camera* p_camera) {
ERR_FAIL_COND(cameras.has(p_camera));
cameras.insert(p_camera);
if (cameras.size()==1) {
- emit_signal(SceneStringNames::get_singleton()->enter_screen);
+ emit_signal(SceneStringNames::get_singleton()->screen_entered);
_screen_enter();
}
- emit_signal(SceneStringNames::get_singleton()->enter_camera,p_camera);
+ emit_signal(SceneStringNames::get_singleton()->camera_entered,p_camera);
}
@@ -50,9 +50,9 @@ void VisibilityNotifier::_exit_camera(Camera* p_camera){
ERR_FAIL_COND(!cameras.has(p_camera));
cameras.erase(p_camera);
- emit_signal(SceneStringNames::get_singleton()->exit_camera,p_camera);
+ emit_signal(SceneStringNames::get_singleton()->camera_exited,p_camera);
if (cameras.size()==0) {
- emit_signal(SceneStringNames::get_singleton()->exit_screen);
+ emit_signal(SceneStringNames::get_singleton()->screen_exited);
_screen_exit();
@@ -60,7 +60,7 @@ void VisibilityNotifier::_exit_camera(Camera* p_camera){
}
-void VisibilityNotifier::set_aabb(const AABB& p_aabb){
+void VisibilityNotifier::set_aabb(const Rect3& p_aabb){
if (aabb==p_aabb)
return;
@@ -74,7 +74,7 @@ void VisibilityNotifier::set_aabb(const AABB& p_aabb){
update_gizmo();
}
-AABB VisibilityNotifier::get_aabb() const{
+Rect3 VisibilityNotifier::get_aabb() const{
return aabb;
}
@@ -109,22 +109,23 @@ bool VisibilityNotifier::is_on_screen() const {
void VisibilityNotifier::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_aabb","rect"),&VisibilityNotifier::set_aabb);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&VisibilityNotifier::get_aabb);
- ObjectTypeDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier::is_on_screen);
+ ClassDB::bind_method(_MD("set_aabb","rect"),&VisibilityNotifier::set_aabb);
+ ClassDB::bind_method(_MD("get_aabb"),&VisibilityNotifier::get_aabb);
+ ClassDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier::is_on_screen);
- ADD_PROPERTY( PropertyInfo(Variant::_AABB,"aabb"),_SCS("set_aabb"),_SCS("get_aabb"));
+ ADD_PROPERTY( PropertyInfo(Variant::RECT3,"aabb"),_SCS("set_aabb"),_SCS("get_aabb"));
- ADD_SIGNAL( MethodInfo("enter_camera",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
- ADD_SIGNAL( MethodInfo("exit_camera",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
- ADD_SIGNAL( MethodInfo("enter_screen"));
- ADD_SIGNAL( MethodInfo("exit_screen"));
+ ADD_SIGNAL( MethodInfo("camera_entered",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
+ ADD_SIGNAL( MethodInfo("camera_exited",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
+ ADD_SIGNAL( MethodInfo("screen_entered"));
+ ADD_SIGNAL( MethodInfo("screen_exited"));
}
VisibilityNotifier::VisibilityNotifier() {
- aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2));
+ aabb=Rect3(Vector3(-1,-1,-1),Vector3(2,2,2));
+ set_notify_transform(true);
}
@@ -183,7 +184,7 @@ void VisibilityEnabler::_find_nodes(Node* p_node) {
if (add) {
- p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
+ p_node->connect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
nodes[p_node]=meta;
_change_node_state(p_node,false);
}
@@ -225,7 +226,7 @@ void VisibilityEnabler::_notification(int p_what){
if (!visible)
_change_node_state(E->key(),true);
- E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
+ E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed");
}
nodes.clear();
@@ -260,19 +261,19 @@ void VisibilityEnabler::_node_removed(Node* p_node) {
if (!visible)
_change_node_state(p_node,true);
- p_node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
+ p_node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed");
nodes.erase(p_node);
}
void VisibilityEnabler::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler::set_enabler);
- ObjectTypeDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler::is_enabler_enabled);
- ObjectTypeDB::bind_method(_MD("_node_removed"),&VisibilityEnabler::_node_removed);
+ ClassDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler::set_enabler);
+ ClassDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler::is_enabler_enabled);
+ ClassDB::bind_method(_MD("_node_removed"),&VisibilityEnabler::_node_removed);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
BIND_CONSTANT( ENABLER_FREEZE_BODIES );
BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h
index a4709b7cf4..aa53e1bcd1 100644
--- a/scene/3d/visibility_notifier.h
+++ b/scene/3d/visibility_notifier.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,11 +34,11 @@
class Camera;
class VisibilityNotifier : public Spatial {
- OBJ_TYPE(VisibilityNotifier,Spatial);
+ GDCLASS(VisibilityNotifier,Spatial);
Set<Camera*> cameras;
- AABB aabb;
+ Rect3 aabb;
protected:
@@ -54,8 +54,8 @@ friend class SpatialIndexer;
public:
- void set_aabb(const AABB& p_aabb);
- AABB get_aabb() const;
+ void set_aabb(const Rect3& p_aabb);
+ Rect3 get_aabb() const;
bool is_on_screen() const;
VisibilityNotifier();
@@ -64,7 +64,7 @@ public:
class VisibilityEnabler : public VisibilityNotifier {
- OBJ_TYPE(VisibilityEnabler,VisibilityNotifier);
+ GDCLASS(VisibilityEnabler,VisibilityNotifier);
public:
enum Enabler {
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index b4f7a4e5b4..ec37aa2bc4 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,15 +31,23 @@
#include "servers/visual_server.h"
#include "room_instance.h"
#include "scene/scene_string_names.h"
-#include "baked_light_instance.h"
#include "skeleton.h"
-AABB VisualInstance::get_transformed_aabb() const {
+Rect3 VisualInstance::get_transformed_aabb() const {
return get_global_transform().xform( get_aabb() );
}
+void VisualInstance::_update_visibility() {
+
+ if (!is_inside_tree())
+ return;
+
+ _change_notify("visible");
+ VS::get_singleton()->instance_set_visible(get_instance(),is_visible_in_tree());
+}
+
void VisualInstance::_notification(int p_what) {
@@ -52,7 +60,7 @@ void VisualInstance::_notification(int p_what) {
Room *room=NULL;
bool is_geom = cast_to<GeometryInstance>();
- while(parent) {
+ /* while(parent) {
room = parent->cast_to<Room>();
if (room)
@@ -64,7 +72,7 @@ void VisualInstance::_notification(int p_what) {
}
parent=parent->get_parent_spatial();
- }
+ }*/
@@ -80,6 +88,8 @@ void VisualInstance::_notification(int p_what) {
*/
VisualServer::get_singleton()->instance_set_scenario( instance, get_world()->get_scenario() );
+ _update_visibility();
+
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -92,10 +102,14 @@ void VisualInstance::_notification(int p_what) {
VisualServer::get_singleton()->instance_set_scenario( instance, RID() );
VisualServer::get_singleton()->instance_set_room(instance,RID());
VisualServer::get_singleton()->instance_attach_skeleton( instance, RID() );
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
+ //VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
+ } break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ _update_visibility();
} break;
+
}
}
@@ -123,14 +137,14 @@ uint32_t VisualInstance::get_layer_mask() const {
void VisualInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_get_visual_instance_rid"),&VisualInstance::_get_visual_instance_rid);
- ObjectTypeDB::bind_method(_MD("set_base","base"), &VisualInstance::set_base);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"), &VisualInstance::get_layer_mask);
+ ClassDB::bind_method(_MD("_get_visual_instance_rid"),&VisualInstance::_get_visual_instance_rid);
+ ClassDB::bind_method(_MD("set_base","base"), &VisualInstance::set_base);
+ ClassDB::bind_method(_MD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
+ ClassDB::bind_method(_MD("get_layer_mask"), &VisualInstance::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
+ ClassDB::bind_method(_MD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_LAYERS_3D_RENDER), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
}
@@ -148,6 +162,7 @@ VisualInstance::VisualInstance()
instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_attach_object_instance_ID( instance, get_instance_ID() );
layers=1;
+ set_notify_transform(true);
}
@@ -172,98 +187,73 @@ Ref<Material> GeometryInstance::get_material_override() const{
-void GeometryInstance::set_draw_range_begin(float p_dist){
+void GeometryInstance::set_lod_min_distance(float p_dist){
- draw_begin=p_dist;
- VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),draw_begin,draw_end);
+ lod_min_distance=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
}
-float GeometryInstance::get_draw_range_begin() const{
+float GeometryInstance::get_lod_min_distance() const{
- return draw_begin;
+ return lod_min_distance;
}
-void GeometryInstance::set_draw_range_end(float p_dist) {
+void GeometryInstance::set_lod_max_distance(float p_dist) {
- draw_end=p_dist;
- VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),draw_begin,draw_end);
+ lod_max_distance=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
}
-float GeometryInstance::get_draw_range_end() const {
+float GeometryInstance::get_lod_max_distance() const {
- return draw_end;
+ return lod_max_distance;
}
-void GeometryInstance::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_WORLD) {
+void GeometryInstance::set_lod_min_hysteresis(float p_dist){
- if (flags[FLAG_USE_BAKED_LIGHT]) {
+ lod_min_hysteresis=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
+}
- _find_baked_light();
- }
+float GeometryInstance::get_lod_min_hysteresis() const{
- _update_visibility();
+ return lod_min_hysteresis;
+}
- } else if (p_what==NOTIFICATION_EXIT_WORLD) {
- if (flags[FLAG_USE_BAKED_LIGHT]) {
+void GeometryInstance::set_lod_max_hysteresis(float p_dist) {
- if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
- }
- _baked_light_changed();
+ lod_max_hysteresis=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
- }
+}
- } if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+float GeometryInstance::get_lod_max_hysteresis() const {
- _update_visibility();
- }
+ return lod_max_hysteresis;
+}
-}
+void GeometryInstance::_notification(int p_what) {
-void GeometryInstance::_baked_light_changed() {
+ if (p_what==NOTIFICATION_ENTER_WORLD) {
- if (!baked_light_instance)
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID());
- else
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance());
+ if (flags[FLAG_USE_BAKED_LIGHT]) {
-}
+ }
-void GeometryInstance::_find_baked_light() {
- Node *n=get_parent();
- while(n) {
+ } else if (p_what==NOTIFICATION_EXIT_WORLD) {
- BakedLightInstance *bl=n->cast_to<BakedLightInstance>();
- if (bl) {
+ if (flags[FLAG_USE_BAKED_LIGHT]) {
- baked_light_instance=bl;
- baked_light_instance->connect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- _baked_light_changed();
- return;
}
- n=n->get_parent();
}
- _baked_light_changed();
-}
-
-void GeometryInstance::_update_visibility() {
-
- if (!is_inside_tree())
- return;
-
- _change_notify("geometry/visible");
- VS::get_singleton()->instance_geometry_set_flag(get_instance(),VS::INSTANCE_FLAG_VISIBLE,is_visible() && flags[FLAG_VISIBLE]);
}
void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
@@ -283,22 +273,8 @@ void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
flags[p_flag]=p_value;
VS::get_singleton()->instance_geometry_set_flag(get_instance(),(VS::InstanceFlags)p_flag,p_value);
- if (p_flag==FLAG_VISIBLE) {
- _update_visibility();
- }
if (p_flag==FLAG_USE_BAKED_LIGHT) {
- if (is_inside_world()) {
- if (!p_value) {
- if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
- }
- _baked_light_changed();
- } else {
- _find_baked_light();
- }
- }
}
}
@@ -331,17 +307,8 @@ GeometryInstance::ShadowCastingSetting GeometryInstance::get_cast_shadows_settin
return shadow_casting_setting;
}
-void GeometryInstance::set_baked_light_texture_id(int p_id) {
- baked_light_texture_id=p_id;
- VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),baked_light_texture_id);
-}
-
-int GeometryInstance::get_baked_light_texture_id() const{
-
- return baked_light_texture_id;
-}
void GeometryInstance::set_extra_cull_margin(float p_margin) {
@@ -357,50 +324,53 @@ float GeometryInstance::get_extra_cull_margin() const{
void GeometryInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_material_override","material"), &GeometryInstance::set_material_override);
- ObjectTypeDB::bind_method(_MD("get_material_override"), &GeometryInstance::get_material_override);
+ ClassDB::bind_method(_MD("set_material_override","material"), &GeometryInstance::set_material_override);
+ ClassDB::bind_method(_MD("get_material_override"), &GeometryInstance::get_material_override);
- ObjectTypeDB::bind_method(_MD("set_flag","flag","value"), &GeometryInstance::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"), &GeometryInstance::get_flag);
+ ClassDB::bind_method(_MD("set_flag","flag","value"), &GeometryInstance::set_flag);
+ ClassDB::bind_method(_MD("get_flag","flag"), &GeometryInstance::get_flag);
- ObjectTypeDB::bind_method(_MD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
- ObjectTypeDB::bind_method(_MD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
+ ClassDB::bind_method(_MD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
+ ClassDB::bind_method(_MD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
- ObjectTypeDB::bind_method(_MD("set_draw_range_begin","mode"), &GeometryInstance::set_draw_range_begin);
- ObjectTypeDB::bind_method(_MD("get_draw_range_begin"), &GeometryInstance::get_draw_range_begin);
+ ClassDB::bind_method(_MD("set_lod_max_hysteresis","mode"), &GeometryInstance::set_lod_max_hysteresis);
+ ClassDB::bind_method(_MD("get_lod_max_hysteresis"), &GeometryInstance::get_lod_max_hysteresis);
- ObjectTypeDB::bind_method(_MD("set_draw_range_end","mode"), &GeometryInstance::set_draw_range_end);
- ObjectTypeDB::bind_method(_MD("get_draw_range_end"), &GeometryInstance::get_draw_range_end);
+ ClassDB::bind_method(_MD("set_lod_max_distance","mode"), &GeometryInstance::set_lod_max_distance);
+ ClassDB::bind_method(_MD("get_lod_max_distance"), &GeometryInstance::get_lod_max_distance);
- ObjectTypeDB::bind_method(_MD("set_baked_light_texture_id","id"), &GeometryInstance::set_baked_light_texture_id);
- ObjectTypeDB::bind_method(_MD("get_baked_light_texture_id"), &GeometryInstance::get_baked_light_texture_id);
+ ClassDB::bind_method(_MD("set_lod_min_hysteresis","mode"), &GeometryInstance::set_lod_min_hysteresis);
+ ClassDB::bind_method(_MD("get_lod_min_hysteresis"), &GeometryInstance::get_lod_min_hysteresis);
- ObjectTypeDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
- ObjectTypeDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
+ ClassDB::bind_method(_MD("set_lod_min_distance","mode"), &GeometryInstance::set_lod_min_distance);
+ ClassDB::bind_method(_MD("get_lod_min_distance"), &GeometryInstance::get_lod_min_distance);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&GeometryInstance::get_aabb);
- ObjectTypeDB::bind_method(_MD("_baked_light_changed"), &GeometryInstance::_baked_light_changed);
+ ClassDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
+ ClassDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "geometry/material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), _SCS("set_material_override"), _SCS("get_material_override"));
- ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), _SCS("set_cast_shadows_setting"), _SCS("get_cast_shadows_setting"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"),FLAG_RECEIVE_SHADOWS);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_begin",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_end",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "geometry/extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard_y"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/depth_scale"), _SCS("set_flag"), _SCS("get_flag"),FLAG_DEPH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible_in_all_rooms"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE_IN_ALL_ROOMS);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/use_baked_light"), _SCS("set_flag"), _SCS("get_flag"),FLAG_USE_BAKED_LIGHT);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/baked_light_tex_id"), _SCS("set_baked_light_texture_id"), _SCS("get_baked_light_texture_id"));
+ ClassDB::bind_method(_MD("get_aabb"),&GeometryInstance::get_aabb);
-// ADD_SIGNAL( MethodInfo("visibility_changed"));
- BIND_CONSTANT(FLAG_VISIBLE );
+ ADD_GROUP("Geometry","");
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), _SCS("set_material_override"), _SCS("get_material_override"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), _SCS("set_cast_shadows_setting"), _SCS("get_cast_shadows_setting"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_as_billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_as_y_billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_depth_scale"), _SCS("set_flag"), _SCS("get_flag"),FLAG_DEPH_SCALE);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "visible_in_all_rooms"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE_IN_ALL_ROOMS);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_in_baked_light"), _SCS("set_flag"), _SCS("get_flag"),FLAG_USE_BAKED_LIGHT);
+
+ ADD_GROUP("LOD","lod_");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_min_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_min_distance"), _SCS("get_lod_min_distance"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_min_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_min_hysteresis"), _SCS("get_lod_min_hysteresis"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_max_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_max_distance"), _SCS("get_lod_max_distance"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_max_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_max_hysteresis"), _SCS("get_lod_max_hysteresis"));
+
+ //ADD_SIGNAL( MethodInfo("visibility_changed"));
+
BIND_CONSTANT(FLAG_CAST_SHADOW );
- BIND_CONSTANT(FLAG_RECEIVE_SHADOWS );
BIND_CONSTANT(FLAG_BILLBOARD );
BIND_CONSTANT(FLAG_BILLBOARD_FIX_Y );
BIND_CONSTANT(FLAG_DEPH_SCALE );
@@ -415,20 +385,21 @@ void GeometryInstance::_bind_methods() {
}
GeometryInstance::GeometryInstance() {
- draw_begin=0;
- draw_end=0;
+ lod_min_distance=0;
+ lod_max_distance=0;
+ lod_min_hysteresis=0;
+ lod_max_hysteresis=0;
+
for(int i=0;i<FLAG_MAX;i++) {
flags[i]=false;
}
- flags[FLAG_VISIBLE]=true;
+
flags[FLAG_CAST_SHADOW]=true;
- flags[FLAG_RECEIVE_SHADOWS]=true;
+
shadow_casting_setting=SHADOW_CASTING_SETTING_ON;
- baked_light_instance=NULL;
- baked_light_texture_id=0;
extra_cull_margin=0;
- VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
+ //VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
}
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index e286d5fa88..5955dae236 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
*/
class VisualInstance : public Spatial {
- OBJ_TYPE( VisualInstance, Spatial );
+ GDCLASS( VisualInstance, Spatial );
OBJ_CATEGORY("3D Visual Nodes");
RID instance;
@@ -48,8 +48,10 @@ class VisualInstance : public Spatial {
RID _get_visual_instance_rid() const;
+
protected:
+ void _update_visibility();
void _notification(int p_what);
static void _bind_methods();
@@ -63,10 +65,10 @@ public:
};
RID get_instance() const;
- virtual AABB get_aabb() const=0;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const=0;
+ virtual Rect3 get_aabb() const=0;
+ virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const=0;
- virtual AABB get_transformed_aabb() const; // helper
+ virtual Rect3 get_transformed_aabb() const; // helper
void set_base(const RID& p_base);
@@ -79,17 +81,15 @@ public:
};
-class BakedLightInstance;
+class BakedLight;
class GeometryInstance : public VisualInstance {
- OBJ_TYPE( GeometryInstance, VisualInstance );
+ GDCLASS( GeometryInstance, VisualInstance );
public:
enum Flags {
- FLAG_VISIBLE=VS::INSTANCE_FLAG_VISIBLE,
FLAG_CAST_SHADOW=VS::INSTANCE_FLAG_CAST_SHADOW,
- FLAG_RECEIVE_SHADOWS=VS::INSTANCE_FLAG_RECEIVE_SHADOWS,
FLAG_BILLBOARD=VS::INSTANCE_FLAG_BILLBOARD,
FLAG_BILLBOARD_FIX_Y=VS::INSTANCE_FLAG_BILLBOARD_FIX_Y,
FLAG_DEPH_SCALE=VS::INSTANCE_FLAG_DEPH_SCALE,
@@ -98,6 +98,7 @@ public:
FLAG_MAX=VS::INSTANCE_FLAG_MAX,
};
+
enum ShadowCastingSetting {
SHADOW_CASTING_SETTING_OFF=VS::SHADOW_CASTING_SETTING_OFF,
SHADOW_CASTING_SETTING_ON = VS::SHADOW_CASTING_SETTING_ON,
@@ -110,15 +111,13 @@ private:
bool flags[FLAG_MAX];
ShadowCastingSetting shadow_casting_setting;
Ref<Material> material_override;
- float draw_begin;
- float draw_end;
- void _find_baked_light();
- BakedLightInstance *baked_light_instance;
- int baked_light_texture_id;
+ float lod_min_distance;
+ float lod_max_distance;
+ float lod_min_hysteresis;
+ float lod_max_hysteresis;
+
float extra_cull_margin;
- void _baked_light_changed();
- void _update_visibility();
protected:
void _notification(int p_what);
@@ -131,18 +130,21 @@ public:
void set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting);
ShadowCastingSetting get_cast_shadows_setting() const;
- void set_draw_range_begin(float p_dist);
- float get_draw_range_begin() const;
+ void set_lod_min_distance(float p_dist);
+ float get_lod_min_distance() const;
+
+ void set_lod_max_distance(float p_dist);
+ float get_lod_max_distance() const;
- void set_draw_range_end(float p_dist);
- float get_draw_range_end() const;
+ void set_lod_min_hysteresis(float p_dist);
+ float get_lod_min_hysteresis() const;
+
+ void set_lod_max_hysteresis(float p_dist);
+ float get_lod_max_hysteresis() const;
void set_material_override(const Ref<Material>& p_material);
Ref<Material> get_material_override() const;
- void set_baked_light_texture_id(int p_id);
- int get_baked_light_texture_id() const;
-
void set_extra_cull_margin(float p_margin);
float get_extra_cull_margin() const;
diff --git a/scene/SCsub b/scene/SCsub
index 6d1dd0044f..bd2da1eab9 100644
--- a/scene/SCsub
+++ b/scene/SCsub
@@ -1,20 +1,22 @@
+#!/usr/bin/env python
+
Import('env')
-env.scene_sources=[]
-env.add_source_files(env.scene_sources,"*.cpp")
+env.scene_sources = []
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
-SConscript('main/SCsub');
-SConscript('gui/SCsub');
-SConscript('3d/SCsub');
-SConscript('2d/SCsub');
-SConscript('animation/SCsub');
-SConscript('audio/SCsub');
-SConscript('resources/SCsub');
-SConscript('io/SCsub');
+SConscript('main/SCsub')
+SConscript('gui/SCsub')
+SConscript('3d/SCsub')
+SConscript('2d/SCsub')
+SConscript('animation/SCsub')
+SConscript('audio/SCsub')
+SConscript('resources/SCsub')
+SConscript('io/SCsub')
-lib = env.Library("scene",env.scene_sources)
+lib = env.Library("scene", env.scene_sources)
env.Prepend(LIBS=[lib])
diff --git a/scene/animation/SCsub b/scene/animation/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/animation/SCsub
+++ b/scene/animation/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index 113e2c2278..25ca74de9f 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -59,7 +59,7 @@ void AnimationCache::_clear_cache() {
while(connected_nodes.size()) {
- connected_nodes.front()->get()->disconnect("exit_tree",this,"_node_exit_tree");
+ connected_nodes.front()->get()->disconnect("tree_exited",this,"_node_exit_tree");
connected_nodes.erase(connected_nodes.front());
}
path_cache.clear();;
@@ -206,7 +206,7 @@ void AnimationCache::_update_cache() {
if (!connected_nodes.has(path.node)) {
connected_nodes.insert(path.node);
- path.node->connect("exit_tree",this,"_node_exit_tree",Node::make_binds(path.node),CONNECT_ONESHOT);
+ path.node->connect("tree_exited",this,"_node_exit_tree",Node::make_binds(path.node),CONNECT_ONESHOT);
}
@@ -292,7 +292,7 @@ void AnimationCache::set_all(float p_time, float p_delta) {
Vector3 loc,scale;
Quat rot;
animation->transform_track_interpolate(i,p_time,&loc,&rot,&scale);
- Transform tr( Matrix3(rot), loc );
+ Transform tr( Basis(rot), loc );
tr.basis.scale(scale);
set_track_transform(i,tr);
@@ -368,8 +368,8 @@ void AnimationCache::set_animation(const Ref<Animation>& p_animation) {
void AnimationCache::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_node_exit_tree"),&AnimationCache::_node_exit_tree);
- ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationCache::_animation_changed);
+ ClassDB::bind_method(_MD("_node_exit_tree"),&AnimationCache::_node_exit_tree);
+ ClassDB::bind_method(_MD("_animation_changed"),&AnimationCache::_animation_changed);
}
void AnimationCache::set_root(Node* p_root) {
diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h
index c9b4ff298c..75e004c811 100644
--- a/scene/animation/animation_cache.h
+++ b/scene/animation/animation_cache.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class AnimationCache : public Object {
- OBJ_TYPE(AnimationCache,Object);
+ GDCLASS(AnimationCache,Object);
struct Path {
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 30af9b0094..8b81c45597 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility
- set_speed(p_value);
+ set_speed_scale(p_value);
} else if (p_name==SceneStringNames::get_singleton()->playback_active) {
set_active(p_value);
@@ -214,14 +214,14 @@ void AnimationPlayer::_notification(int p_what) {
set_autoplay(""); //this line is the fix for autoplay issues with animatio
}
} break;
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (animation_process_mode==ANIMATION_PROCESS_FIXED)
break;
if (processing)
_animation_process( get_process_delta_time() );
} break;
- case NOTIFICATION_FIXED_PROCESS: {
+ case NOTIFICATION_INTERNAL_FIXED_PROCESS: {
if (animation_process_mode==ANIMATION_PROCESS_IDLE)
break;
@@ -269,8 +269,8 @@ void AnimationPlayer::_generate_node_caches(AnimationData* p_anim) {
}
{
- if (!child->is_connected("exit_tree",this,"_node_removed"))
- child->connect("exit_tree",this,"_node_removed",make_binds(child),CONNECT_ONESHOT);
+ if (!child->is_connected("tree_exited",this,"_node_removed"))
+ child->connect("tree_exited",this,"_node_removed",make_binds(child),CONNECT_ONESHOT);
}
TrackNodeCacheKey key;
@@ -426,8 +426,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
Variant value=a->value_track_interpolate(i,p_time);
//thanks to trigger mode, this should be solved now..
- //if (p_delta==0 && value.get_type()==Variant::STRING)
- // continue; // doing this with strings is messy, should find another way
+ /*
+ if (p_delta==0 && value.get_type()==Variant::STRING)
+ continue; // doing this with strings is messy, should find another way
+ */
if (pa->accum_pass!=accum_pass) {
ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX );
cache_update_prop[cache_update_prop_size++]=pa;
@@ -465,7 +467,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
ERR_PRINTS("Position key at time "+rtos(p_time)+" in Animation Track '"+String(pa->owner->path)+"' not of type Vector2()");
}
#endif
- static_cast<Node2D*>(pa->object)->set_pos(value);
+ static_cast<Node2D*>(pa->object)->set_position(value);
} break;
case SP_NODE2D_ROT: {
#ifdef DEBUG_ENABLED
@@ -474,7 +476,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
}
#endif
- static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(value));
+ static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(value));
} break;
case SP_NODE2D_SCALE: {
#ifdef DEBUG_ENABLED
@@ -679,7 +681,7 @@ void AnimationPlayer::_animation_update_transforms() {
ERR_PRINTS("Position key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"' not of type Vector2()");
}
#endif
- static_cast<Node2D*>(pa->object)->set_pos(pa->value_accum);
+ static_cast<Node2D*>(pa->object)->set_position(pa->value_accum);
} break;
case SP_NODE2D_ROT: {
#ifdef DEBUG_ENABLED
@@ -688,7 +690,7 @@ void AnimationPlayer::_animation_update_transforms() {
}
#endif
- static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum));
+ static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(pa->value_accum));
} break;
case SP_NODE2D_SCALE: {
#ifdef DEBUG_ENABLED
@@ -713,7 +715,7 @@ void AnimationPlayer::_animation_process(float p_delta) {
-// bool any_active=false;
+ //bool any_active=false;
if (playback.current.from) {
@@ -733,7 +735,7 @@ void AnimationPlayer::_animation_process(float p_delta) {
playing = false;
_set_process(false);
end_notify=false;
- emit_signal(SceneStringNames::get_singleton()->finished);
+ emit_signal(SceneStringNames::get_singleton()->animation_finished,playback.assigned);
}
}
@@ -1082,13 +1084,13 @@ void AnimationPlayer::stop_all() {
}
-void AnimationPlayer::set_speed(float p_speed) {
+void AnimationPlayer::set_speed_scale(float p_speed) {
speed_scale=p_speed;
}
-float AnimationPlayer::get_speed() const {
+float AnimationPlayer::get_speed_scale() const {
return speed_scale;
}
@@ -1231,8 +1233,8 @@ void AnimationPlayer::_set_process(bool p_process,bool p_force) {
switch(animation_process_mode) {
- case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break;
- case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break;
+ case ANIMATION_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break;
+ case ANIMATION_PROCESS_IDLE: set_process_internal(p_process && active); break;
}
processing=p_process;
@@ -1291,68 +1293,69 @@ void AnimationPlayer::get_argument_options(const StringName& p_function,int p_id
void AnimationPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed);
- ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed);
+ ClassDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed);
+ ClassDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed);
- ObjectTypeDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation);
- ObjectTypeDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation);
- ObjectTypeDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation);
- ObjectTypeDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation);
- ObjectTypeDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation);
- ObjectTypeDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list);
+ ClassDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation);
+ ClassDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation);
+ ClassDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation);
+ ClassDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation);
+ ClassDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation);
+ ClassDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list);
- ObjectTypeDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next);
- ObjectTypeDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next);
+ ClassDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next);
+ ClassDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next);
- ObjectTypeDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time);
- ObjectTypeDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time);
+ ClassDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time);
+ ClassDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time);
- ObjectTypeDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time);
- ObjectTypeDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time);
+ ClassDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time);
+ ClassDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time);
- ObjectTypeDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation);
- ObjectTypeDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation);
- ObjectTypeDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue);
- ObjectTypeDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue);
+ ClassDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false));
+ ClassDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1));
+ ClassDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true));
+ ClassDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all);
+ ClassDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing);
+ ClassDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation);
+ ClassDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation);
+ ClassDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue);
+ ClassDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue);
- ObjectTypeDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active);
+ ClassDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active);
+ ClassDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active);
- ObjectTypeDB::bind_method(_MD("set_speed","speed"),&AnimationPlayer::set_speed);
- ObjectTypeDB::bind_method(_MD("get_speed"),&AnimationPlayer::get_speed);
+ ClassDB::bind_method(_MD("set_speed_scale","speed"),&AnimationPlayer::set_speed_scale);
+ ClassDB::bind_method(_MD("get_speed_scale"),&AnimationPlayer::get_speed_scale);
- ObjectTypeDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay);
+ ClassDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay);
+ ClassDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay);
- ObjectTypeDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root);
- ObjectTypeDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root);
+ ClassDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root);
+ ClassDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root);
- ObjectTypeDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos);
+ ClassDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos);
- ObjectTypeDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation);
+ ClassDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation);
- ObjectTypeDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches);
+ ClassDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches);
- ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode);
+ ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode);
+ ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos);
- ObjectTypeDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length);
+ ClassDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos);
+ ClassDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length);
- ObjectTypeDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance);
+ ClassDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback/default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time"));
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root/root"), _SCS("set_root"), _SCS("get_root"));
+ ADD_GROUP("Playback","playback_");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time"));
+ ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root_node"), _SCS("set_root"), _SCS("get_root"));
- ADD_SIGNAL( MethodInfo("finished") );
+ ADD_SIGNAL( MethodInfo("animation_finished", PropertyInfo(Variant::STRING,"name")) );
ADD_SIGNAL( MethodInfo("animation_changed", PropertyInfo(Variant::STRING,"old_name"), PropertyInfo(Variant::STRING,"new_name")) );
ADD_SIGNAL( MethodInfo("animation_started", PropertyInfo(Variant::STRING,"name")) );
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index ac0265dbaa..41bae6c928 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@
*/
class AnimationPlayer : public Node {
- OBJ_TYPE( AnimationPlayer, Node );
+ GDCLASS( AnimationPlayer, Node );
OBJ_CATEGORY("Animation Nodes");
public:
@@ -208,11 +208,11 @@ private:
void _node_removed(Node *p_node);
// bind helpers
- DVector<String> _get_animation_list() const {
+ PoolVector<String> _get_animation_list() const {
List<StringName> animations;
get_animation_list(&animations);
- DVector<String> ret;
+ PoolVector<String> ret;
while(animations.size()) {
ret.push_back( animations.front()->get());
@@ -271,8 +271,8 @@ public:
bool is_active() const;
bool is_valid() const;
- void set_speed(float p_speed);
- float get_speed() const;
+ void set_speed_scale(float p_speed);
+ float get_speed_scale() const;
void set_autoplay(const String& pname);
String get_autoplay() const;
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 9488ae37a8..c3a05240bb 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -58,8 +58,8 @@ void AnimationTreePlayer::_set_process(bool p_process, bool p_force)
switch (animation_process_mode) {
- case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break;
- case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break;
+ case ANIMATION_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break;
+ case ANIMATION_PROCESS_IDLE: set_process_internal(p_process && active); break;
}
processing = p_process;
@@ -214,7 +214,7 @@ bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value)
StringName src = connections[i*3+0];
StringName dst = connections[i*3+1];
int dst_in = connections[i*3+2];
- connect(src,dst,dst_in);
+ connect_nodes(src,dst,dst_in);
}
set_active(data.get_valid("active"));
@@ -416,8 +416,8 @@ void AnimationTreePlayer::_notification(int p_what) {
if (!processing) {
//make sure that a previous process state was not saved
//only process if "processing" is set
- set_fixed_process(false);
- set_process(false);
+ set_fixed_process_internal(false);
+ set_process_internal(false);
}
} break;
case NOTIFICATION_READY: {
@@ -426,14 +426,14 @@ void AnimationTreePlayer::_notification(int p_what) {
_update_sources();
}
} break;
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (animation_process_mode==ANIMATION_PROCESS_FIXED)
break;
if (processing)
_process_animation( get_process_delta_time() );
} break;
- case NOTIFICATION_FIXED_PROCESS: {
+ case NOTIFICATION_INTERNAL_FIXED_PROCESS: {
if (animation_process_mode==ANIMATION_PROCESS_IDLE)
break;
@@ -494,15 +494,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
case NODE_OUTPUT: {
NodeOut *on = static_cast<NodeOut*>(nb);
-
- for(TrackMap::Element *E=track_map.front();E;E=E->next()) {
- E->get().total_weight = 0;
- }
-
HashMap<NodePath, float> weights;
-
-
return _process_node(on->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, &weights);
} break;
@@ -513,10 +506,10 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
float rem = 0;
if (!an->animation.is_null()) {
- // float pos = an->time;
-// float delta = p_time;
+ //float pos = an->time;
+ //float delta = p_time;
- // const Animation *a = an->animation.operator->();
+ //const Animation *a = an->animation.operator->();
if (p_seek) {
an->time=p_time;
@@ -544,15 +537,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
NodePath track_path = an->animation->track_get_path(E->get().local_track);
if (an->filter.has(track_path) && an->filter[track_path]) {
E->get().weight = 0;
- E->get().track->total_weight += p_fallback_weight;
} else {
if (p_weights->has(track_path)) {
float weight = (*p_weights)[track_path];
E->get().weight = weight;
- E->get().track->total_weight += weight;
} else {
E->get().weight = p_fallback_weight;
- E->get().track->total_weight += p_fallback_weight;
}
}
if (E->get().weight>CMP_EPSILON)
@@ -875,8 +865,6 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
if (tr.track==NULL || tr.local_track<0 || tr.weight < CMP_EPSILON)
continue;
- float blend=tr.weight / tr.track->total_weight;
-
switch(a->track_get_type(tr.local_track)) {
case Animation::TYPE_TRANSFORM: { ///< Transform a node or a bone.
@@ -885,14 +873,14 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
Vector3 scale;
a->transform_track_interpolate(tr.local_track,anim_list->time,&loc,&rot,&scale);
- tr.track->loc+=loc*blend;
+ tr.track->loc+=loc*tr.weight;
scale.x-=1.0;
scale.y-=1.0;
scale.z-=1.0;
- tr.track->scale+=scale*blend;
+ tr.track->scale+=scale*tr.weight;
- tr.track->rot = tr.track->rot * empty_rot.slerp(rot,blend);
+ tr.track->rot = tr.track->rot * empty_rot.slerp(rot,tr.weight);
} break;
@@ -900,7 +888,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
if (a->value_track_get_update_mode(tr.local_track)==Animation::UPDATE_CONTINUOUS) {
Variant value = a->value_track_interpolate(tr.local_track,anim_list->time);
- Variant::blend(tr.track->value,value,blend,tr.track->value);
+ Variant::blend(tr.track->value,value,tr.weight,tr.track->value);
} else {
int index = a->track_find_key(tr.local_track,anim_list->time);
tr.track->value = a->track_get_key_value(tr.local_track, index);
@@ -1508,17 +1496,17 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringN
}
-Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) {
+Error AnimationTreePlayer::connect_nodes(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) {
ERR_FAIL_COND_V( !node_map.has(p_src_node) , ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V( !node_map.has(p_dst_node) , ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V( p_src_node==p_dst_node , ERR_INVALID_PARAMETER);
-// NodeBase *src = node_map[p_src_node];
+ //NodeBase *src = node_map[p_src_node];
NodeBase *dst = node_map[p_dst_node];
ERR_FAIL_INDEX_V( p_dst_input, dst->inputs.size(), ERR_INVALID_PARAMETER);
-// int oldval = dst->inputs[p_dst_input].node;
+ //int oldval = dst->inputs[p_dst_input].node;
for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
@@ -1550,7 +1538,7 @@ Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName
return OK;
}
-bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const {
+bool AnimationTreePlayer::are_nodes_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const {
ERR_FAIL_COND_V( !node_map.has(p_src_node) , false);
ERR_FAIL_COND_V( !node_map.has(p_dst_node) , false);
@@ -1562,7 +1550,7 @@ bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const String
}
-void AnimationTreePlayer::disconnect(const StringName& p_node, int p_input) {
+void AnimationTreePlayer::disconnect_nodes(const StringName& p_node, int p_input) {
ERR_FAIL_COND( !node_map.has(p_node));
@@ -1752,11 +1740,11 @@ NodePath AnimationTreePlayer::get_master_player() const{
return master;
}
-DVector<String> AnimationTreePlayer::_get_node_list() {
+PoolVector<String> AnimationTreePlayer::_get_node_list() {
List<StringName> nl;
get_node_list(&nl);
- DVector<String> ret;
+ PoolVector<String> ret;
ret.resize(nl.size());
int idx=0;
for(List<StringName>::Element *E=nl.front();E;E=E->next()) {
@@ -1840,105 +1828,106 @@ Error AnimationTreePlayer::node_rename(const StringName& p_node,const StringName
void AnimationTreePlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_node","type","id"),&AnimationTreePlayer::add_node);
+ ClassDB::bind_method(_MD("add_node","type","id"),&AnimationTreePlayer::add_node);
- ObjectTypeDB::bind_method(_MD("node_exists","node"),&AnimationTreePlayer::node_exists);
- ObjectTypeDB::bind_method(_MD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename);
+ ClassDB::bind_method(_MD("node_exists","node"),&AnimationTreePlayer::node_exists);
+ ClassDB::bind_method(_MD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename);
- ObjectTypeDB::bind_method(_MD("node_get_type","id"),&AnimationTreePlayer::node_get_type);
- ObjectTypeDB::bind_method(_MD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count);
- ObjectTypeDB::bind_method(_MD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source);
+ ClassDB::bind_method(_MD("node_get_type","id"),&AnimationTreePlayer::node_get_type);
+ ClassDB::bind_method(_MD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count);
+ ClassDB::bind_method(_MD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source);
- ObjectTypeDB::bind_method(_MD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation);
+ ClassDB::bind_method(_MD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation);
+ ClassDB::bind_method(_MD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path);
+ ClassDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation);
+ ClassDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation);
+ ClassDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time);
+ ClassDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time);
+ ClassDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time);
+ ClassDB::bind_method(_MD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time);
+ ClassDB::bind_method(_MD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay);
+ ClassDB::bind_method(_MD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart);
+ ClassDB::bind_method(_MD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay);
+ ClassDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay);
+ ClassDB::bind_method(_MD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart);
+ ClassDB::bind_method(_MD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay);
+ ClassDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start);
- ObjectTypeDB::bind_method(_MD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop);
- ObjectTypeDB::bind_method(_MD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path);
+ ClassDB::bind_method(_MD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start);
+ ClassDB::bind_method(_MD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop);
+ ClassDB::bind_method(_MD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active);
+ ClassDB::bind_method(_MD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path);
- ObjectTypeDB::bind_method(_MD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount);
- ObjectTypeDB::bind_method(_MD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount);
+ ClassDB::bind_method(_MD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount);
+ ClassDB::bind_method(_MD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount);
- ObjectTypeDB::bind_method(_MD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount);
- ObjectTypeDB::bind_method(_MD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount);
- ObjectTypeDB::bind_method(_MD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path);
+ ClassDB::bind_method(_MD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount);
+ ClassDB::bind_method(_MD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount);
+ ClassDB::bind_method(_MD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path);
- ObjectTypeDB::bind_method(_MD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount);
- ObjectTypeDB::bind_method(_MD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount);
+ ClassDB::bind_method(_MD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount);
+ ClassDB::bind_method(_MD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount);
- ObjectTypeDB::bind_method(_MD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount);
- ObjectTypeDB::bind_method(_MD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount);
+ ClassDB::bind_method(_MD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount);
+ ClassDB::bind_method(_MD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount);
- ObjectTypeDB::bind_method(_MD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale);
- ObjectTypeDB::bind_method(_MD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale);
+ ClassDB::bind_method(_MD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale);
+ ClassDB::bind_method(_MD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale);
- ObjectTypeDB::bind_method(_MD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek);
+ ClassDB::bind_method(_MD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek);
- ObjectTypeDB::bind_method(_MD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count);
- ObjectTypeDB::bind_method(_MD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count);
- ObjectTypeDB::bind_method(_MD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input);
+ ClassDB::bind_method(_MD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count);
+ ClassDB::bind_method(_MD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count);
+ ClassDB::bind_method(_MD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input);
- ObjectTypeDB::bind_method(_MD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance);
- ObjectTypeDB::bind_method(_MD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance);
+ ClassDB::bind_method(_MD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance);
+ ClassDB::bind_method(_MD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance);
- ObjectTypeDB::bind_method(_MD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time);
- ObjectTypeDB::bind_method(_MD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time);
+ ClassDB::bind_method(_MD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time);
+ ClassDB::bind_method(_MD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time);
- ObjectTypeDB::bind_method(_MD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current);
- ObjectTypeDB::bind_method(_MD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current);
+ ClassDB::bind_method(_MD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current);
+ ClassDB::bind_method(_MD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current);
- ObjectTypeDB::bind_method(_MD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos);
- ObjectTypeDB::bind_method(_MD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos);
+ ClassDB::bind_method(_MD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos);
+ ClassDB::bind_method(_MD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos);
- ObjectTypeDB::bind_method(_MD("remove_node","id"),&AnimationTreePlayer::remove_node);
- ObjectTypeDB::bind_method(_MD("connect","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect);
- ObjectTypeDB::bind_method(_MD("is_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::is_connected);
- ObjectTypeDB::bind_method(_MD("disconnect","id","dst_input_idx"),&AnimationTreePlayer::disconnect);
+ ClassDB::bind_method(_MD("remove_node","id"),&AnimationTreePlayer::remove_node);
+ ClassDB::bind_method(_MD("connect_nodes","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect_nodes);
+ ClassDB::bind_method(_MD("are_nodes_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::are_nodes_connected);
+ ClassDB::bind_method(_MD("disconnect_nodes","id","dst_input_idx"),&AnimationTreePlayer::disconnect_nodes);
- ObjectTypeDB::bind_method(_MD("set_active","enabled"),&AnimationTreePlayer::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&AnimationTreePlayer::is_active);
+ ClassDB::bind_method(_MD("set_active","enabled"),&AnimationTreePlayer::set_active);
+ ClassDB::bind_method(_MD("is_active"),&AnimationTreePlayer::is_active);
- ObjectTypeDB::bind_method(_MD("set_base_path","path"),&AnimationTreePlayer::set_base_path);
- ObjectTypeDB::bind_method(_MD("get_base_path"),&AnimationTreePlayer::get_base_path);
+ ClassDB::bind_method(_MD("set_base_path","path"),&AnimationTreePlayer::set_base_path);
+ ClassDB::bind_method(_MD("get_base_path"),&AnimationTreePlayer::get_base_path);
- ObjectTypeDB::bind_method(_MD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player);
- ObjectTypeDB::bind_method(_MD("get_master_player"),&AnimationTreePlayer::get_master_player);
+ ClassDB::bind_method(_MD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player);
+ ClassDB::bind_method(_MD("get_master_player"),&AnimationTreePlayer::get_master_player);
- ObjectTypeDB::bind_method(_MD("get_node_list"),&AnimationTreePlayer::_get_node_list);
+ ClassDB::bind_method(_MD("get_node_list"),&AnimationTreePlayer::_get_node_list);
- ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode);
+ ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode);
+ ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("advance", "delta"), &AnimationTreePlayer::advance);
+ ClassDB::bind_method(_MD("advance", "delta"), &AnimationTreePlayer::advance);
- ObjectTypeDB::bind_method(_MD("reset"),&AnimationTreePlayer::reset);
+ ClassDB::bind_method(_MD("reset"),&AnimationTreePlayer::reset);
- ObjectTypeDB::bind_method(_MD("recompute_caches"),&AnimationTreePlayer::recompute_caches);
+ ClassDB::bind_method(_MD("recompute_caches"),&AnimationTreePlayer::recompute_caches);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
+ ADD_GROUP("Playback","playback_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
BIND_CONSTANT( NODE_OUTPUT );
BIND_CONSTANT( NODE_ANIMATION );
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index 6b5350e9ee..5e118be034 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
class AnimationTreePlayer : public Node {
- OBJ_TYPE( AnimationTreePlayer, Node );
+ GDCLASS( AnimationTreePlayer, Node );
OBJ_CATEGORY("Animation Nodes");
public:
@@ -111,7 +111,6 @@ private:
Variant value;
bool skip;
- float total_weight;
};
@@ -283,7 +282,7 @@ private:
Track* _find_track(const NodePath& p_path);
void _recompute_caches();
void _recompute_caches(const StringName& p_node);
- DVector<String> _get_node_list();
+ PoolVector<String> _get_node_list();
void _compute_weights(float *p_fallback_weight, HashMap<NodePath,float> *p_weights, float p_coeff, const HashMap<NodePath,bool> *p_filter = NULL, float p_filtered_coeff = 0);
@@ -398,9 +397,9 @@ public:
void get_node_list(List<StringName> *p_node_list) const;
void remove_node(const StringName& p_node);
- Error connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input);
- bool is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const;
- void disconnect(const StringName& p_src_node, int p_input);
+ Error connect_nodes(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input);
+ bool are_nodes_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const;
+ void disconnect_nodes(const StringName& p_src_node, int p_input);
void set_base_path(const NodePath& p_path);
NodePath get_base_path() const;
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index adc8f9c8cf..0916119db3 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -109,7 +109,7 @@ bool Tween::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
if (name=="playback/speed" || name=="speed") { //bw compatibility
- set_speed(p_value);
+ set_speed_scale(p_value);
} else if (name=="playback/active") {
set_active(p_value);
@@ -155,21 +155,21 @@ void Tween::_notification(int p_what) {
if (!processing) {
//make sure that a previous process state was not saved
//only process if "processing" is set
- set_fixed_process(false);
- set_process(false);
+ set_fixed_process_internal(false);
+ set_process_internal(false);
}
} break;
case NOTIFICATION_READY: {
} break;
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (tween_process_mode==TWEEN_PROCESS_FIXED)
break;
if (processing)
_tween_process( get_process_delta_time() );
} break;
- case NOTIFICATION_FIXED_PROCESS: {
+ case NOTIFICATION_INTERNAL_FIXED_PROCESS: {
if (tween_process_mode==TWEEN_PROCESS_IDLE)
break;
@@ -186,45 +186,46 @@ void Tween::_notification(int p_what) {
void Tween::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("is_active"),&Tween::is_active );
- ObjectTypeDB::bind_method(_MD("set_active","active"),&Tween::set_active );
-
- ObjectTypeDB::bind_method(_MD("is_repeat"),&Tween::is_repeat );
- ObjectTypeDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat );
-
- ObjectTypeDB::bind_method(_MD("set_speed","speed"),&Tween::set_speed);
- ObjectTypeDB::bind_method(_MD("get_speed"),&Tween::get_speed);
-
- ObjectTypeDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode);
- ObjectTypeDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode);
-
- ObjectTypeDB::bind_method(_MD("start"),&Tween::start );
- ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset );
- ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all );
- ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop );
- ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all );
- ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume );
- ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all );
- ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove );
- ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all );
- ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek );
- ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell );
- ObjectTypeDB::bind_method(_MD("get_runtime"),&Tween::get_runtime );
-
- ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("interpolate_callback","object","times_in_sec","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
- ObjectTypeDB::bind_method(_MD("interpolate_deferred_callback","object","times_in_sec","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
- ObjectTypeDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("targeting_method","object","method","initial","initial_method","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) );
-
- ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
+ ClassDB::bind_method(_MD("is_active"),&Tween::is_active );
+ ClassDB::bind_method(_MD("set_active","active"),&Tween::set_active );
+
+ ClassDB::bind_method(_MD("is_repeat"),&Tween::is_repeat );
+ ClassDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat );
+
+ ClassDB::bind_method(_MD("set_speed_scale","speed"),&Tween::set_speed_scale);
+ ClassDB::bind_method(_MD("get_speed_scale"),&Tween::get_speed_scale);
+
+ ClassDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode);
+ ClassDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode);
+
+ ClassDB::bind_method(_MD("start"),&Tween::start );
+ ClassDB::bind_method(_MD("reset","object","key"),&Tween::reset, DEFVAL("") );
+ ClassDB::bind_method(_MD("reset_all"),&Tween::reset_all );
+ ClassDB::bind_method(_MD("stop","object","key"),&Tween::stop, DEFVAL("") );
+ ClassDB::bind_method(_MD("stop_all"),&Tween::stop_all );
+ ClassDB::bind_method(_MD("resume","object","key"),&Tween::resume, DEFVAL("") );
+ ClassDB::bind_method(_MD("resume_all"),&Tween::resume_all );
+ ClassDB::bind_method(_MD("remove","object","key"),&Tween::remove, DEFVAL("") );
+ ClassDB::bind_method(_MD("_remove","object","key","first_only"),&Tween::_remove );
+ ClassDB::bind_method(_MD("remove_all"),&Tween::remove_all );
+ ClassDB::bind_method(_MD("seek","time"),&Tween::seek );
+ ClassDB::bind_method(_MD("tell"),&Tween::tell );
+ ClassDB::bind_method(_MD("get_runtime"),&Tween::get_runtime );
+
+ ClassDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) );
+ ClassDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) );
+ ClassDB::bind_method(_MD("interpolate_callback","object","duration","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
+ ClassDB::bind_method(_MD("interpolate_deferred_callback","object","duration","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
+ ClassDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","duration","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) );
+ ClassDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","duration","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) );
+ ClassDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) );
+ ClassDB::bind_method(_MD("targeting_method","object","method","initial","initial_method","final_val","duration","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) );
+
+ ADD_SIGNAL( MethodInfo("tween_started", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) );
- ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
+ ADD_SIGNAL( MethodInfo("tween_completed", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode"));
BIND_CONSTANT(TWEEN_PROCESS_FIXED);
BIND_CONSTANT(TWEEN_PROCESS_IDLE);
@@ -338,21 +339,21 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
Variant result;
#define APPLY_EQUATION(element)\
- r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.times_in_sec);
+ r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.duration);
switch(initial_val.get_type())
{
case Variant::BOOL:
- result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.times_in_sec)) >= 0.5;
+ result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5;
break;
case Variant::INT:
- result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.times_in_sec);
+ result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.duration);
break;
case Variant::REAL:
- result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec);
+ result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.duration);
break;
case Variant::VECTOR2:
@@ -382,11 +383,11 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
}
break;
- case Variant::MATRIX3:
+ case Variant::BASIS:
{
- Matrix3 i = initial_val;
- Matrix3 d = delta_val;
- Matrix3 r;
+ Basis i = initial_val;
+ Basis d = delta_val;
+ Basis r;
APPLY_EQUATION(elements[0][0]);
APPLY_EQUATION(elements[0][1]);
@@ -402,11 +403,11 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
}
break;
- case Variant::MATRIX32:
+ case Variant::TRANSFORM2D:
{
- Matrix3 i = initial_val;
- Matrix3 d = delta_val;
- Matrix3 r;
+ Basis i = initial_val;
+ Basis d = delta_val;
+ Basis r;
APPLY_EQUATION(elements[0][0]);
APPLY_EQUATION(elements[0][1]);
@@ -432,11 +433,11 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
result = r;
}
break;
- case Variant::_AABB:
+ case Variant::RECT3:
{
- AABB i = initial_val;
- AABB d = delta_val;
- AABB r;
+ Rect3 i = initial_val;
+ Rect3 d = delta_val;
+ Rect3 r;
APPLY_EQUATION(pos.x);
APPLY_EQUATION(pos.y);
@@ -572,13 +573,13 @@ void Tween::_tween_process(float p_delta) {
continue;
else if(prev_delaying) {
- emit_signal("tween_start",object,data.key);
+ emit_signal("tween_started",object,data.key);
_apply_tween_value(data, data.initial_val);
}
- if(data.elapsed > (data.delay + data.times_in_sec)) {
+ if(data.elapsed > (data.delay + data.duration)) {
- data.elapsed = data.delay + data.times_in_sec;
+ data.elapsed = data.delay + data.duration;
data.finish = true;
}
@@ -620,7 +621,7 @@ 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);
+ call_deferred("_remove", object, data.key, true);
}
continue;
}
@@ -631,10 +632,10 @@ void Tween::_tween_process(float p_delta) {
_apply_tween_value(data, result);
if (data.finish) {
- emit_signal("tween_complete",object,data.key);
+ emit_signal("tween_completed",object,data.key);
// not repeat mode, remove completed action
if (!repeat)
- call_deferred("remove", object, data.key);
+ call_deferred("_remove", object, data.key, true);
}
}
pending_update --;
@@ -665,8 +666,8 @@ void Tween::_set_process(bool p_process,bool p_force) {
switch(tween_process_mode) {
- case TWEEN_PROCESS_FIXED: set_fixed_process(p_process && active); break;
- case TWEEN_PROCESS_IDLE: set_process(p_process && active); break;
+ case TWEEN_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break;
+ case TWEEN_PROCESS_IDLE: set_process_internal(p_process && active); break;
}
processing=p_process;
@@ -696,12 +697,12 @@ void Tween::set_repeat(bool p_repeat) {
repeat = p_repeat;
}
-void Tween::set_speed(float p_speed) {
+void Tween::set_speed_scale(float p_speed) {
speed_scale=p_speed;
}
-float Tween::get_speed() const {
+float Tween::get_speed_scale() const {
return speed_scale;
}
@@ -723,7 +724,7 @@ bool Tween::reset(Object *p_object, String p_key) {
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key) {
+ if(object == p_object && (data.key == p_key || p_key == "")) {
data.elapsed = 0;
data.finish = false;
@@ -759,7 +760,7 @@ bool Tween::stop(Object *p_object, String p_key) {
Object *object = ObjectDB::get_instance(data.id);
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key)
+ if(object == p_object && (data.key == p_key || p_key == ""))
data.active = false;
}
pending_update --;
@@ -793,7 +794,7 @@ bool Tween::resume(Object *p_object, String p_key) {
Object *object = ObjectDB::get_instance(data.id);
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key)
+ if(object == p_object && (data.key == p_key || p_key == ""))
data.active = true;
}
pending_update --;
@@ -816,23 +817,33 @@ bool Tween::resume_all() {
}
bool Tween::remove(Object *p_object, String p_key) {
+ _remove(p_object, p_key, false);
+ return true;
+}
+
+void Tween::_remove(Object *p_object, String p_key, bool first_only) {
if(pending_update != 0) {
- call_deferred("remove", p_object, p_key);
- return true;
+ call_deferred("_remove", p_object, p_key, first_only);
+ return;
}
+ List<List<InterpolateData>::Element *> for_removal;
for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
InterpolateData& data = E->get();
Object *object = ObjectDB::get_instance(data.id);
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key) {
- interpolates.erase(E);
- return true;
+ if(object == p_object && (data.key == p_key || p_key == "")) {
+ for_removal.push_back(E);
+ if (first_only) {
+ break;
+ }
}
}
- return true;
+ for(List<List<InterpolateData>::Element *>::Element *E=for_removal.front();E;E=E->next()) {
+ interpolates.erase(E->get());
+ }
}
bool Tween::remove_all() {
@@ -860,10 +871,10 @@ bool Tween::seek(real_t p_time) {
data.finish = false;
continue;
}
- else if(data.elapsed >= (data.delay + data.times_in_sec)) {
+ else if(data.elapsed >= (data.delay + data.duration)) {
data.finish = true;
- data.elapsed = (data.delay + data.times_in_sec);
+ data.elapsed = (data.delay + data.duration);
} else
data.finish = false;
@@ -905,7 +916,7 @@ real_t Tween::get_runtime() const {
for(const List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
const InterpolateData& data = E->get();
- real_t t = data.delay + data.times_in_sec;
+ real_t t = data.delay + data.duration;
if(t > runtime)
runtime = t;
}
@@ -942,11 +953,11 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
delta_val = final_val.operator Vector3() - initial_val.operator Vector3();
break;
- case Variant::MATRIX3:
+ case Variant::BASIS:
{
- Matrix3 i = initial_val;
- Matrix3 f = final_val;
- delta_val = Matrix3(f.elements[0][0] - i.elements[0][0],
+ Basis i = initial_val;
+ Basis f = final_val;
+ delta_val = Basis(f.elements[0][0] - i.elements[0][0],
f.elements[0][1] - i.elements[0][1],
f.elements[0][2] - i.elements[0][2],
f.elements[1][0] - i.elements[1][0],
@@ -959,11 +970,11 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
}
break;
- case Variant::MATRIX32:
+ case Variant::TRANSFORM2D:
{
- Matrix32 i = initial_val;
- Matrix32 f = final_val;
- Matrix32 d = Matrix32();
+ Transform2D i = initial_val;
+ Transform2D f = final_val;
+ Transform2D d = Transform2D();
d[0][0] = f.elements[0][0] - i.elements[0][0];
d[0][1] = f.elements[0][1] - i.elements[0][1];
d[1][0] = f.elements[1][0] - i.elements[1][0];
@@ -976,11 +987,11 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
case Variant::QUAT:
delta_val = final_val.operator Quat() - initial_val.operator Quat();
break;
- case Variant::_AABB:
+ case Variant::RECT3:
{
- AABB i = initial_val;
- AABB f = final_val;
- delta_val = AABB(f.pos - i.pos, f.size - i.size);
+ Rect3 i = initial_val;
+ Rect3 f = final_val;
+ delta_val = Rect3(f.pos - i.pos, f.size - i.size);
}
break;
case Variant::TRANSFORM:
@@ -1024,7 +1035,7 @@ bool Tween::interpolate_property(Object *p_object
, String p_property
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1035,7 +1046,7 @@ bool Tween::interpolate_property(Object *p_object
, p_property
, p_initial_val
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1049,7 +1060,7 @@ bool Tween::interpolate_property(Object *p_object
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1068,7 +1079,7 @@ bool Tween::interpolate_property(Object *p_object
data.key = p_property;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1084,7 +1095,7 @@ bool Tween::interpolate_method(Object *p_object
, String p_method
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1095,7 +1106,7 @@ bool Tween::interpolate_method(Object *p_object
, p_method
, p_initial_val
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1109,7 +1120,7 @@ bool Tween::interpolate_method(Object *p_object
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1127,7 +1138,7 @@ bool Tween::interpolate_method(Object *p_object
data.key = p_method;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1140,7 +1151,7 @@ bool Tween::interpolate_method(Object *p_object
}
bool Tween::interpolate_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
) {
@@ -1148,7 +1159,7 @@ bool Tween::interpolate_callback(Object *p_object
if(pending_update != 0) {
_add_pending_command("interpolate_callback"
, p_object
- , p_times_in_sec
+ , p_duration
, p_callback
, p_arg1
, p_arg2
@@ -1161,7 +1172,7 @@ bool Tween::interpolate_callback(Object *p_object
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
- ERR_FAIL_COND_V(p_times_in_sec < 0, false);
+ ERR_FAIL_COND_V(p_duration < 0, false);
ERR_EXPLAIN("Object has no callback named: %s" + p_callback);
ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
@@ -1175,7 +1186,7 @@ bool Tween::interpolate_callback(Object *p_object
data.id = p_object->get_instance_ID();
data.key = p_callback;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.delay = 0;
int args=0;
@@ -1206,7 +1217,7 @@ bool Tween::interpolate_callback(Object *p_object
}
bool Tween::interpolate_deferred_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
) {
@@ -1214,7 +1225,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object
if(pending_update != 0) {
_add_pending_command("interpolate_deferred_callback"
, p_object
- , p_times_in_sec
+ , p_duration
, p_callback
, p_arg1
, p_arg2
@@ -1226,7 +1237,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object
}
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
- ERR_FAIL_COND_V(p_times_in_sec < 0, false);
+ ERR_FAIL_COND_V(p_duration < 0, false);
ERR_EXPLAIN("Object has no callback named: %s" + p_callback);
ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
@@ -1240,7 +1251,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object
data.id = p_object->get_instance_ID();
data.key = p_callback;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.delay = 0;
int args=0;
@@ -1275,7 +1286,7 @@ bool Tween::follow_property(Object *p_object
, Variant p_initial_val
, Object *p_target
, String p_target_property
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1287,7 +1298,7 @@ bool Tween::follow_property(Object *p_object
, p_initial_val
, p_target
, p_target_property
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1301,7 +1312,7 @@ bool Tween::follow_property(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_target == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_target), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1329,7 +1340,7 @@ bool Tween::follow_property(Object *p_object
data.initial_val = p_initial_val;
data.target_id = p_target->get_instance_ID();
data.target_key = p_target_property;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1343,7 +1354,7 @@ bool Tween::follow_method(Object *p_object
, Variant p_initial_val
, Object *p_target
, String p_target_method
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1355,7 +1366,7 @@ bool Tween::follow_method(Object *p_object
, p_initial_val
, p_target
, p_target_method
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1369,7 +1380,7 @@ bool Tween::follow_method(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_target == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_target), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1398,7 +1409,7 @@ bool Tween::follow_method(Object *p_object
data.initial_val = p_initial_val;
data.target_id = p_target->get_instance_ID();
data.target_key = p_target_method;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1412,7 +1423,7 @@ bool Tween::targeting_property(Object *p_object
, Object *p_initial
, String p_initial_property
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1424,7 +1435,7 @@ bool Tween::targeting_property(Object *p_object
, p_initial
, p_initial_property
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1438,7 +1449,7 @@ bool Tween::targeting_property(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_initial), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1467,7 +1478,7 @@ bool Tween::targeting_property(Object *p_object
data.target_key = p_initial_property;
data.initial_val = initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1485,7 +1496,7 @@ bool Tween::targeting_method(Object *p_object
, Object *p_initial
, String p_initial_method
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1497,7 +1508,7 @@ bool Tween::targeting_method(Object *p_object
, p_initial
, p_initial_method
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1511,7 +1522,7 @@ bool Tween::targeting_method(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_initial), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1541,7 +1552,7 @@ bool Tween::targeting_method(Object *p_object
data.target_key = p_initial_method;
data.initial_val = initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index d0455cdc71..07c2e90da2 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Tween : public Node {
- OBJ_TYPE( Tween, Node );
+ GDCLASS( Tween, Node );
public:
enum TweenProcessMode {
@@ -92,7 +92,7 @@ private:
Variant final_val;
ObjectID target_id;
StringName target_key;
- real_t times_in_sec;
+ real_t duration;
TransitionType trans_type;
EaseType ease_type;
real_t delay;
@@ -143,6 +143,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);
protected:
@@ -164,8 +165,8 @@ public:
void set_tween_process_mode(TweenProcessMode p_mode);
TweenProcessMode get_tween_process_mode() const;
- void set_speed(float p_speed);
- float get_speed() const;
+ void set_speed_scale(float p_speed);
+ float get_speed_scale() const;
bool start();
bool reset(Object *p_node, String p_key);
@@ -185,7 +186,7 @@ public:
, String p_property
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -195,20 +196,20 @@ public:
, String p_method
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
);
bool interpolate_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
);
bool interpolate_deferred_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
);
@@ -218,7 +219,7 @@ public:
, Variant p_initial_val
, Object *p_target
, String p_target_property
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -229,7 +230,7 @@ public:
, Variant p_initial_val
, Object *p_target
, String p_target_method
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -240,7 +241,7 @@ public:
, Object *p_initial
, String p_initial_property
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -251,7 +252,7 @@ public:
, Object *p_initial
, String p_initial_method
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp
index 058a7f12bc..5ba9673014 100644
--- a/scene/animation/tween_interpolaters.cpp
+++ b/scene/animation/tween_interpolaters.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/audio/SCsub b/scene/audio/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/audio/SCsub
+++ b/scene/audio/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/audio/event_player.cpp b/scene/audio/event_player.cpp
index f43c3c2a59..c46f4e3b89 100644
--- a/scene/audio/event_player.cpp
+++ b/scene/audio/event_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -282,58 +282,58 @@ float EventPlayer::get_channel_last_note_time(int p_channel) const {
void EventPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:EventStream"),&EventPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:EventStream"),&EventPlayer::get_stream);
+ ClassDB::bind_method(_MD("set_stream","stream:EventStream"),&EventPlayer::set_stream);
+ ClassDB::bind_method(_MD("get_stream:EventStream"),&EventPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play"),&EventPlayer::play);
- ObjectTypeDB::bind_method(_MD("stop"),&EventPlayer::stop);
+ ClassDB::bind_method(_MD("play"),&EventPlayer::play);
+ ClassDB::bind_method(_MD("stop"),&EventPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&EventPlayer::is_playing);
+ ClassDB::bind_method(_MD("is_playing"),&EventPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&EventPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&EventPlayer::is_paused);
+ ClassDB::bind_method(_MD("set_paused","paused"),&EventPlayer::set_paused);
+ ClassDB::bind_method(_MD("is_paused"),&EventPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&EventPlayer::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&EventPlayer::has_loop);
+ ClassDB::bind_method(_MD("set_loop","enabled"),&EventPlayer::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&EventPlayer::has_loop);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&EventPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&EventPlayer::get_volume);
+ ClassDB::bind_method(_MD("set_volume","volume"),&EventPlayer::set_volume);
+ ClassDB::bind_method(_MD("get_volume"),&EventPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&EventPlayer::set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("get_pitch_scale"),&EventPlayer::get_pitch_scale);
+ ClassDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&EventPlayer::set_pitch_scale);
+ ClassDB::bind_method(_MD("get_pitch_scale"),&EventPlayer::get_pitch_scale);
- ObjectTypeDB::bind_method(_MD("set_tempo_scale","tempo_scale"),&EventPlayer::set_tempo_scale);
- ObjectTypeDB::bind_method(_MD("get_tempo_scale"),&EventPlayer::get_tempo_scale);
+ ClassDB::bind_method(_MD("set_tempo_scale","tempo_scale"),&EventPlayer::set_tempo_scale);
+ ClassDB::bind_method(_MD("get_tempo_scale"),&EventPlayer::get_tempo_scale);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&EventPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&EventPlayer::get_volume_db);
+ ClassDB::bind_method(_MD("set_volume_db","db"),&EventPlayer::set_volume_db);
+ ClassDB::bind_method(_MD("get_volume_db"),&EventPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&EventPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&EventPlayer::get_loop_count);
+ ClassDB::bind_method(_MD("get_stream_name"),&EventPlayer::get_stream_name);
+ ClassDB::bind_method(_MD("get_loop_count"),&EventPlayer::get_loop_count);
- ObjectTypeDB::bind_method(_MD("get_pos"),&EventPlayer::get_pos);
- ObjectTypeDB::bind_method(_MD("seek_pos","time"),&EventPlayer::seek_pos);
+ ClassDB::bind_method(_MD("get_pos"),&EventPlayer::get_pos);
+ ClassDB::bind_method(_MD("seek_pos","time"),&EventPlayer::seek_pos);
- ObjectTypeDB::bind_method(_MD("get_length"),&EventPlayer::get_length);
+ ClassDB::bind_method(_MD("get_length"),&EventPlayer::get_length);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&EventPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&EventPlayer::has_autoplay);
+ ClassDB::bind_method(_MD("set_autoplay","enabled"),&EventPlayer::set_autoplay);
+ ClassDB::bind_method(_MD("has_autoplay"),&EventPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("set_channel_volume","channel","channel_volume"),&EventPlayer::set_channel_volume);
- ObjectTypeDB::bind_method(_MD("get_channel_volume","channel"),&EventPlayer::get_channel_volume);
- ObjectTypeDB::bind_method(_MD("get_channel_last_note_time","channel"),&EventPlayer::get_channel_last_note_time);
+ ClassDB::bind_method(_MD("set_channel_volume","channel","channel_volume"),&EventPlayer::set_channel_volume);
+ ClassDB::bind_method(_MD("get_channel_volume","channel"),&EventPlayer::get_channel_volume);
+ ClassDB::bind_method(_MD("get_channel_last_note_time","channel"),&EventPlayer::get_channel_last_note_time);
- ObjectTypeDB::bind_method(_MD("_set_play","play"),&EventPlayer::_set_play);
- ObjectTypeDB::bind_method(_MD("_get_play"),&EventPlayer::_get_play);
+ ClassDB::bind_method(_MD("_set_play","play"),&EventPlayer::_set_play);
+ ClassDB::bind_method(_MD("_get_play"),&EventPlayer::_get_play);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"EventStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/pitch_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_pitch_scale"), _SCS("get_pitch_scale") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/tempo_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_tempo_scale"), _SCS("get_tempo_scale") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"EventStream"), _SCS("set_stream"), _SCS("get_stream") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_pitch_scale"), _SCS("get_pitch_scale") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "tempo_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_tempo_scale"), _SCS("get_tempo_scale") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
}
diff --git a/scene/audio/event_player.h b/scene/audio/event_player.h
index c04e85fe77..715017e0d6 100644
--- a/scene/audio/event_player.h
+++ b/scene/audio/event_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#include "scene/resources/event_stream.h"
class EventPlayer : public Node {
- OBJ_TYPE(EventPlayer,Node);
+ GDCLASS(EventPlayer,Node);
enum {
diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp
index 3827d40a71..ba2d379311 100644
--- a/scene/audio/sample_player.cpp
+++ b/scene/audio/sample_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -611,64 +611,64 @@ String SamplePlayer::get_configuration_warning() const {
void SamplePlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer::set_sample_library );
- ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer::get_sample_library );
-
- ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer::set_polyphony );
- ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer::get_polyphony );
-
- ObjectTypeDB::bind_method(_MD("play","name","unique"),&SamplePlayer::play, DEFVAL(false) );
- ObjectTypeDB::bind_method(_MD("stop","voice"),&SamplePlayer::stop );
- ObjectTypeDB::bind_method(_MD("stop_all"),&SamplePlayer::stop_all );
-
- ObjectTypeDB::bind_method(_MD("set_mix_rate","voice","hz"),&SamplePlayer::set_mix_rate );
- ObjectTypeDB::bind_method(_MD("set_pitch_scale","voice","ratio"),&SamplePlayer::set_pitch_scale );
- ObjectTypeDB::bind_method(_MD("set_volume","voice","volume"),&SamplePlayer::set_volume );
- ObjectTypeDB::bind_method(_MD("set_volume_db","voice","db"),&SamplePlayer::set_volume_db );
- ObjectTypeDB::bind_method(_MD("set_pan","voice","pan","depth","height"),&SamplePlayer::set_pan,DEFVAL(0),DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_filter","voice","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_filter,DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_chorus","voice","send"),&SamplePlayer::set_chorus );
- ObjectTypeDB::bind_method(_MD("set_reverb","voice","room_type","send"),&SamplePlayer::set_reverb );
-
- ObjectTypeDB::bind_method(_MD("get_mix_rate","voice"),&SamplePlayer::get_mix_rate );
- ObjectTypeDB::bind_method(_MD("get_pitch_scale","voice"),&SamplePlayer::get_pitch_scale );
- ObjectTypeDB::bind_method(_MD("get_volume","voice"),&SamplePlayer::get_volume );
- ObjectTypeDB::bind_method(_MD("get_volume_db","voice"),&SamplePlayer::get_volume_db );
- ObjectTypeDB::bind_method(_MD("get_pan","voice"),&SamplePlayer::get_pan );
- ObjectTypeDB::bind_method(_MD("get_pan_depth","voice"),&SamplePlayer::get_pan_depth );
- ObjectTypeDB::bind_method(_MD("get_pan_height","voice"),&SamplePlayer::get_pan_height );
- ObjectTypeDB::bind_method(_MD("get_filter_type","voice"),&SamplePlayer::get_filter_type );
- ObjectTypeDB::bind_method(_MD("get_filter_cutoff","voice"),&SamplePlayer::get_filter_cutoff );
- ObjectTypeDB::bind_method(_MD("get_filter_resonance","voice"),&SamplePlayer::get_filter_resonance );
- ObjectTypeDB::bind_method(_MD("get_filter_gain","voice"),&SamplePlayer::get_filter_gain );
- ObjectTypeDB::bind_method(_MD("get_chorus","voice"),&SamplePlayer::get_chorus );
- ObjectTypeDB::bind_method(_MD("get_reverb_room","voice"),&SamplePlayer::get_reverb_room );
- ObjectTypeDB::bind_method(_MD("get_reverb","voice"),&SamplePlayer::get_reverb );
-
- ObjectTypeDB::bind_method(_MD("set_default_pitch_scale","ratio"),&SamplePlayer::set_default_pitch_scale );
- ObjectTypeDB::bind_method(_MD("set_default_volume","volume"),&SamplePlayer::set_default_volume );
- ObjectTypeDB::bind_method(_MD("set_default_volume_db","db"),&SamplePlayer::set_default_volume_db );
- ObjectTypeDB::bind_method(_MD("set_default_pan","pan","depth","height"),&SamplePlayer::set_default_pan,DEFVAL(0),DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_default_filter","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_default_filter,DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_default_chorus","send"),&SamplePlayer::set_default_chorus );
- ObjectTypeDB::bind_method(_MD("set_default_reverb","room_type","send"),&SamplePlayer::set_default_reverb );
-
- ObjectTypeDB::bind_method(_MD("get_default_pitch_scale"),&SamplePlayer::get_default_pitch_scale );
- ObjectTypeDB::bind_method(_MD("get_default_volume"),&SamplePlayer::get_default_volume );
- ObjectTypeDB::bind_method(_MD("get_default_volume_db"),&SamplePlayer::get_default_volume_db );
- ObjectTypeDB::bind_method(_MD("get_default_pan"),&SamplePlayer::get_default_pan );
- ObjectTypeDB::bind_method(_MD("get_default_pan_depth"),&SamplePlayer::get_default_pan_depth );
- ObjectTypeDB::bind_method(_MD("get_default_pan_height"),&SamplePlayer::get_default_pan_height );
- ObjectTypeDB::bind_method(_MD("get_default_filter_type"),&SamplePlayer::get_default_filter_type );
- ObjectTypeDB::bind_method(_MD("get_default_filter_cutoff"),&SamplePlayer::get_default_filter_cutoff );
- ObjectTypeDB::bind_method(_MD("get_default_filter_resonance"),&SamplePlayer::get_default_filter_resonance );
- ObjectTypeDB::bind_method(_MD("get_default_filter_gain"),&SamplePlayer::get_default_filter_gain );
- ObjectTypeDB::bind_method(_MD("get_default_chorus"),&SamplePlayer::get_default_chorus );
- ObjectTypeDB::bind_method(_MD("get_default_reverb_room"),&SamplePlayer::get_default_reverb_room );
- ObjectTypeDB::bind_method(_MD("get_default_reverb"),&SamplePlayer::get_default_reverb );
-
- ObjectTypeDB::bind_method(_MD("is_active"),&SamplePlayer::is_active );
- ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer::is_voice_active );
+ ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer::set_sample_library );
+ ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer::get_sample_library );
+
+ ClassDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer::set_polyphony );
+ ClassDB::bind_method(_MD("get_polyphony"),&SamplePlayer::get_polyphony );
+
+ ClassDB::bind_method(_MD("play","name","unique"),&SamplePlayer::play, DEFVAL(false) );
+ ClassDB::bind_method(_MD("stop","voice"),&SamplePlayer::stop );
+ ClassDB::bind_method(_MD("stop_all"),&SamplePlayer::stop_all );
+
+ ClassDB::bind_method(_MD("set_mix_rate","voice","hz"),&SamplePlayer::set_mix_rate );
+ ClassDB::bind_method(_MD("set_pitch_scale","voice","ratio"),&SamplePlayer::set_pitch_scale );
+ ClassDB::bind_method(_MD("set_volume","voice","volume"),&SamplePlayer::set_volume );
+ ClassDB::bind_method(_MD("set_volume_db","voice","db"),&SamplePlayer::set_volume_db );
+ ClassDB::bind_method(_MD("set_pan","voice","pan","depth","height"),&SamplePlayer::set_pan,DEFVAL(0),DEFVAL(0) );
+ ClassDB::bind_method(_MD("set_filter","voice","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_filter,DEFVAL(0) );
+ ClassDB::bind_method(_MD("set_chorus","voice","send"),&SamplePlayer::set_chorus );
+ ClassDB::bind_method(_MD("set_reverb","voice","room_type","send"),&SamplePlayer::set_reverb );
+
+ ClassDB::bind_method(_MD("get_mix_rate","voice"),&SamplePlayer::get_mix_rate );
+ ClassDB::bind_method(_MD("get_pitch_scale","voice"),&SamplePlayer::get_pitch_scale );
+ ClassDB::bind_method(_MD("get_volume","voice"),&SamplePlayer::get_volume );
+ ClassDB::bind_method(_MD("get_volume_db","voice"),&SamplePlayer::get_volume_db );
+ ClassDB::bind_method(_MD("get_pan","voice"),&SamplePlayer::get_pan );
+ ClassDB::bind_method(_MD("get_pan_depth","voice"),&SamplePlayer::get_pan_depth );
+ ClassDB::bind_method(_MD("get_pan_height","voice"),&SamplePlayer::get_pan_height );
+ ClassDB::bind_method(_MD("get_filter_type","voice"),&SamplePlayer::get_filter_type );
+ ClassDB::bind_method(_MD("get_filter_cutoff","voice"),&SamplePlayer::get_filter_cutoff );
+ ClassDB::bind_method(_MD("get_filter_resonance","voice"),&SamplePlayer::get_filter_resonance );
+ ClassDB::bind_method(_MD("get_filter_gain","voice"),&SamplePlayer::get_filter_gain );
+ ClassDB::bind_method(_MD("get_chorus","voice"),&SamplePlayer::get_chorus );
+ ClassDB::bind_method(_MD("get_reverb_room","voice"),&SamplePlayer::get_reverb_room );
+ ClassDB::bind_method(_MD("get_reverb","voice"),&SamplePlayer::get_reverb );
+
+ ClassDB::bind_method(_MD("set_default_pitch_scale","ratio"),&SamplePlayer::set_default_pitch_scale );
+ ClassDB::bind_method(_MD("set_default_volume","volume"),&SamplePlayer::set_default_volume );
+ ClassDB::bind_method(_MD("set_default_volume_db","db"),&SamplePlayer::set_default_volume_db );
+ ClassDB::bind_method(_MD("set_default_pan","pan","depth","height"),&SamplePlayer::set_default_pan,DEFVAL(0),DEFVAL(0) );
+ ClassDB::bind_method(_MD("set_default_filter","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_default_filter,DEFVAL(0) );
+ ClassDB::bind_method(_MD("set_default_chorus","send"),&SamplePlayer::set_default_chorus );
+ ClassDB::bind_method(_MD("set_default_reverb","room_type","send"),&SamplePlayer::set_default_reverb );
+
+ ClassDB::bind_method(_MD("get_default_pitch_scale"),&SamplePlayer::get_default_pitch_scale );
+ ClassDB::bind_method(_MD("get_default_volume"),&SamplePlayer::get_default_volume );
+ ClassDB::bind_method(_MD("get_default_volume_db"),&SamplePlayer::get_default_volume_db );
+ ClassDB::bind_method(_MD("get_default_pan"),&SamplePlayer::get_default_pan );
+ ClassDB::bind_method(_MD("get_default_pan_depth"),&SamplePlayer::get_default_pan_depth );
+ ClassDB::bind_method(_MD("get_default_pan_height"),&SamplePlayer::get_default_pan_height );
+ ClassDB::bind_method(_MD("get_default_filter_type"),&SamplePlayer::get_default_filter_type );
+ ClassDB::bind_method(_MD("get_default_filter_cutoff"),&SamplePlayer::get_default_filter_cutoff );
+ ClassDB::bind_method(_MD("get_default_filter_resonance"),&SamplePlayer::get_default_filter_resonance );
+ ClassDB::bind_method(_MD("get_default_filter_gain"),&SamplePlayer::get_default_filter_gain );
+ ClassDB::bind_method(_MD("get_default_chorus"),&SamplePlayer::get_default_chorus );
+ ClassDB::bind_method(_MD("get_default_reverb_room"),&SamplePlayer::get_default_reverb_room );
+ ClassDB::bind_method(_MD("get_default_reverb"),&SamplePlayer::get_default_reverb );
+
+ ClassDB::bind_method(_MD("is_active"),&SamplePlayer::is_active );
+ ClassDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer::is_voice_active );
BIND_CONSTANT( FILTER_NONE);
BIND_CONSTANT( FILTER_LOWPASS);
diff --git a/scene/audio/sample_player.h b/scene/audio/sample_player.h
index 833fac3868..8c4e6418aa 100644
--- a/scene/audio/sample_player.h
+++ b/scene/audio/sample_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class SamplePlayer : public Node {
- OBJ_TYPE( SamplePlayer, Node );
+ GDCLASS( SamplePlayer, Node );
OBJ_CATEGORY("Audio Nodes");
public:
diff --git a/scene/audio/sound_room_params.cpp b/scene/audio/sound_room_params.cpp
index bb2285c97f..d08bc5d6b8 100644
--- a/scene/audio/sound_room_params.cpp
+++ b/scene/audio/sound_room_params.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -134,14 +134,14 @@ bool SoundRoomParams::is_forcing_params_to_all_sources() {
void SoundRoomParams::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SoundRoomParams::set_param );
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SoundRoomParams::get_param );
+ ClassDB::bind_method(_MD("set_param","param","value"),&SoundRoomParams::set_param );
+ ClassDB::bind_method(_MD("get_param","param"),&SoundRoomParams::get_param );
- ObjectTypeDB::bind_method(_MD("set_reverb_mode","reverb_mode","value"),&SoundRoomParams::set_reverb_mode );
- ObjectTypeDB::bind_method(_MD("get_reverb_mode","reverb_mode"),&SoundRoomParams::get_reverb_mode );
+ ClassDB::bind_method(_MD("set_reverb_mode","reverb_mode","value"),&SoundRoomParams::set_reverb_mode );
+ ClassDB::bind_method(_MD("get_reverb_mode","reverb_mode"),&SoundRoomParams::get_reverb_mode );
- ObjectTypeDB::bind_method(_MD("set_force_params_to_all_sources","enabled"),&SoundRoomParams::set_force_params_to_all_sources );
- ObjectTypeDB::bind_method(_MD("is_forcing_params_to_all_sources"),&SoundRoomParams::is_forcing_params_to_all_sources );
+ ClassDB::bind_method(_MD("set_force_params_to_all_sources","enabled"),&SoundRoomParams::set_force_params_to_all_sources );
+ ClassDB::bind_method(_MD("is_forcing_params_to_all_sources"),&SoundRoomParams::is_forcing_params_to_all_sources );
ADD_PROPERTY( PropertyInfo( Variant::INT, "reverb/mode", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"), _SCS("set_reverb_mode"), _SCS("get_reverb_mode") );
diff --git a/scene/audio/sound_room_params.h b/scene/audio/sound_room_params.h
index 4ca1eae2ce..3cdffda652 100644
--- a/scene/audio/sound_room_params.h
+++ b/scene/audio/sound_room_params.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
#include "scene/3d/room_instance.h"
class SoundRoomParams : public Node {
- OBJ_TYPE( SoundRoomParams, Node );
+ GDCLASS( SoundRoomParams, Node );
public:
enum Params {
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
index 99ecace1ed..9e506034a6 100644
--- a/scene/audio/stream_player.cpp
+++ b/scene/audio/stream_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -167,8 +167,10 @@ void StreamPlayer::play(float p_from_offset) {
sp_update();
AudioServer::get_singleton()->stream_set_active(stream_rid,true);
AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-// if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
-// set_idle_process(true);
+ /*
+ if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
+ set_idle_process(true);
+ */
}
@@ -305,8 +307,10 @@ bool StreamPlayer::has_autoplay() const {
void StreamPlayer::set_paused(bool p_paused) {
paused=p_paused;
- //if (stream.is_valid())
- // stream->set_paused(p_paused);
+ /*
+ if (stream.is_valid())
+ stream->set_paused(p_paused);
+ */
}
bool StreamPlayer::is_paused() const {
@@ -345,55 +349,55 @@ int StreamPlayer::get_buffering_msec() const{
void StreamPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:AudioStream"),&StreamPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:AudioStream"),&StreamPlayer::get_stream);
+ ClassDB::bind_method(_MD("set_stream","stream:AudioStream"),&StreamPlayer::set_stream);
+ ClassDB::bind_method(_MD("get_stream:AudioStream"),&StreamPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play","offset"),&StreamPlayer::play,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("stop"),&StreamPlayer::stop);
+ ClassDB::bind_method(_MD("play","offset"),&StreamPlayer::play,DEFVAL(0));
+ ClassDB::bind_method(_MD("stop"),&StreamPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&StreamPlayer::is_playing);
+ ClassDB::bind_method(_MD("is_playing"),&StreamPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&StreamPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&StreamPlayer::is_paused);
+ ClassDB::bind_method(_MD("set_paused","paused"),&StreamPlayer::set_paused);
+ ClassDB::bind_method(_MD("is_paused"),&StreamPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&StreamPlayer::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&StreamPlayer::has_loop);
+ ClassDB::bind_method(_MD("set_loop","enabled"),&StreamPlayer::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&StreamPlayer::has_loop);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&StreamPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&StreamPlayer::get_volume);
+ ClassDB::bind_method(_MD("set_volume","volume"),&StreamPlayer::set_volume);
+ ClassDB::bind_method(_MD("get_volume"),&StreamPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&StreamPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&StreamPlayer::get_volume_db);
+ ClassDB::bind_method(_MD("set_volume_db","db"),&StreamPlayer::set_volume_db);
+ ClassDB::bind_method(_MD("get_volume_db"),&StreamPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&StreamPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&StreamPlayer::get_buffering_msec);
+ ClassDB::bind_method(_MD("set_buffering_msec","msec"),&StreamPlayer::set_buffering_msec);
+ ClassDB::bind_method(_MD("get_buffering_msec"),&StreamPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("set_loop_restart_time","secs"),&StreamPlayer::set_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_loop_restart_time"),&StreamPlayer::get_loop_restart_time);
+ ClassDB::bind_method(_MD("set_loop_restart_time","secs"),&StreamPlayer::set_loop_restart_time);
+ ClassDB::bind_method(_MD("get_loop_restart_time"),&StreamPlayer::get_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&StreamPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&StreamPlayer::get_loop_count);
+ ClassDB::bind_method(_MD("get_stream_name"),&StreamPlayer::get_stream_name);
+ ClassDB::bind_method(_MD("get_loop_count"),&StreamPlayer::get_loop_count);
- ObjectTypeDB::bind_method(_MD("get_pos"),&StreamPlayer::get_pos);
- ObjectTypeDB::bind_method(_MD("seek_pos","time"),&StreamPlayer::seek_pos);
+ ClassDB::bind_method(_MD("get_pos"),&StreamPlayer::get_pos);
+ ClassDB::bind_method(_MD("seek_pos","time"),&StreamPlayer::seek_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&StreamPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&StreamPlayer::has_autoplay);
+ ClassDB::bind_method(_MD("set_autoplay","enabled"),&StreamPlayer::set_autoplay);
+ ClassDB::bind_method(_MD("has_autoplay"),&StreamPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("get_length"),&StreamPlayer::get_length);
+ ClassDB::bind_method(_MD("get_length"),&StreamPlayer::get_length);
- ObjectTypeDB::bind_method(_MD("_set_play","play"),&StreamPlayer::_set_play);
- ObjectTypeDB::bind_method(_MD("_get_play"),&StreamPlayer::_get_play);
- ObjectTypeDB::bind_method(_MD("_do_stop"),&StreamPlayer::_do_stop);
+ ClassDB::bind_method(_MD("_set_play","play"),&StreamPlayer::_set_play);
+ ClassDB::bind_method(_MD("_get_play"),&StreamPlayer::_get_play);
+ ClassDB::bind_method(_MD("_do_stop"),&StreamPlayer::_do_stop);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
ADD_SIGNAL(MethodInfo("finished"));
}
diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h
index 4facc3c816..6031d86aa2 100644
--- a/scene/audio/stream_player.h
+++ b/scene/audio/stream_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class StreamPlayer : public Node {
- OBJ_TYPE(StreamPlayer,Node);
+ GDCLASS(StreamPlayer,Node);
//_THREAD_SAFE_CLASS_
diff --git a/scene/gui/SCsub b/scene/gui/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/gui/SCsub
+++ b/scene/gui/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 6479dd2d02..0b40983ddf 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,11 +29,24 @@
#include "base_button.h"
#include "os/keyboard.h"
#include "print_string.h"
-#include "button_group.h"
#include "scene/scene_string_names.h"
#include "scene/main/viewport.h"
-void BaseButton::_input_event(InputEvent p_event) {
+
+void BaseButton::_unpress_group() {
+
+ if (!button_group.is_valid())
+ return;
+
+ for (Set<BaseButton*>::Element *E=button_group->buttons.front();E;E=E->next()) {
+ if (E->get()==this)
+ continue;
+
+ E->get()->set_pressed(false);
+ }
+}
+
+void BaseButton::_gui_input(InputEvent p_event) {
if (status.disabled) // no interaction with disabled button
@@ -51,7 +64,7 @@ void BaseButton::_input_event(InputEvent p_event) {
if (status.pressing_button)
break;
- if (status.click_on_press) {
+ if (action_mode==ACTION_MODE_BUTTON_PRESS) {
if (b.pressed) {
@@ -69,6 +82,8 @@ void BaseButton::_input_event(InputEvent p_event) {
}
emit_signal("pressed");
+ _unpress_group();
+
} else {
@@ -79,6 +94,8 @@ void BaseButton::_input_event(InputEvent p_event) {
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
}
emit_signal("pressed");
+ _unpress_group();
+
toggled(status.pressed);
emit_signal("toggled",status.pressed);
@@ -90,10 +107,11 @@ void BaseButton::_input_event(InputEvent p_event) {
emit_signal("button_up");
- if (status.press_attempt && status.pressing_inside) {
-// released();
+/* this is pointless if (status.press_attempt && status.pressing_inside) {
+ //released();
emit_signal("released");
}
+*/
status.press_attempt=false;
}
update();
@@ -138,6 +156,9 @@ void BaseButton::_input_event(InputEvent p_event) {
}
+ _unpress_group();
+
+
}
status.press_attempt=false;
@@ -156,7 +177,7 @@ void BaseButton::_input_event(InputEvent p_event) {
}
} break;
case InputEvent::ACTION:
- case InputEvent::JOYSTICK_BUTTON:
+ case InputEvent::JOYPAD_BUTTON:
case InputEvent::KEY: {
@@ -211,6 +232,9 @@ void BaseButton::_input_event(InputEvent p_event) {
}
emit_signal("toggled",status.pressed);
}
+
+ _unpress_group();
+
}
accept_event();
@@ -243,39 +267,37 @@ void BaseButton::_notification(int p_what) {
update();
}
}
+
+ if (p_what==NOTIFICATION_FOCUS_ENTER) {
+
+ status.hovering=true;
+ update();
+ }
if (p_what==NOTIFICATION_FOCUS_EXIT) {
if (status.pressing_button && status.press_attempt) {
status.press_attempt=false;
status.pressing_button=0;
+ status.hovering=false;
+ update();
+ } else if (status.hovering) {
+ status.hovering=false;
update();
}
}
if (p_what==NOTIFICATION_ENTER_TREE) {
- CanvasItem *ci=this;
- while(ci) {
-
- ButtonGroup *bg = ci->cast_to<ButtonGroup>();
- if (bg) {
-
- group=bg;
- group->_add_button(this);
- }
- ci=ci->get_parent_item();
- }
}
if (p_what==NOTIFICATION_EXIT_TREE) {
- if (group)
- group->_remove_button(this);
+
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) {
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree()) {
if (!toggle_mode) {
status.pressed = false;
@@ -295,8 +317,9 @@ void BaseButton::pressed() {
void BaseButton::toggled(bool p_pressed) {
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("toggled",p_pressed);
+ }
}
@@ -325,6 +348,11 @@ void BaseButton::set_pressed(bool p_pressed) {
return;
_change_notify("pressed");
status.pressed=p_pressed;
+
+ if (p_pressed) {
+ _unpress_group();
+
+ }
update();
}
@@ -387,14 +415,14 @@ bool BaseButton::is_toggle_mode() const {
return toggle_mode;
}
-void BaseButton::set_click_on_press(bool p_click_on_press) {
+void BaseButton::set_action_mode(ActionMode p_mode) {
- status.click_on_press=p_click_on_press;
+ action_mode=p_mode;
}
-bool BaseButton::get_click_on_press() const {
+BaseButton::ActionMode BaseButton::get_action_mode() const {
- return status.click_on_press;
+ return action_mode;
}
void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
@@ -425,7 +453,7 @@ Ref<ShortCut> BaseButton:: get_shortcut() const {
void BaseButton::_unhandled_input(InputEvent p_event) {
- if (!is_disabled() && is_visible() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+ if (!is_disabled() && is_visible_in_tree() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
return; //ignore because of modal window
@@ -452,39 +480,66 @@ String BaseButton::get_tooltip(const Point2& p_pos) const {
return tooltip;
}
+
+void BaseButton::set_button_group(const Ref<ButtonGroup>& p_group) {
+
+ if (button_group.is_valid()) {
+ button_group->buttons.erase(this);
+ }
+
+ button_group=p_group;
+
+ if (button_group.is_valid()) {
+ button_group->buttons.insert(this);
+ }
+
+ update(); //checkbox changes to radio if set a buttongroup
+
+}
+
+Ref<ButtonGroup> BaseButton::get_button_group() const {
+
+ return button_group;
+}
+
+
void BaseButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&BaseButton::_input_event);
- ObjectTypeDB::bind_method(_MD("_unhandled_input"),&BaseButton::_unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
- ObjectTypeDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
- ObjectTypeDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
- ObjectTypeDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
- ObjectTypeDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
- ObjectTypeDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
- ObjectTypeDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
- ObjectTypeDB::bind_method(_MD("set_click_on_press","enable"),&BaseButton::set_click_on_press);
- ObjectTypeDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
- ObjectTypeDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
- ObjectTypeDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
- ObjectTypeDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
- ObjectTypeDB::bind_method(_MD("set_shortcut","shortcut"),&BaseButton::set_shortcut);
- ObjectTypeDB::bind_method(_MD("get_shortcut"),&BaseButton::get_shortcut);
+ ClassDB::bind_method(_MD("_gui_input"),&BaseButton::_gui_input);
+ ClassDB::bind_method(_MD("_unhandled_input"),&BaseButton::_unhandled_input);
+ ClassDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
+ ClassDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
+ ClassDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
+ ClassDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
+ ClassDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
+ ClassDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
+ ClassDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
+ ClassDB::bind_method(_MD("set_action_mode","mode"),&BaseButton::set_action_mode);
+ ClassDB::bind_method(_MD("get_action_mode"),&BaseButton::get_action_mode);
+ ClassDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
+ ClassDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
+ ClassDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
+
+ ClassDB::bind_method(_MD("set_shortcut","shortcut"),&BaseButton::set_shortcut);
+ ClassDB::bind_method(_MD("get_shortcut"),&BaseButton::get_shortcut);
+
+ ClassDB::bind_method(_MD("set_button_group","button_group"),&BaseButton::set_button_group);
+ ClassDB::bind_method(_MD("get_button_group"),&BaseButton::get_button_group);
BIND_VMETHOD(MethodInfo("_pressed"));
BIND_VMETHOD(MethodInfo("_toggled",PropertyInfo(Variant::BOOL,"pressed")));
ADD_SIGNAL( MethodInfo("pressed" ) );
- ADD_SIGNAL( MethodInfo("released" ) );
ADD_SIGNAL( MethodInfo("button_up") );
ADD_SIGNAL( MethodInfo("button_down") );
ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "action_mode",PROPERTY_HINT_ENUM,"Button Press,Button Release"), _SCS("set_action_mode"), _SCS("get_action_mode"));
ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode") );
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "group",PROPERTY_HINT_RESOURCE_TYPE,"ButtonGroup"), _SCS("set_button_group"), _SCS("get_button_group"));
BIND_CONSTANT( DRAW_NORMAL );
@@ -492,6 +547,10 @@ void BaseButton::_bind_methods() {
BIND_CONSTANT( DRAW_HOVER );
BIND_CONSTANT( DRAW_DISABLED );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_PRESS );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_RELEASE );
+
+
}
BaseButton::BaseButton() {
@@ -502,11 +561,15 @@ BaseButton::BaseButton() {
status.hovering=false;
status.pressing_inside=false;
status.disabled = false;
- status.click_on_press=false;
status.pressing_button=0;
set_focus_mode( FOCUS_ALL );
enabled_focus_mode = FOCUS_ALL;
- group=NULL;
+ action_mode=ACTION_MODE_BUTTON_RELEASE;
+
+
+ if (button_group.is_valid()) {
+ button_group->buttons.erase(this);
+ }
}
@@ -515,4 +578,30 @@ BaseButton::~BaseButton()
{
}
+void ButtonGroup::get_buttons(List<BaseButton*> *r_buttons) {
+
+ for (Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ r_buttons->push_back(E->get());
+ }
+}
+
+BaseButton* ButtonGroup::get_pressed_button() {
+
+ for (Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ if (E->get()->is_pressed())
+ return E->get();
+ }
+
+ return NULL;
+}
+
+void ButtonGroup::_bind_methods() {
+
+ ClassDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
+}
+
+ButtonGroup::ButtonGroup() {
+
+ set_local_to_scene(true);
+}
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 0056b00f33..def4ff7536 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,12 +39,21 @@ class ButtonGroup;
class BaseButton : public Control {
- OBJ_TYPE( BaseButton, Control );
+ GDCLASS( BaseButton, Control );
+public:
+
+ enum ActionMode {
+ ACTION_MODE_BUTTON_PRESS,
+ ACTION_MODE_BUTTON_RELEASE,
+ };
+
+private:
bool toggle_mode;
FocusMode enabled_focus_mode;
Ref<ShortCut> shortcut;
+ ActionMode action_mode;
struct Status {
bool pressed;
@@ -53,15 +62,16 @@ class BaseButton : public Control {
bool pressing_inside;
bool disabled;
- bool click_on_press;
int pressing_button;
} status;
- ButtonGroup *group;
+ Ref<ButtonGroup> button_group;
+ void _unpress_group();
+
protected:
@@ -70,7 +80,7 @@ protected:
virtual void pressed();
virtual void toggled(bool p_pressed);
static void _bind_methods();
- virtual void _input_event(InputEvent p_event);
+ virtual void _gui_input(InputEvent p_event);
virtual void _unhandled_input(InputEvent p_event);
void _notification(int p_what);
@@ -98,8 +108,8 @@ public:
void set_disabled(bool p_disabled);
bool is_disabled() const;
- void set_click_on_press(bool p_click_on_press);
- bool get_click_on_press() const;
+ void set_action_mode(ActionMode p_mode);
+ ActionMode get_action_mode() const;
void set_enabled_focus_mode(FocusMode p_mode);
FocusMode get_enabled_focus_mode() const;
@@ -109,11 +119,31 @@ public:
virtual String get_tooltip(const Point2& p_pos) const;
+ void set_button_group(const Ref<ButtonGroup>& p_group);
+ Ref<ButtonGroup> get_button_group() const;
+
BaseButton();
~BaseButton();
};
-VARIANT_ENUM_CAST( BaseButton::DrawMode );
+VARIANT_ENUM_CAST( BaseButton::DrawMode )
+VARIANT_ENUM_CAST( BaseButton::ActionMode )
+
+
+
+class ButtonGroup : public Resource {
+
+ GDCLASS(ButtonGroup,Resource)
+friend class BaseButton;
+ Set<BaseButton*> buttons;
+protected:
+ static void _bind_methods();
+public:
+
+ BaseButton* get_pressed_button();
+ void get_buttons(List<BaseButton*> *r_buttons);
+ ButtonGroup();
+};
#endif
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index a6ffc30a83..7ca44ac27b 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -55,7 +55,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -108,7 +108,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -164,7 +164,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -227,7 +227,7 @@ Size2 BoxContainer::get_minimum_size() const {
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden()) {
+ if (!c->is_visible()) {
continue;
}
@@ -280,7 +280,8 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const {
void BoxContainer::add_spacer(bool p_begin) {
Control *c = memnew( Control );
- c->set_stop_mouse(false);
+ c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events
+
if (vertical)
c->set_v_size_flags(SIZE_EXPAND_FILL);
else
@@ -295,15 +296,15 @@ BoxContainer::BoxContainer(bool p_vertical) {
vertical=p_vertical;
align = ALIGN_BEGIN;
-// set_ignore_mouse(true);
- set_stop_mouse(false);
+ //set_ignore_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_PASS);
}
void BoxContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_spacer","begin"),&BoxContainer::add_spacer);
- ObjectTypeDB::bind_method(_MD("get_alignment"),&BoxContainer::get_alignment);
- ObjectTypeDB::bind_method(_MD("set_alignment","alignment"),&BoxContainer::set_alignment);
+ ClassDB::bind_method(_MD("add_spacer","begin"),&BoxContainer::add_spacer);
+ ClassDB::bind_method(_MD("get_alignment"),&BoxContainer::get_alignment);
+ ClassDB::bind_method(_MD("set_alignment","alignment"),&BoxContainer::set_alignment);
BIND_CONSTANT( ALIGN_BEGIN );
BIND_CONSTANT( ALIGN_CENTER );
diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h
index 6e63e8bdac..c428ec132c 100644
--- a/scene/gui/box_container.h
+++ b/scene/gui/box_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class BoxContainer : public Container {
- OBJ_TYPE(BoxContainer,Container);
+ GDCLASS(BoxContainer,Container);
public:
@@ -68,7 +68,7 @@ public:
class HBoxContainer : public BoxContainer {
- OBJ_TYPE(HBoxContainer,BoxContainer);
+ GDCLASS(HBoxContainer,BoxContainer);
public:
@@ -79,7 +79,7 @@ public:
class MarginContainer;
class VBoxContainer : public BoxContainer {
- OBJ_TYPE(VBoxContainer,BoxContainer);
+ GDCLASS(VBoxContainer,BoxContainer);
public:
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 579f6e08c9..f28595b622 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
Size2 Button::get_minimum_size() const {
- Size2 minsize=get_font("font")->get_string_size( text );
+ Size2 minsize=get_font("font")->get_string_size( xl_text );
if (clip_text)
minsize.width=0;
@@ -48,7 +48,7 @@ Size2 Button::get_minimum_size() const {
minsize.height=MAX( minsize.height, _icon->get_height() );
minsize.width+=_icon->get_width();
- if (text!="")
+ if (xl_text!="")
minsize.width+=get_constant("hseparation");
}
@@ -59,6 +59,13 @@ Size2 Button::get_minimum_size() const {
void Button::_notification(int p_what) {
+ if (p_what==NOTIFICATION_TRANSLATION_CHANGED) {
+
+ xl_text=XL_MESSAGE(text);
+ minimum_size_changed();
+ update();
+ }
+
if (p_what==NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
@@ -114,7 +121,7 @@ void Button::_notification(int p_what) {
Point2 icon_ofs = (!_icon.is_null())?Point2( _icon->get_width() + get_constant("hseparation"), 0):Point2();
int text_clip=size.width - style->get_minimum_size().width - icon_ofs.width;
- Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size( text ) )/2.0;
+ Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size( xl_text ) )/2.0;
switch(align) {
case ALIGN_LEFT: {
@@ -128,14 +135,14 @@ void Button::_notification(int p_what) {
text_ofs+=style->get_offset();
} break;
case ALIGN_RIGHT: {
- text_ofs.x=size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size( text ).x;
+ text_ofs.x=size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size( xl_text ).x;
text_ofs.y+=style->get_offset().y;
} break;
}
text_ofs.y+=font->get_ascent();
- font->draw( ci, text_ofs.floor(), text, color,clip_text?text_clip:-1);
+ font->draw( ci, text_ofs.floor(), xl_text, color,clip_text?text_clip:-1);
if (!_icon.is_null()) {
int valign = size.height-style->get_minimum_size().y;
@@ -152,7 +159,8 @@ void Button::set_text(const String& p_text) {
if (text==p_text)
return;
- text=XL_MESSAGE(p_text);
+ text=p_text;
+ xl_text=XL_MESSAGE(p_text);
update();
_change_notify("text");
minimum_size_changed();
@@ -215,16 +223,16 @@ Button::TextAlign Button::get_text_align() const {
void Button::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_text","text"),&Button::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&Button::get_text);
- ObjectTypeDB::bind_method(_MD("set_button_icon","texture:Texture"),&Button::set_icon);
- ObjectTypeDB::bind_method(_MD("get_button_icon:Texture"),&Button::get_icon);
- ObjectTypeDB::bind_method(_MD("set_flat","enabled"),&Button::set_flat);
- ObjectTypeDB::bind_method(_MD("set_clip_text","enabled"),&Button::set_clip_text);
- ObjectTypeDB::bind_method(_MD("get_clip_text"),&Button::get_clip_text);
- ObjectTypeDB::bind_method(_MD("set_text_align","align"),&Button::set_text_align);
- ObjectTypeDB::bind_method(_MD("get_text_align"),&Button::get_text_align);
- ObjectTypeDB::bind_method(_MD("is_flat"),&Button::is_flat);
+ ClassDB::bind_method(_MD("set_text","text"),&Button::set_text);
+ ClassDB::bind_method(_MD("get_text"),&Button::get_text);
+ ClassDB::bind_method(_MD("set_button_icon","texture:Texture"),&Button::set_icon);
+ ClassDB::bind_method(_MD("get_button_icon:Texture"),&Button::get_icon);
+ ClassDB::bind_method(_MD("set_flat","enabled"),&Button::set_flat);
+ ClassDB::bind_method(_MD("set_clip_text","enabled"),&Button::set_clip_text);
+ ClassDB::bind_method(_MD("get_clip_text"),&Button::get_clip_text);
+ ClassDB::bind_method(_MD("set_text_align","align"),&Button::set_text_align);
+ ClassDB::bind_method(_MD("get_text_align"),&Button::get_text_align);
+ ClassDB::bind_method(_MD("is_flat"),&Button::is_flat);
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
@@ -242,7 +250,7 @@ Button::Button(const String &p_text) {
flat=false;
clip_text=false;
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
set_text(p_text);
align=ALIGN_CENTER;
}
diff --git a/scene/gui/button.h b/scene/gui/button.h
index c39237c9af..2fd3a0cace 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,9 +33,12 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
+
+
class Button : public BaseButton {
- OBJ_TYPE( Button, BaseButton );
+ GDCLASS( Button, BaseButton );
public:
@@ -49,6 +52,7 @@ private:
bool flat;
String text;
+ String xl_text;
Ref<Texture> icon;
bool clip_text;
TextAlign align;
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index be48296110..3d7c0e2825 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -60,6 +60,8 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {
String f = n.get_slicec('/',2);
if (f=="text")
buttons[idx].text=p_value;
+ else if (f=="tooltip")
+ buttons[idx].tooltip=p_value;
else if (f=="icon")
buttons[idx].icon=p_value;
else
@@ -95,6 +97,8 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const {
String f = n.get_slicec('/',2);
if (f=="text")
r_ret=buttons[idx].text;
+ else if (f=="tooltip")
+ r_ret=buttons[idx].tooltip;
else if (f=="icon")
r_ret=buttons[idx].icon;
else
@@ -115,6 +119,7 @@ void ButtonArray::_get_property_list( List<PropertyInfo> *p_list) const {
for(int i=0;i<buttons.size();i++) {
String base="button/"+itos(i)+"/";
p_list->push_back( PropertyInfo( Variant::STRING, base+"text"));
+ p_list->push_back( PropertyInfo( Variant::STRING, base+"tooltip"));
p_list->push_back( PropertyInfo( Variant::OBJECT, base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
}
if (buttons.size()>0) {
@@ -168,8 +173,12 @@ Size2 ButtonArray::get_minimum_size() const {
void ButtonArray::_notification(int p_what) {
switch(p_what) {
+ case NOTIFICATION_MOUSE_EXIT:{
+ hover=-1;
+ update();
+ }break;
case NOTIFICATION_READY:{
- MethodInfo mi;
+ MethodInfo mi;
mi.name="mouse_sub_enter";
add_user_signal(mi);
@@ -245,8 +254,12 @@ void ButtonArray::_notification(int p_what) {
Ref<Font> f;
Color c;
+ Point2 sbsize;
+ Point2 sbofs;
if (i==selected) {
draw_style_box(style_selected,r);
+ sbsize=style_selected->get_minimum_size();
+ sbofs=style_selected->get_offset();
f=font_selected;
c=color_selected;
if (has_focus())
@@ -254,8 +267,10 @@ void ButtonArray::_notification(int p_what) {
} else {
if (hover==i)
draw_style_box(style_hover,r);
- else
+ else if (!flat)
draw_style_box(style_normal,r);
+ sbsize=style_normal->get_minimum_size();
+ sbofs=style_normal->get_offset();
f=font_normal;
c=color_normal;
}
@@ -265,7 +280,7 @@ void ButtonArray::_notification(int p_what) {
ssize.x+=buttons[i].icon->get_width();
}
- Point2 text_ofs=((r.size-ssize)/2.0+Point2(0,f->get_ascent())).floor();
+ Point2 text_ofs=((r.size-ssize-sbsize)/2.0+Point2(0,f->get_ascent())).floor()+sbofs;
if (buttons[i].icon.is_valid()) {
draw_texture(buttons[i].icon,r.pos+Point2(text_ofs.x,Math::floor((r.size.height-buttons[i].icon->get_height())/2.0)));
@@ -285,7 +300,7 @@ void ButtonArray::_notification(int p_what) {
}
-void ButtonArray::_input_event(const InputEvent& p_event) {
+void ButtonArray::_gui_input(const InputEvent& p_event) {
if (
( (orientation==HORIZONTAL && p_event.is_action("ui_left") ) ||
@@ -349,6 +364,18 @@ void ButtonArray::_input_event(const InputEvent& p_event) {
}
+String ButtonArray::get_tooltip(const Point2& p_pos) const {
+
+ int ofs = orientation==HORIZONTAL ? p_pos.x: p_pos.y;
+ for(int i=0;i<buttons.size();i++) {
+
+ if (ofs>=buttons[i]._pos_cache && ofs<buttons[i]._pos_cache+buttons[i]._size_cache)
+ return buttons[i].tooltip;
+
+ }
+ return Control::get_tooltip(p_pos);
+}
+
void ButtonArray::set_align(Align p_align) {
align=p_align;
@@ -361,11 +388,23 @@ ButtonArray::Align ButtonArray::get_align() const {
return align;
}
+void ButtonArray::set_flat(bool p_flat) {
+
+ flat=p_flat;
+ update();
+}
+
+bool ButtonArray::is_flat() const {
+
+ return flat;
+}
+
-void ButtonArray::add_button(const String& p_text) {
+void ButtonArray::add_button(const String& p_text,const String& p_tooltip) {
Button button;
button.text=p_text;
+ button.tooltip=p_tooltip;
buttons.push_back(button);
update();
@@ -375,11 +414,12 @@ void ButtonArray::add_button(const String& p_text) {
minimum_size_changed();
}
-void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text) {
+void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text,const String& p_tooltip) {
Button button;
button.text=p_text;
button.icon=p_icon;
+ button.tooltip=p_tooltip;
buttons.push_back(button);
if (selected==-1)
selected=0;
@@ -397,6 +437,13 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) {
}
+void ButtonArray::set_button_tooltip(int p_button, const String& p_text) {
+
+ ERR_FAIL_INDEX(p_button,buttons.size());
+ buttons[p_button].tooltip=p_text;
+
+}
+
void ButtonArray::set_button_icon(int p_button, const Ref<Texture>& p_icon) {
ERR_FAIL_INDEX(p_button,buttons.size());
@@ -411,6 +458,12 @@ String ButtonArray::get_button_text(int p_button) const {
return buttons[p_button].text;
}
+String ButtonArray::get_button_tooltip(int p_button) const {
+
+ ERR_FAIL_INDEX_V(p_button,buttons.size(),"");
+ return buttons[p_button].tooltip;
+}
+
Ref<Texture> ButtonArray::get_button_icon(int p_button) const {
ERR_FAIL_INDEX_V(p_button,buttons.size(),Ref<Texture>());
@@ -465,27 +518,33 @@ int ButtonArray::get_button_count() const {
void ButtonArray::get_translatable_strings(List<String> *p_strings) const {
- for(int i=0;i<buttons.size();i++)
+ for(int i=0;i<buttons.size();i++) {
p_strings->push_back(buttons[i].text);
+ p_strings->push_back(buttons[i].tooltip);
+ }
}
void ButtonArray::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_button","text"),&ButtonArray::add_button);
- ObjectTypeDB::bind_method(_MD("add_icon_button","icon:Texture","text"),&ButtonArray::add_icon_button,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
- ObjectTypeDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
- ObjectTypeDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text);
- ObjectTypeDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
- ObjectTypeDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count);
- ObjectTypeDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected);
- ObjectTypeDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered);
- ObjectTypeDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected);
- ObjectTypeDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button);
- ObjectTypeDB::bind_method(_MD("clear"),&ButtonArray::clear);
-
- ObjectTypeDB::bind_method(_MD("_input_event"),&ButtonArray::_input_event);
+ ClassDB::bind_method(_MD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL(""));
+ ClassDB::bind_method(_MD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL(""));
+ ClassDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
+ ClassDB::bind_method(_MD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip);
+ ClassDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
+ ClassDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text);
+ ClassDB::bind_method(_MD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip);
+ ClassDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
+ ClassDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count);
+ ClassDB::bind_method(_MD("set_flat","enabled"),&ButtonArray::set_flat);
+ ClassDB::bind_method(_MD("is_flat"),&ButtonArray::is_flat);
+ ClassDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected);
+ ClassDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered);
+ ClassDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected);
+ ClassDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button);
+ ClassDB::bind_method(_MD("clear"),&ButtonArray::clear);
+
+ ClassDB::bind_method(_MD("_gui_input"),&ButtonArray::_gui_input);
BIND_CONSTANT( ALIGN_BEGIN );
BIND_CONSTANT( ALIGN_CENTER );
@@ -493,6 +552,8 @@ void ButtonArray::_bind_methods() {
BIND_CONSTANT( ALIGN_FILL );
BIND_CONSTANT( ALIGN_EXPAND_FILL );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") );
+
ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button_idx")));
}
@@ -503,5 +564,6 @@ ButtonArray::ButtonArray(Orientation p_orientation) {
selected=-1;
set_focus_mode(FOCUS_ALL);
hover=-1;
+ flat=false;
min_button_size = -1;
}
diff --git a/scene/gui/button_array.h b/scene/gui/button_array.h
index c4b9b0c9e3..37533695c9 100644
--- a/scene/gui/button_array.h
+++ b/scene/gui/button_array.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ButtonArray : public Control {
- OBJ_TYPE(ButtonArray, Control);
+ GDCLASS(ButtonArray, Control);
public:
enum Align {
ALIGN_BEGIN,
@@ -50,6 +50,7 @@ private:
struct Button {
String text;
+ String tooltip;
Ref<Texture> icon;
mutable int _ms_cache;
mutable int _pos_cache;
@@ -58,6 +59,7 @@ private:
int selected;
int hover;
+ bool flat;
double min_button_size;
Vector<Button> buttons;
@@ -72,20 +74,25 @@ protected:
public:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void set_align(Align p_align);
Align get_align() const;
- void add_button(const String& p_button);
- void add_icon_button(const Ref<Texture>& p_icon,const String& p_button="");
+ void set_flat(bool p_flat);
+ bool is_flat() const;
+
+ void add_button(const String& p_button,const String& p_tooltip="");
+ void add_icon_button(const Ref<Texture>& p_icon,const String& p_button="",const String& p_tooltip="");
void set_button_text(int p_button, const String& p_text);
+ void set_button_tooltip(int p_button, const String& p_text);
void set_button_icon(int p_button, const Ref<Texture>& p_icon);
String get_button_text(int p_button) const;
+ String get_button_tooltip(int p_button) const;
Ref<Texture> get_button_icon(int p_button) const;
int get_selected() const;
@@ -100,20 +107,21 @@ public:
virtual Size2 get_minimum_size() const;
virtual void get_translatable_strings(List<String> *p_strings) const;
+ virtual String get_tooltip(const Point2& p_pos) const;
ButtonArray(Orientation p_orientation=HORIZONTAL);
};
class HButtonArray : public ButtonArray {
- OBJ_TYPE(HButtonArray,ButtonArray);
+ GDCLASS(HButtonArray,ButtonArray);
public:
HButtonArray() : ButtonArray(HORIZONTAL) {};
};
class VButtonArray : public ButtonArray {
- OBJ_TYPE(VButtonArray,ButtonArray);
+ GDCLASS(VButtonArray,ButtonArray);
public:
VButtonArray() : ButtonArray(VERTICAL) {};
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
index 04ba5fc06d..01a3f633c3 100644
--- a/scene/gui/button_group.cpp
+++ b/scene/gui/button_group.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,6 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "button_group.h"
+
+#if 0
#include "base_button.h"
void ButtonGroup::_add_button(BaseButton *p_button) {
@@ -60,6 +62,9 @@ void ButtonGroup::_pressed(Object *p_button) {
BaseButton *bb=E->get();
bb->set_pressed( b==bb );
+ if (b==bb){
+ emit_signal("button_selected", b);
+ }
}
}
@@ -146,15 +151,17 @@ int ButtonGroup::get_pressed_button_index() const {
void ButtonGroup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
- ObjectTypeDB::bind_method(_MD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
- ObjectTypeDB::bind_method(_MD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
- ObjectTypeDB::bind_method(_MD("get_button_list"),&ButtonGroup::_get_button_list);
- ObjectTypeDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
- ObjectTypeDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ClassDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
+ ClassDB::bind_method(_MD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
+ ClassDB::bind_method(_MD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
+ ClassDB::bind_method(_MD("get_button_list"),&ButtonGroup::_get_button_list);
+ ClassDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
+ ClassDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
}
ButtonGroup::ButtonGroup() : BoxContainer(true)
{
}
+#endif
diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h
index 4afba22228..38acd06984 100644
--- a/scene/gui/button_group.h
+++ b/scene/gui/button_group.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,12 +31,12 @@
#include "scene/gui/box_container.h"
-
+#if 0
class BaseButton;
class ButtonGroup : public BoxContainer {
- OBJ_TYPE(ButtonGroup,BoxContainer);
+ GDCLASS(ButtonGroup,BoxContainer);
Set<BaseButton*> buttons;
@@ -63,4 +63,5 @@ public:
ButtonGroup();
};
+#endif
#endif // BUTTON_GROUP_H
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index 844175e4c1..4d4abb6484 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,7 +42,7 @@ Size2 CenterContainer::get_minimum_size() const {
continue;
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width , minsize.width);
@@ -92,8 +92,8 @@ void CenterContainer::_notification(int p_what) {
void CenterContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
- ObjectTypeDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
+ ClassDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
+ ClassDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"use_top_left"),_SCS("set_use_top_left"),_SCS("is_using_top_left"));
}
diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h
index dc95533525..7acc14de19 100644
--- a/scene/gui/center_container.h
+++ b/scene/gui/center_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class CenterContainer : public Container {
- OBJ_TYPE( CenterContainer, Container );
+ GDCLASS( CenterContainer, Container );
bool use_top_left;
protected:
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 1381d6eb60..c9803bc654 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -56,14 +56,8 @@ void CheckBox::_notification(int p_what) {
bool CheckBox::is_radio()
{
- Node* parent = this;
- do {
- parent = parent->get_parent();
- if (parent->cast_to<ButtonGroup>())
- break;
- } while (parent);
- return (parent != 0);
+ return get_button_group().is_valid();
}
CheckBox::CheckBox(const String &p_text):
diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h
index 95dd4891d4..6a4893936f 100644
--- a/scene/gui/check_box.h
+++ b/scene/gui/check_box.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class CheckBox : public Button {
- OBJ_TYPE( CheckBox, Button );
+ GDCLASS( CheckBox, Button );
protected:
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index f8c0c6b208..6404f066e8 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h
index a1ed4c1896..1c5440a25d 100644
--- a/scene/gui/check_button.h
+++ b/scene/gui/check_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class CheckButton : public Button {
- OBJ_TYPE( CheckButton, Button );
+ GDCLASS( CheckButton, Button );
protected:
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 5e66544153..da2fb1bc91 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,41 +34,20 @@
#include "os/input.h"
#include "os/keyboard.h"
-void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color,float h,float s,float v) {
- if (!mat.is_valid())
- return;
- Ref<Shader> sdr = mat->get_shader();
- if (!sdr.is_valid())
- return;
-
- mat->set_shader_param("R",p_color.r);
- mat->set_shader_param("G",p_color.g);
- mat->set_shader_param("B",p_color.b);
- mat->set_shader_param("H",h);
- mat->set_shader_param("S",s);
- mat->set_shader_param("V",v);
- mat->set_shader_param("A",p_color.a);
-}
void ColorPicker::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_THEME_CHANGED: {
- uv_material->set_shader(get_shader("uv_editor"));
- w_material->set_shader(get_shader("w_editor"));
- update_material(uv_material,color,h,s,v);
- update_material(w_material,color,h,s,v);
+ //sample->set_texture(get_icon("color_sample"));
+
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
- update_material(uv_material, color,h,s,v);
- update_material(w_material, color,h,s,v);
- uv_edit->get_child(0)->cast_to<Control>()->update();
- w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
}
@@ -96,7 +75,7 @@ void ColorPicker::_update_controls() {
}
-void ColorPicker::set_color(const Color& p_color) {
+void ColorPicker::set_pick_color(const Color& p_color) {
color=p_color;
if (color != last_hsv) {
@@ -109,9 +88,7 @@ void ColorPicker::set_color(const Color& p_color) {
if (!is_inside_tree())
return;
- update_material(uv_material, color,h,s,v);
- update_material(w_material, color,h,s,v);
-
+ return; //it crashes, so returning
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
@@ -141,10 +118,10 @@ void ColorPicker::_value_changed(double) {
return;
for(int i=0;i<4;i++) {
- color.components[i] = scroll[i]->get_val()/(raw_mode_enabled?1.0:255.0);
+ color.components[i] = scroll[i]->get_value()/(raw_mode_enabled?1.0:255.0);
}
- set_color(color);
+ set_pick_color(color);
_update_text_value();
@@ -162,7 +139,7 @@ void ColorPicker::_html_entered(const String& p_html) {
if (!is_inside_tree())
return;
- _update_color();
+ set_pick_color(color);
emit_signal("color_changed",color);
}
@@ -176,9 +153,9 @@ void ColorPicker::_update_color() {
if (raw_mode_enabled) {
if (i == 3)
scroll[i]->set_max(1);
- scroll[i]->set_val(color.components[i]);
+ scroll[i]->set_value(color.components[i]);
} else {
- scroll[i]->set_val(color.components[i] * 255);
+ scroll[i]->set_value(color.components[i] * 255);
}
}
@@ -192,10 +169,24 @@ void ColorPicker::_update_presets()
{
Size2 size=bt_add_preset->get_size();
preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height));
- Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB);
- for (int y=0;y<size.y;y++)
- for (int x=0;x<size.x*presets.size();x++)
- i.put_pixel(x,y,presets[(int)x/size.x]);
+
+ PoolVector<uint8_t> img;
+ img.resize(size.x*presets.size()*size.y*3);
+
+ {
+ PoolVector<uint8_t>::Write w=img.write();
+ for (int y=0;y<size.y;y++) {
+ for (int x=0;x<size.x*presets.size();x++) {
+ int ofs = (y*(size.x*presets.size())+x)*3;
+ w[ofs+0]=uint8_t(CLAMP(presets[(int)x/size.x].r*255.0,0,255));
+ w[ofs+1]=uint8_t(CLAMP(presets[(int)x/size.x].g*255.0,0,255));
+ w[ofs+2]=uint8_t(CLAMP(presets[(int)x/size.x].b*255.0,0,255));
+ }
+ }
+ }
+
+ Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB8,img);
+
Ref<ImageTexture> t;
t.instance();
t->create_from_image(i);
@@ -217,7 +208,7 @@ void ColorPicker::_text_type_toggled()
_update_color();
}
-Color ColorPicker::get_color() const {
+Color ColorPicker::get_pick_color() const {
return color;
}
@@ -278,14 +269,39 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c)
if (!c)
return;
if (p_wich==0) {
+ Vector<Point2> points;
+ points.push_back(Vector2());
+ points.push_back(Vector2(c->get_size().x,0));
+ points.push_back(c->get_size());
+ points.push_back(Vector2(0,c->get_size().y));
+ Vector<Color> colors;
+ colors.push_back(Color(1,1,1));
+ colors.push_back(Color(1,1,1));
+ colors.push_back(Color());
+ colors.push_back(Color());
+ c->draw_polygon(points,colors);
+ Vector<Color> colors2;
+ Color col = color;
+ col.set_hsv(color.get_h(),1,1);
+ col.a = 0;
+ colors2.push_back(col);
+ col.a = 1;
+ colors2.push_back(col);
+ col.set_hsv(color.get_h(),1,0);
+ colors2.push_back(col);
+ col.a = 0;
+ colors2.push_back(col);
+ c->draw_polygon(points,colors);
int x = CLAMP(c->get_size().x * s, 0, c->get_size().x);
int y = CLAMP(c->get_size().y-c->get_size().y * v, 0, c->get_size().y);
- Color col = color;
+ col = color;
col.a=1;
c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted());
c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted());
c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2);
} else if (p_wich==1) {
+ Ref<Texture> hue = get_icon("color_hue","ColorPicker");
+ c->draw_texture_rect(hue,Rect2(Point2(),c->get_size()));
int y=c->get_size().y-c->get_size().y*h;
Color col=Color();
col.set_hsv(h,1,1);
@@ -296,7 +312,7 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c)
void ColorPicker::_uv_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed) {
+ if (bev.pressed && bev.button_index==BUTTON_LEFT) {
changing_color = true;
float x = CLAMP((float)bev.x,0,256);
float y = CLAMP((float)bev.y,0,256);
@@ -304,7 +320,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
v=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
} else {
@@ -320,7 +336,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
v=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
}
@@ -329,7 +345,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
void ColorPicker::_w_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed) {
+ if (bev.pressed && bev.button_index==BUTTON_LEFT) {
changing_color = true;
h=1-((float)bev.y)/256.0;
@@ -338,7 +354,7 @@ void ColorPicker::_w_input(const InputEvent &ev) {
}
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
} else if (ev.type == InputEvent::MOUSE_MOTION) {
@@ -349,7 +365,7 @@ void ColorPicker::_w_input(const InputEvent &ev) {
h=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
}
@@ -360,7 +376,7 @@ void ColorPicker::_preset_input(const InputEvent &ev) {
const InputEventMouseButton &bev = ev.mouse_button;
if (bev.pressed && bev.button_index==BUTTON_LEFT) {
int index = bev.x/(preset->get_size().x/presets.size());
- set_color(presets[index]);
+ set_pick_color(presets[index]);
} else if (bev.pressed && bev.button_index==BUTTON_RIGHT) {
int index = bev.x/(preset->get_size().x/presets.size());
presets.erase(presets[index]);
@@ -394,15 +410,23 @@ void ColorPicker::_screen_input(const InputEvent &ev)
} else if (ev.type==InputEvent::MOUSE_MOTION) {
const InputEventMouse &mev = ev.mouse_motion;
Viewport *r=get_tree()->get_root();
- if (!r->get_rect().has_point(Point2(mev.global_x,mev.global_y)))
+ if (!r->get_visible_rect().has_point(Point2(mev.global_x,mev.global_y)))
return;
Image img =r->get_screen_capture();
if (!img.empty()) {
last_capture=img;
r->queue_screen_capture();
}
- if (!last_capture.empty())
- set_color(last_capture.get_pixel(mev.global_x,mev.global_y));
+ if (!last_capture.empty()) {
+ int pw = last_capture.get_format()==Image::FORMAT_RGBA8?4:3;
+ int ofs = (mev.global_y*last_capture.get_width()+mev.global_x)*pw;
+
+ PoolVector<uint8_t>::Read r = last_capture.get_data().read();
+
+ Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 );
+
+ set_pick_color(c);
+ }
}
}
@@ -418,7 +442,7 @@ void ColorPicker::_screen_pick_pressed()
r->add_child(screen);
screen->set_as_toplevel(true);
screen->set_area_as_parent_rect();
- screen->connect("input_event",this,"_screen_input");
+ screen->connect("gui_input",this,"_screen_input");
}
screen->raise();
screen->show_modal();
@@ -427,24 +451,24 @@ void ColorPicker::_screen_pick_pressed()
void ColorPicker::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPicker::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&ColorPicker::get_color);
- ObjectTypeDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
- ObjectTypeDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode);
- ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha);
- ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPicker::is_editing_alpha);
- ObjectTypeDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset);
- ObjectTypeDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed);
- ObjectTypeDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered);
- ObjectTypeDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled);
- ObjectTypeDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
- ObjectTypeDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
- ObjectTypeDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw);
- ObjectTypeDB::bind_method(_MD("_hsv_draw"),&ColorPicker::_hsv_draw);
- ObjectTypeDB::bind_method(_MD("_uv_input"),&ColorPicker::_uv_input);
- ObjectTypeDB::bind_method(_MD("_w_input"),&ColorPicker::_w_input);
- ObjectTypeDB::bind_method(_MD("_preset_input"),&ColorPicker::_preset_input);
- ObjectTypeDB::bind_method(_MD("_screen_input"),&ColorPicker::_screen_input);
+ ClassDB::bind_method(_MD("set_pick_color","color"),&ColorPicker::set_pick_color);
+ ClassDB::bind_method(_MD("get_pick_color"),&ColorPicker::get_pick_color);
+ ClassDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
+ ClassDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode);
+ ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha);
+ ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPicker::is_editing_alpha);
+ ClassDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset);
+ ClassDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed);
+ ClassDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered);
+ ClassDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled);
+ ClassDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
+ ClassDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
+ ClassDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw);
+ ClassDB::bind_method(_MD("_hsv_draw"),&ColorPicker::_hsv_draw);
+ ClassDB::bind_method(_MD("_uv_input"),&ColorPicker::_uv_input);
+ ClassDB::bind_method(_MD("_w_input"),&ColorPicker::_w_input);
+ ClassDB::bind_method(_MD("_preset_input"),&ColorPicker::_preset_input);
+ ClassDB::bind_method(_MD("_screen_input"),&ColorPicker::_screen_input);
ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
}
@@ -463,7 +487,7 @@ ColorPicker::ColorPicker() :
btn_pick = memnew( ToolButton );
btn_pick->connect("pressed",this,"_screen_pick_pressed");
- sample = memnew( TextureFrame );
+ sample = memnew( TextureRect );
sample->set_h_size_flags(SIZE_EXPAND_FILL);
sample->connect("draw",this,"_sample_draw");
@@ -473,50 +497,30 @@ ColorPicker::ColorPicker() :
HBoxContainer *hb_edit = memnew( HBoxContainer );
- uv_edit= memnew ( TextureFrame );
- Image i(256, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<256;x++)
- i.put_pixel(x,y,Color());
- Ref<ImageTexture> t;
- t.instance();
- t->create_from_image(i);
- uv_edit->set_texture(t);
- uv_edit->set_ignore_mouse(false);
- uv_edit->set_custom_minimum_size(Size2(256,256));
- uv_edit->connect("input_event", this, "_uv_input");
- Control *c= memnew( Control );
- uv_edit->add_child(c);
- c->set_area_as_parent_rect();
- c->set_stop_mouse(false);
- c->set_material(memnew ( CanvasItemMaterial ));
+ uv_edit= memnew ( Control );
+
+
+
+
+ uv_edit->connect("gui_input", this, "_uv_input");
+ uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
+ uv_edit->set_custom_minimum_size(Size2 (256,256));
Vector<Variant> args=Vector<Variant>();
args.push_back(0);
- args.push_back(c);
- c->connect("draw",this,"_hsv_draw",args);
+ args.push_back(uv_edit);
+ uv_edit->connect("draw",this,"_hsv_draw",args);
add_child(hb_edit);
- w_edit= memnew( TextureFrame );
- i = Image(15, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<15;x++)
- i.put_pixel(x,y,Color());
- Ref<ImageTexture> tw;
- tw.instance();
- tw->create_from_image(i);
- w_edit->set_texture(tw);
- w_edit->set_ignore_mouse(false);
- w_edit->set_custom_minimum_size(Size2(15,256));
- w_edit->connect("input_event", this, "_w_input");
- c= memnew( Control );
- w_edit->add_child(c);
- c->set_area_as_parent_rect();
- c->set_stop_mouse(false);
- c->set_material(memnew ( CanvasItemMaterial ));
+
+ w_edit= memnew( Control );
+ //w_edit->set_ignore_mouse(false);
+ w_edit->set_custom_minimum_size(Size2(30,256));
+ w_edit->connect("gui_input", this, "_w_input");
args.clear();
args.push_back(1);
- args.push_back(c);
- c->connect("draw",this,"_hsv_draw",args);
+ args.push_back(w_edit);
+ w_edit->connect("draw",this,"_hsv_draw",args);
+
hb_edit->add_child(uv_edit);
hb_edit->add_child(memnew( VSeparator ));
@@ -580,39 +584,16 @@ ColorPicker::ColorPicker() :
//_update_color();
updating=false;
- uv_material.instance();
- Ref<Shader> s_uv = get_shader("uv_editor");
- uv_material->set_shader(s_uv);
-
- w_material.instance();
-
- Ref<Shader> s_w = get_shader("w_editor");
- w_material->set_shader(s_w);
+ set_pick_color(Color(1,1,1));
- uv_edit->set_material(uv_material);
- w_edit->set_material(w_material);
-
- set_color(Color(1,1,1));
-
- i.create(256,20,false,Image::FORMAT_RGB);
- for (int y=0;y<20;y++)
- for(int x=0;x<256;x++)
- if ((x/4+y/4)%2)
- i.put_pixel(x,y,Color(1,1,1));
- else
- i.put_pixel(x,y,Color(0.6,0.6,0.6));
- Ref<ImageTexture> t_smpl;
- t_smpl.instance();
- t_smpl->create_from_image(i);
- sample->set_texture(t_smpl);
HBoxContainer *bbc = memnew( HBoxContainer );
add_child(bbc);
- preset = memnew( TextureFrame );
+ preset = memnew( TextureRect );
bbc->add_child(preset);
- preset->set_ignore_mouse(false);
- preset->connect("input_event", this, "_preset_input");
+ //preset->set_ignore_mouse(false);
+ preset->connect("gui_input", this, "_preset_input");
bt_add_preset = memnew ( Button );
bt_add_preset->set_icon(get_icon("add_preset"));
@@ -651,19 +632,20 @@ void ColorPickerButton::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
Ref<StyleBox> normal = get_stylebox("normal" );
- draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_color());
+ draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_pick_color());
}
}
-void ColorPickerButton::set_color(const Color& p_color){
+void ColorPickerButton::set_pick_color(const Color& p_color){
- picker->set_color(p_color);
+ picker->set_pick_color(p_color);
update();
+ emit_signal("color_changed",p_color);
}
-Color ColorPickerButton::get_color() const{
+Color ColorPickerButton::get_pick_color() const{
- return picker->get_color();
+ return picker->get_pick_color();
}
void ColorPickerButton::set_edit_alpha(bool p_show) {
@@ -683,15 +665,15 @@ ColorPicker *ColorPickerButton::get_picker() {
void ColorPickerButton::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPickerButton::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&ColorPickerButton::get_color);
- ObjectTypeDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
- ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
- ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
- ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed);
+ ClassDB::bind_method(_MD("set_pick_color","color"),&ColorPickerButton::set_pick_color);
+ ClassDB::bind_method(_MD("get_pick_color"),&ColorPickerButton::get_pick_color);
+ ClassDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
+ ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
+ ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
+ ClassDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed);
ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color") );
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_pick_color"),_SCS("get_pick_color") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"edit_alpha"),_SCS("set_edit_alpha"),_SCS("is_editing_alpha") );
}
@@ -701,7 +683,7 @@ ColorPickerButton::ColorPickerButton() {
popup = memnew( PopupPanel );
picker = memnew( ColorPicker );
popup->add_child(picker);
- popup->set_child_rect(picker);
+
picker->connect("color_changed",this,"_color_changed");
add_child(popup);
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 5e2cc57274..d9db9c89f7 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,29 +36,26 @@
#include "scene/gui/button.h"
#include "scene/gui/popup.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/check_button.h"
-#include "scene/resources/material.h"
class ColorPicker : public BoxContainer {
- OBJ_TYPE(ColorPicker,BoxContainer);
+ GDCLASS(ColorPicker,BoxContainer);
private:
Control *screen;
Image last_capture;
- TextureFrame *uv_edit;
- TextureFrame *w_edit;
- TextureFrame *sample;
- TextureFrame *preset;
+ Control *uv_edit;
+ Control *w_edit;
+ TextureRect *sample;
+ TextureRect *preset;
Button *bt_add_preset;
List<Color> presets;
ToolButton *btn_pick;
CheckButton *btn_mode;
- Ref<CanvasItemMaterial> uv_material;
- Ref<CanvasItemMaterial> w_material;
HSlider *scroll[4];
SpinBox *values[4];
Label *labels[4];
@@ -101,8 +98,8 @@ public:
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
- void set_color(const Color& p_color);
- Color get_color() const;
+ void set_pick_color(const Color& p_color);
+ Color get_pick_color() const;
void add_preset(const Color& p_color);
void set_raw_mode(bool p_enabled);
@@ -115,7 +112,7 @@ public:
class ColorPickerButton : public Button {
- OBJ_TYPE(ColorPickerButton,Button);
+ GDCLASS(ColorPickerButton,Button);
PopupPanel *popup;
ColorPicker *picker;
@@ -129,8 +126,8 @@ protected:
static void _bind_methods();
public:
- void set_color(const Color& p_color);
- Color get_color() const;
+ void set_pick_color(const Color& p_color);
+ Color get_pick_color() const;
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp
index b7347f00dc..5d5d6c31a2 100644
--- a/scene/gui/color_ramp_edit.cpp
+++ b/scene/gui/color_ramp_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@ ColorRampEdit::ColorRampEdit(){
popup = memnew( PopupPanel );
picker = memnew( ColorPicker );
popup->add_child(picker);
- popup->set_child_rect(picker);
+
add_child(popup);
checker = Ref<ImageTexture>(memnew( ImageTexture ));
@@ -60,7 +60,7 @@ void ColorRampEdit::_show_color_picker() {
if (grabbed==-1)
return;
Size2 ms = Size2(350, picker->get_combined_minimum_size().height+10);
- picker->set_color(points[grabbed].color);
+ picker->set_pick_color(points[grabbed].color);
popup->set_pos(get_global_pos()-Vector2(ms.width-get_size().width,ms.height));
popup->set_size(ms);
popup->popup();
@@ -70,7 +70,7 @@ ColorRampEdit::~ColorRampEdit() {
}
-void ColorRampEdit::_input_event(const InputEvent& p_event) {
+void ColorRampEdit::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode==KEY_DELETE && grabbed!=-1) {
@@ -446,7 +446,7 @@ Vector<ColorRamp::Point>& ColorRampEdit::get_points() {
}
void ColorRampEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&ColorRampEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorRampEdit::_color_changed);
+ ClassDB::bind_method(_MD("_gui_input"),&ColorRampEdit::_gui_input);
+ ClassDB::bind_method(_MD("_color_changed"),&ColorRampEdit::_color_changed);
ADD_SIGNAL(MethodInfo("ramp_changed"));
}
diff --git a/scene/gui/color_ramp_edit.h b/scene/gui/color_ramp_edit.h
index 61365d9f07..c6a20a539d 100644
--- a/scene/gui/color_ramp_edit.h
+++ b/scene/gui/color_ramp_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
class ColorRampEdit : public Control {
- OBJ_TYPE(ColorRampEdit,Control);
+ GDCLASS(ColorRampEdit,Control);
PopupPanel *popup;
ColorPicker *picker;
@@ -55,7 +55,7 @@ class ColorRampEdit : public Control {
void _show_color_picker();
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
static void _bind_methods();
@@ -73,7 +73,7 @@ public:
/*class ColorRampEditPanel : public Panel
{
- OBJ_TYPE(ColorRampEditPanel, Panel );
+ GDCLASS(ColorRampEditPanel, Panel );
};*/
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
index a0e4df66b5..99797aa9c1 100644
--- a/scene/gui/color_rect.cpp
+++ b/scene/gui/color_rect.cpp
@@ -1,36 +1,61 @@
+/*************************************************************************/
+/* color_rect.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "color_rect.h"
-
-
-void ColorFrame::set_frame_color(const Color& p_color) {
+void ColorRect::set_frame_color(const Color& p_color) {
color=p_color;
update();
}
-Color ColorFrame::get_frame_color() const{
+Color ColorRect::get_frame_color() const{
return color;
}
-void ColorFrame::_notification(int p_what) {
+void ColorRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
draw_rect(Rect2(Point2(),get_size()),color);
}
}
-void ColorFrame::_bind_methods() {
+void ColorRect::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_frame_color","color"),&ColorFrame::set_frame_color);
- ObjectTypeDB::bind_method(_MD("get_frame_color"),&ColorFrame::get_frame_color);
+ ClassDB::bind_method(_MD("set_frame_color","color"),&ColorRect::set_frame_color);
+ ClassDB::bind_method(_MD("get_frame_color"),&ColorRect::get_frame_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_frame_color"),_SCS("get_frame_color") );
}
-ColorFrame::ColorFrame() {
+ColorRect::ColorRect() {
color=Color(1,1,1);
}
-
diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h
index 3816d44052..55e413ce27 100644
--- a/scene/gui/color_rect.h
+++ b/scene/gui/color_rect.h
@@ -1,10 +1,38 @@
-#ifndef COLORRECT_H
-#define COLORRECT_H
+/*************************************************************************/
+/* color_rect.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef COLOR_RECT_H
+#define COLOR_RECT_H
#include "scene/gui/control.h"
-class ColorFrame : public Control {
- OBJ_TYPE(ColorFrame,Control)
+class ColorRect : public Control {
+ GDCLASS(ColorRect,Control)
Color color;
protected:
@@ -16,7 +44,7 @@ public:
void set_frame_color(const Color& p_color);
Color get_frame_color() const;
- ColorFrame();
+ ColorRect();
};
-#endif // COLORRECT_H
+#endif // COLOR_RECT_H
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index feaf516f42..de5f35933c 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -147,7 +147,7 @@ void Container::_notification(int p_what) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
queue_sort();
}
} break;
@@ -156,11 +156,11 @@ void Container::_notification(int p_what) {
void Container::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_sort_children"),&Container::_sort_children);
- ObjectTypeDB::bind_method(_MD("_child_minsize_changed"),&Container::_child_minsize_changed);
+ ClassDB::bind_method(_MD("_sort_children"),&Container::_sort_children);
+ ClassDB::bind_method(_MD("_child_minsize_changed"),&Container::_child_minsize_changed);
- ObjectTypeDB::bind_method(_MD("queue_sort"),&Container::queue_sort);
- ObjectTypeDB::bind_method(_MD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
+ ClassDB::bind_method(_MD("queue_sort"),&Container::queue_sort);
+ ClassDB::bind_method(_MD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
BIND_CONSTANT( NOTIFICATION_SORT_CHILDREN );
ADD_SIGNAL(MethodInfo("sort_children"));
diff --git a/scene/gui/container.h b/scene/gui/container.h
index 1c7587c155..bb47524972 100644
--- a/scene/gui/container.h
+++ b/scene/gui/container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Container : public Control {
- OBJ_TYPE(Container,Control);
+ GDCLASS(Container,Control);
bool pending_sort;
void _sort_children();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index a5bee32a69..533d24f998 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,7 +96,7 @@ Size2 Control::edit_get_minimum_size() const {
void Control::edit_set_rect(const Rect2& p_edit_rect) {
- Matrix32 postxf;
+ Transform2D postxf;
postxf.set_rotation_and_scale(data.rotation,data.scale);
Vector2 new_pos = postxf.xform(p_edit_rect.pos);
@@ -116,30 +116,7 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) {
String name= p_name;
if (!name.begins_with("custom")) {
- if (name.begins_with("margin/")) {
- String dname = name.get_slicec('/', 1);
- if (dname == "left") {
- set_margin(MARGIN_LEFT, p_value);
- return true;
- }
- else if (dname == "top") {
- set_margin(MARGIN_TOP, p_value);
- return true;
- }
- else if (dname == "right") {
- set_margin(MARGIN_RIGHT, p_value);
- return true;
- }
- else if (dname == "bottom") {
- set_margin(MARGIN_BOTTOM, p_value);
- return true;
- }
- else {
- return false;
- }
- } else {
- return false;
- }
+ return false;
}
if (p_value.get_type()==Variant::NIL) {
@@ -235,30 +212,8 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
String sname=p_name;
if (!sname.begins_with("custom")) {
- if (sname.begins_with("margin/")) {
- String dname = sname.get_slicec('/', 1);
- if (dname == "left") {
- r_ret = get_margin(MARGIN_LEFT);
- return true;
- }
- else if (dname == "top") {
- r_ret = get_margin(MARGIN_TOP);
- return true;
- }
- else if (dname == "right") {
- r_ret = get_margin(MARGIN_RIGHT);
- return true;
- }
- else if (dname == "bottom") {
- r_ret = get_margin(MARGIN_BOTTOM);
- return true;
- }
- else {
- return false;
- }
- } else {
- return false;
- }
+ return false;
+
}
if (sname.begins_with("custom_icons/")) {
@@ -295,36 +250,6 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
}
void Control::_get_property_list( List<PropertyInfo> *p_list) const {
- {
- if (get_anchor(MARGIN_LEFT) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_TOP) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_RIGHT) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_BOTTOM) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
- }
-
Ref<Theme> theme;
if (data.theme.is_valid()) {
@@ -336,7 +261,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
{
List<StringName> names;
- theme->get_icon_list(get_type_name(),&names);
+ theme->get_icon_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -348,7 +273,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_shader_list(get_type_name(),&names);
+ theme->get_shader_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -360,7 +285,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_stylebox_list(get_type_name(),&names);
+ theme->get_stylebox_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -372,7 +297,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_font_list(get_type_name(),&names);
+ theme->get_font_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -384,7 +309,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_color_list(get_type_name(),&names);
+ theme->get_color_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -396,7 +321,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_constant_list(get_type_name(),&names);
+ theme->get_constant_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -449,7 +374,7 @@ void Control::remove_child_notify(Node *p_child) {
void Control::_update_canvas_item_transform() {
- Matrix32 xform=Matrix32(data.rotation,get_pos());
+ Transform2D xform=Transform2D(data.rotation,get_pos());
xform.scale_basis(data.scale);
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform);
@@ -480,10 +405,10 @@ void Control::_notification(int p_notification) {
if (is_set_as_toplevel()) {
data.SI=get_viewport()->_gui_add_subwindow_control(this);
- /*if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
data.theme_owner=data.parent->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
- }*/
+ }
} else {
@@ -519,10 +444,10 @@ void Control::_notification(int p_notification) {
if (parent_control) {
//do nothing, has a parent control
- /*if (data.theme.is_null() && parent_control->data.theme_owner) {
+ if (data.theme.is_null() && parent_control->data.theme_owner) {
data.theme_owner=parent_control->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
- }*/
+ }
} else if (subwindow) {
//is a subwindow (process input before other controls for that canvas)
data.SI=get_viewport()->_gui_add_subwindow_control(this);
@@ -543,10 +468,12 @@ void Control::_notification(int p_notification) {
}
- //if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
- // data.theme_owner=data.parent->data.theme_owner;
- // notification(NOTIFICATION_THEME_CHANGED);
- //}
+ /*
+ if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ data.theme_owner=data.parent->data.theme_owner;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ */
} break;
case NOTIFICATION_EXIT_CANVAS: {
@@ -578,10 +505,12 @@ void Control::_notification(int p_notification) {
data.parent=NULL;
data.parent_canvas_item=NULL;
- //if (data.theme_owner && data.theme.is_null()) {
- // data.theme_owner=NULL;
- //notification(NOTIFICATION_THEME_CHANGED);
- //}
+ /*
+ if (data.theme_owner && data.theme.is_null()) {
+ data.theme_owner=NULL;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ */
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
@@ -607,26 +536,26 @@ void Control::_notification(int p_notification) {
_update_canvas_item_transform();
VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),!data.disable_visibility_clip, Rect2(Point2(),get_size()));
-
+ VisualServer::get_singleton()->canvas_item_set_clip( get_canvas_item(), data.clip_contents );
//emit_signal(SceneStringNames::get_singleton()->draw);
} break;
case NOTIFICATION_MOUSE_ENTER: {
- emit_signal(SceneStringNames::get_singleton()->mouse_enter);
+ emit_signal(SceneStringNames::get_singleton()->mouse_entered);
} break;
case NOTIFICATION_MOUSE_EXIT: {
- emit_signal(SceneStringNames::get_singleton()->mouse_exit);
+ emit_signal(SceneStringNames::get_singleton()->mouse_exited);
} break;
case NOTIFICATION_FOCUS_ENTER: {
- emit_signal(SceneStringNames::get_singleton()->focus_enter);
+ emit_signal(SceneStringNames::get_singleton()->focus_entered);
update();
} break;
case NOTIFICATION_FOCUS_EXIT: {
- emit_signal(SceneStringNames::get_singleton()->focus_exit);
+ emit_signal(SceneStringNames::get_singleton()->focus_exited);
update();
} break;
@@ -636,11 +565,11 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_MODAL_CLOSE: {
- emit_signal("modal_close");
+ emit_signal("modal_closed");
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (!is_visible()) {
+ if (!is_visible_in_tree()) {
if(get_viewport() != NULL)
get_viewport()->_gui_hid_control(this);
@@ -822,15 +751,23 @@ Ref<Texture> Control::get_icon(const StringName& p_name,const StringName& p_type
return *tex;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_icon(p_name, type ) )
- return theme_owner->data.theme->get_icon(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_icon(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_icon(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -852,15 +789,23 @@ Ref<Shader> Control::get_shader(const StringName& p_name,const StringName& p_typ
return *sdr;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_shader(p_name, type))
- return theme_owner->data.theme->get_shader(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_shader(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_shader(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -881,16 +826,23 @@ Ref<StyleBox> Control::get_stylebox(const StringName& p_name,const StringName& p
return *style;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) ) {
- return theme_owner->data.theme->get_stylebox(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_stylebox(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_stylebox(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
}
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -910,15 +862,23 @@ Ref<Font> Control::get_font(const StringName& p_name,const StringName& p_type) c
return *font;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_font(p_name, type ) )
- return theme_owner->data.theme->get_font(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_font(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_font(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
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;
@@ -941,14 +901,22 @@ Color Control::get_color(const StringName& p_name,const StringName& p_type) cons
return *color;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_color(p_name, type ) )
- return theme_owner->data.theme->get_color(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_color(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_color(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -970,14 +938,22 @@ int Control::get_constant(const StringName& p_name,const StringName& p_type) con
return *constant;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_constant(p_name, type ) )
- return theme_owner->data.theme->get_constant(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_constant(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_constant(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1053,15 +1029,22 @@ bool Control::has_icon(const StringName& p_name,const StringName& p_type) const
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_icon(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_icon(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1082,15 +1065,22 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_shader(p_name, type))
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_shader(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1110,15 +1100,22 @@ bool Control::has_stylebox(const StringName& p_name,const StringName& p_type) co
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_stylebox(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1139,15 +1136,22 @@ bool Control::has_font(const StringName& p_name,const StringName& p_type) const
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_font(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_font(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1168,15 +1172,22 @@ bool Control::has_color(const StringName& p_name, const StringName& p_type) cons
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_color(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_color(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1198,15 +1209,22 @@ bool Control::has_constant(const StringName& p_name,const StringName& p_type) co
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_constant(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_constant(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1258,14 +1276,10 @@ void Control::_size_changed() {
margin_pos[i]=area-data.margin[i];
} break;
- case ANCHOR_RATIO: {
+ case ANCHOR_CENTER: {
- margin_pos[i]=area*data.margin[i];
+ margin_pos[i]=(area/2)-data.margin[i];
} break;
- case ANCHOR_CENTER: {
-
- margin_pos[i]=(area/2)-data.margin[i];
- } break;
}
}
@@ -1334,12 +1348,9 @@ float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const {
case ANCHOR_END: {
return p_range-p_val;
} break;
- case ANCHOR_RATIO: {
- return p_val/p_range;
+ case ANCHOR_CENTER: {
+ return (p_range/2)-p_val;
} break;
- case ANCHOR_CENTER: {
- return (p_range/2)-p_val;
- } break;
}
return 0;
@@ -1356,11 +1367,8 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const {
case ANCHOR_END: {
return Math::floor(p_range-p_val);
} break;
- case ANCHOR_RATIO: {
- return Math::floor(p_range*p_val);
- } break;
case ANCHOR_CENTER: {
- return Math::floor((p_range/2)-p_val);
+ return Math::floor((p_range/2)-p_val);
} break;
}
return 0;
@@ -1387,7 +1395,7 @@ void Control::set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin
void Control::_set_anchor(Margin p_margin,AnchorType p_anchor) {
#ifdef TOOLS_ENABLED
if (is_inside_tree() && get_tree()->is_editor_hint()) {
- set_anchor(p_margin, p_anchor, EDITOR_DEF("2d_editor/keep_margins_when_changing_anchors", false));
+ set_anchor(p_margin, p_anchor, EDITOR_DEF("editors/2d/keep_margins_when_changing_anchors", false));
} else {
set_anchor(p_margin, p_anchor, false);
}
@@ -1467,7 +1475,7 @@ Point2 Control::get_global_pos() const {
void Control::set_global_pos(const Point2& p_point) {
- Matrix32 inv;
+ Transform2D inv;
if (data.parent_canvas_item) {
@@ -1656,7 +1664,7 @@ static Control *_next_control(Control *p_from) {
for(int i=(next+1);i<parent->get_child_count();i++) {
Control *c = parent->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
return c;
@@ -1681,7 +1689,7 @@ Control *Control::find_next_valid_focus() const {
for(int i=0;i<from->get_child_count();i++) {
Control *c = from->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1725,11 +1733,11 @@ Control *Control::find_next_valid_focus() const {
if (next_child==this) // no next control->
return (get_focus_mode()==FOCUS_ALL)?next_child:NULL;
-
- if (next_child->get_focus_mode()==FOCUS_ALL)
- return next_child;
-
- from = next_child;
+ if (next_child) {
+ if (next_child->get_focus_mode()==FOCUS_ALL)
+ return next_child;
+ from = next_child;
+ } else break;
}
return NULL;
@@ -1747,7 +1755,7 @@ static Control *_prev_control(Control *p_from) {
for(int i=p_from->get_child_count()-1;i>=0;i--) {
Control *c = p_from->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
child=c;
@@ -1787,7 +1795,7 @@ Control *Control::find_prev_valid_focus() const {
Control *c = from->get_parent()->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1871,7 +1879,7 @@ void Control::show_modal(bool p_exclusive) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND(!data.SI);
- if (is_visible())
+ if (is_visible_in_tree())
hide();
ERR_FAIL_COND( data.MI!=NULL );
@@ -1879,7 +1887,7 @@ void Control::show_modal(bool p_exclusive) {
raise();
data.modal_exclusive=p_exclusive;
data.MI=get_viewport()->_gui_show_modal(this);
- data.modal_frame=OS::get_singleton()->get_frames_drawn();
+ data.modal_frame=Engine::get_singleton()->get_frames_drawn();
}
@@ -2003,9 +2011,9 @@ Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const {
return data.default_cursor;
}
-Matrix32 Control::get_transform() const {
+Transform2D Control::get_transform() const {
- Matrix32 xform=Matrix32(data.rotation,get_pos());
+ Transform2D xform=Transform2D(data.rotation,get_pos());
xform.scale_basis(data.scale);
return xform;
}
@@ -2049,7 +2057,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
return NULL;
}
bool valid=true;
- if (c->is_hidden())
+ if (!c->is_visible())
valid=false;
if (c->get_focus_mode()==FOCUS_NONE)
valid=false;
@@ -2066,7 +2074,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
Point2 points[4];
- Matrix32 xform = get_global_transform();
+ Transform2D xform = get_global_transform();
Rect2 rect = get_item_rect();
points[0]=xform.xform(rect.pos);
@@ -2122,11 +2130,11 @@ void Control::_window_find_focus_neighbour(const Vector2& p_dir, Node *p_at,cons
Control *c = p_at->cast_to<Control>();
- if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible()) {
+ if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible_in_tree()) {
Point2 points[4];
- Matrix32 xform = c->get_global_transform();
+ Transform2D xform = c->get_global_transform();
Rect2 rect = c->get_item_rect();
points[0]=xform.xform(rect.pos);
@@ -2246,25 +2254,17 @@ int Control::get_v_size_flags() const{
return data.v_size_flags;
}
-void Control::set_ignore_mouse(bool p_ignore) {
-
- data.ignore_mouse=p_ignore;
-}
-
-bool Control::is_ignoring_mouse() const {
+void Control::set_mouse_filter(MouseFilter p_filter) {
- return data.ignore_mouse;
+ ERR_FAIL_INDEX(p_filter,3);
+ data.mouse_filter=p_filter;
}
-void Control::set_stop_mouse(bool p_stop) {
+Control::MouseFilter Control::get_mouse_filter() const{
- data.stop_mouse=p_stop;
+ return data.mouse_filter;
}
-bool Control::is_stopping_mouse() const {
-
- return data.stop_mouse;
-}
Control *Control::get_focus_owner() const {
@@ -2414,15 +2414,15 @@ void Control::get_argument_options(const StringName& p_function,int p_idx,List<S
List<StringName> sn;
String pf = p_function;
if (pf=="add_color_override" || pf=="has_color" || pf=="has_color_override" || pf=="get_color") {
- Theme::get_default()->get_color_list(get_type(),&sn);
+ Theme::get_default()->get_color_list(get_class(),&sn);
} else if (pf=="add_style_override" || pf=="has_style" || pf=="has_style_override" || pf=="get_style") {
- Theme::get_default()->get_stylebox_list(get_type(),&sn);
+ Theme::get_default()->get_stylebox_list(get_class(),&sn);
} else if (pf=="add_font_override" || pf=="has_font" || pf=="has_font_override" || pf=="get_font") {
- Theme::get_default()->get_font_list(get_type(),&sn);
+ Theme::get_default()->get_font_list(get_class(),&sn);
} else if (pf=="add_constant_override" || pf=="has_constant" || pf=="has_constant_override" || pf=="get_constant") {
- Theme::get_default()->get_constant_list(get_type(),&sn);
+ Theme::get_default()->get_constant_list(get_class(),&sn);
} else if (pf=="add_color_override" || pf=="has_color" || pf=="has_color_override" || pf=="get_color") {
- Theme::get_default()->get_color_list(get_type(),&sn);
+ Theme::get_default()->get_color_list(get_class(),&sn);
}
sn.sort_custom<StringName::AlphCompare>();
@@ -2433,163 +2433,190 @@ void Control::get_argument_options(const StringName& p_function,int p_idx,List<S
}
+void Control::set_clip_contents(bool p_clip) {
+
+ data.clip_contents=p_clip;
+ update();
+}
+
+bool Control::is_clipping_contents() {
+
+ return data.clip_contents;
+}
void Control::_bind_methods() {
-// ObjectTypeDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
- ObjectTypeDB::bind_method(_MD("_size_changed"),&Control::_size_changed);
- ObjectTypeDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size);
-
- ObjectTypeDB::bind_method(_MD("accept_event"),&Control::accept_event);
- ObjectTypeDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
- ObjectTypeDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
- ObjectTypeDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
- ObjectTypeDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
- ObjectTypeDB::bind_method(_MD("set_begin","pos"),&Control::set_begin);
- ObjectTypeDB::bind_method(_MD("set_end","pos"),&Control::set_end);
- ObjectTypeDB::bind_method(_MD("set_pos","pos"),&Control::set_pos);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size);
- ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
- ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
+ //ClassDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
+ ClassDB::bind_method(_MD("_size_changed"),&Control::_size_changed);
+ ClassDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size);
+
+ ClassDB::bind_method(_MD("accept_event"),&Control::accept_event);
+ ClassDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
+ ClassDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
+ ClassDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
+ ClassDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
+ ClassDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
+ ClassDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
+ ClassDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
+ ClassDB::bind_method(_MD("set_begin","pos"),&Control::set_begin);
+ ClassDB::bind_method(_MD("set_end","pos"),&Control::set_end);
+ ClassDB::bind_method(_MD("set_pos","pos"),&Control::set_pos);
+ ClassDB::bind_method(_MD("set_size","size"),&Control::set_size);
+ ClassDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
+ ClassDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
+ ClassDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
+ ClassDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
- ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
- ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin);
- ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end);
- ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos);
- ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size);
- ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
- ObjectTypeDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
+ ClassDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
+ ClassDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
+ ClassDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
+ ClassDB::bind_method(_MD("get_begin"),&Control::get_begin);
+ ClassDB::bind_method(_MD("get_end"),&Control::get_end);
+ ClassDB::bind_method(_MD("get_pos"),&Control::get_pos);
+ ClassDB::bind_method(_MD("get_size"),&Control::get_size);
+ ClassDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
+ ClassDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
- ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale);
- ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
- ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
- ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect);
- ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
- ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_focus_mode","mode"),&Control::set_focus_mode);
- ObjectTypeDB::bind_method(_MD("get_focus_mode"),&Control::get_focus_mode);
- ObjectTypeDB::bind_method(_MD("has_focus"),&Control::has_focus);
- ObjectTypeDB::bind_method(_MD("grab_focus"),&Control::grab_focus);
- ObjectTypeDB::bind_method(_MD("release_focus"),&Control::release_focus);
- ObjectTypeDB::bind_method(_MD("get_focus_owner:Control"),&Control::get_focus_owner);
+ ClassDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
+ ClassDB::bind_method(_MD("get_scale"),&Control::get_scale);
+ ClassDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
+ ClassDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
+ ClassDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
+ ClassDB::bind_method(_MD("get_rect"),&Control::get_rect);
+ ClassDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
+ ClassDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
+ ClassDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
+ ClassDB::bind_method(_MD("set_focus_mode","mode"),&Control::set_focus_mode);
+ ClassDB::bind_method(_MD("get_focus_mode"),&Control::get_focus_mode);
+ ClassDB::bind_method(_MD("has_focus"),&Control::has_focus);
+ ClassDB::bind_method(_MD("grab_focus"),&Control::grab_focus);
+ ClassDB::bind_method(_MD("release_focus"),&Control::release_focus);
+ ClassDB::bind_method(_MD("get_focus_owner:Control"),&Control::get_focus_owner);
- ObjectTypeDB::bind_method(_MD("set_h_size_flags","flags"),&Control::set_h_size_flags);
- ObjectTypeDB::bind_method(_MD("get_h_size_flags"),&Control::get_h_size_flags);
+ ClassDB::bind_method(_MD("set_h_size_flags","flags"),&Control::set_h_size_flags);
+ ClassDB::bind_method(_MD("get_h_size_flags"),&Control::get_h_size_flags);
- ObjectTypeDB::bind_method(_MD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
- ObjectTypeDB::bind_method(_MD("get_stretch_ratio"),&Control::get_stretch_ratio);
+ ClassDB::bind_method(_MD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
+ ClassDB::bind_method(_MD("get_stretch_ratio"),&Control::get_stretch_ratio);
- ObjectTypeDB::bind_method(_MD("set_v_size_flags","flags"),&Control::set_v_size_flags);
- ObjectTypeDB::bind_method(_MD("get_v_size_flags"),&Control::get_v_size_flags);
+ ClassDB::bind_method(_MD("set_v_size_flags","flags"),&Control::set_v_size_flags);
+ ClassDB::bind_method(_MD("get_v_size_flags"),&Control::get_v_size_flags);
- ObjectTypeDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme);
- ObjectTypeDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme);
+ ClassDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme);
+ ClassDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme);
- ObjectTypeDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
- ObjectTypeDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
- ObjectTypeDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
- ObjectTypeDB::bind_method(_MD("add_font_override","name","font:Font"),&Control::add_font_override);
- ObjectTypeDB::bind_method(_MD("add_color_override","name","color"),&Control::add_color_override);
- ObjectTypeDB::bind_method(_MD("add_constant_override","name","constant"),&Control::add_constant_override);
+ ClassDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
+ ClassDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
+ ClassDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
+ ClassDB::bind_method(_MD("add_font_override","name","font:Font"),&Control::add_font_override);
+ ClassDB::bind_method(_MD("add_color_override","name","color"),&Control::add_color_override);
+ ClassDB::bind_method(_MD("add_constant_override","name","constant"),&Control::add_constant_override);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_color","name","type"),&Control::get_color,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_color","name","type"),&Control::get_color,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_icon_override", "name"), &Control::has_icon_override);
- ObjectTypeDB::bind_method(_MD("has_stylebox_override", "name"), &Control::has_stylebox_override);
- ObjectTypeDB::bind_method(_MD("has_font_override", "name"), &Control::has_font_override);
- ObjectTypeDB::bind_method(_MD("has_color_override", "name"), &Control::has_color_override);
- ObjectTypeDB::bind_method(_MD("has_constant_override", "name"), &Control::has_constant_override);
+ ClassDB::bind_method(_MD("has_icon_override", "name"), &Control::has_icon_override);
+ ClassDB::bind_method(_MD("has_stylebox_override", "name"), &Control::has_stylebox_override);
+ ClassDB::bind_method(_MD("has_font_override", "name"), &Control::has_font_override);
+ ClassDB::bind_method(_MD("has_color_override", "name"), &Control::has_color_override);
+ ClassDB::bind_method(_MD("has_constant_override", "name"), &Control::has_constant_override);
- ObjectTypeDB::bind_method(_MD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control);
+ ClassDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control);
- ObjectTypeDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip);
- ObjectTypeDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2()));
- ObjectTypeDB::bind_method(_MD("_get_tooltip"),&Control::_get_tooltip);
+ ClassDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip);
+ ClassDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2()));
+ ClassDB::bind_method(_MD("_get_tooltip"),&Control::_get_tooltip);
- ObjectTypeDB::bind_method(_MD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
- ObjectTypeDB::bind_method(_MD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
- ObjectTypeDB::bind_method(_MD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
+ ClassDB::bind_method(_MD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
+ ClassDB::bind_method(_MD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
+ ClassDB::bind_method(_MD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
- ObjectTypeDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour);
- ObjectTypeDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour);
+ ClassDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour);
+ ClassDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour);
- ObjectTypeDB::bind_method(_MD("set_ignore_mouse","ignore"),&Control::set_ignore_mouse);
- ObjectTypeDB::bind_method(_MD("is_ignoring_mouse"),&Control::is_ignoring_mouse);
+ ClassDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag);
- ObjectTypeDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag);
+ ClassDB::bind_method(_MD("set_mouse_filter","filter"),&Control::set_mouse_filter);
+ ClassDB::bind_method(_MD("get_mouse_filter"),&Control::get_mouse_filter);
- ObjectTypeDB::bind_method(_MD("set_stop_mouse","stop"),&Control::set_stop_mouse);
- ObjectTypeDB::bind_method(_MD("is_stopping_mouse"),&Control::is_stopping_mouse);
+ ClassDB::bind_method(_MD("set_clip_contents","enable"),&Control::set_clip_contents);
+ ClassDB::bind_method(_MD("is_clipping_contents"),&Control::is_clipping_contents);
- ObjectTypeDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus);
+ ClassDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus);
- ObjectTypeDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
- ObjectTypeDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview);
+ ClassDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
+ ClassDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview);
- ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse);
+ ClassDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse);
- ObjectTypeDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
+ ClassDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
- ObjectTypeDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
+ ClassDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
- ObjectTypeDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
+ ClassDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
- BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
+ BIND_VMETHOD(MethodInfo("_gui_input",PropertyInfo(Variant::INPUT_EVENT,"event")));
BIND_VMETHOD(MethodInfo(Variant::VECTOR2,"get_minimum_size"));
BIND_VMETHOD(MethodInfo(Variant::OBJECT,"get_drag_data",PropertyInfo(Variant::VECTOR2,"pos")));
BIND_VMETHOD(MethodInfo(Variant::BOOL,"can_drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
BIND_VMETHOD(MethodInfo("drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/left", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/top", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/right", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
-
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
- ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/ignore_mouse"), _SCS("set_ignore_mouse"),_SCS("is_ignoring_mouse") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/stop_mouse"), _SCS("set_stop_mouse"),_SCS("is_stopping_mouse") );
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") );
+ ADD_GROUP("Anchor","anchor_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_left", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_top", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_right", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_bottom", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
+
+ ADD_GROUP("Margin","margin_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_top", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_right", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_BOTTOM );
+
+ ADD_GROUP("Rect","rect_");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect_rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect_scale"), _SCS("set_scale"),_SCS("get_scale") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"rect_clip_content"), _SCS("set_clip_contents"),_SCS("is_clipping_contents") );
+
+
+ ADD_GROUP("Hint","hint_");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
+
+ ADD_GROUP("Focus","focus_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM );
+
+ ADD_GROUP("Mouse","mouse_");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mouse_filter",PROPERTY_HINT_ENUM,"Stop,Pass,Ignore"), _SCS("set_mouse_filter"),_SCS("get_mouse_filter") );
+
+ ADD_GROUP("Size Flags","size_flags_");
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") );
+ ADD_GROUP("Theme","");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") );
+ ADD_GROUP("","");
BIND_CONSTANT( ANCHOR_BEGIN );
BIND_CONSTANT( ANCHOR_END );
- BIND_CONSTANT( ANCHOR_RATIO );
BIND_CONSTANT( ANCHOR_CENTER );
BIND_CONSTANT( FOCUS_NONE );
BIND_CONSTANT( FOCUS_CLICK );
@@ -2626,15 +2653,19 @@ void Control::_bind_methods() {
BIND_CONSTANT( SIZE_FILL );
BIND_CONSTANT( SIZE_EXPAND_FILL );
+ BIND_CONSTANT( MOUSE_FILTER_STOP );
+ BIND_CONSTANT( MOUSE_FILTER_PASS );
+ BIND_CONSTANT( MOUSE_FILTER_IGNORE );
+
ADD_SIGNAL( MethodInfo("resized") );
- ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
- ADD_SIGNAL( MethodInfo("mouse_enter") );
- ADD_SIGNAL( MethodInfo("mouse_exit") );
- ADD_SIGNAL( MethodInfo("focus_enter") );
- ADD_SIGNAL( MethodInfo("focus_exit") );
+ ADD_SIGNAL( MethodInfo("gui_input",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
+ ADD_SIGNAL( MethodInfo("mouse_entered") );
+ ADD_SIGNAL( MethodInfo("mouse_exited") );
+ ADD_SIGNAL( MethodInfo("focus_entered") );
+ ADD_SIGNAL( MethodInfo("focus_exited") );
ADD_SIGNAL( MethodInfo("size_flags_changed") );
ADD_SIGNAL( MethodInfo("minimum_size_changed") );
- ADD_SIGNAL( MethodInfo("modal_close") );
+ ADD_SIGNAL( MethodInfo("modal_closed") );
}
@@ -2642,9 +2673,7 @@ Control::Control() {
data.parent=NULL;
- data.ignore_mouse=false;
- data.stop_mouse=true;
-
+ data.mouse_filter=MOUSE_FILTER_STOP;
data.SI=NULL;
data.MI=NULL;
@@ -2665,7 +2694,7 @@ Control::Control() {
data.block_minimum_size_adjust=false;
data.disable_visibility_clip=false;
-
+ data.clip_contents=false;
for (int i=0;i<4;i++) {
data.anchor[i]=ANCHOR_BEGIN;
data.margin[i]=0;
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 37efd80970..68795b054c 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -46,7 +46,7 @@ class Panel;
class Control : public CanvasItem {
- OBJ_TYPE( Control, CanvasItem );
+ GDCLASS( Control, CanvasItem );
OBJ_CATEGORY("GUI Nodes");
public:
@@ -54,7 +54,6 @@ public:
enum AnchorType {
ANCHOR_BEGIN,
ANCHOR_END,
- ANCHOR_RATIO,
ANCHOR_CENTER,
};
@@ -66,12 +65,18 @@ public:
enum SizeFlags {
- SIZE_EXPAND=1,
- SIZE_FILL=2,
+ SIZE_FILL=1,
+ SIZE_EXPAND=2,
SIZE_EXPAND_FILL=SIZE_EXPAND|SIZE_FILL
};
+ enum MouseFilter {
+ MOUSE_FILTER_STOP,
+ MOUSE_FILTER_PASS,
+ MOUSE_FILTER_IGNORE
+ };
+
enum CursorShape {
CURSOR_ARROW,
CURSOR_IBEAM,
@@ -125,8 +130,9 @@ private:
bool pending_min_size_update;
Point2 custom_minimum_size;
- bool ignore_mouse;
- bool stop_mouse;
+ MouseFilter mouse_filter;
+
+ bool clip_contents;
bool block_minimum_size_adjust;
bool disable_visibility_clip;
@@ -162,7 +168,7 @@ private:
} data;
// used internally
- Control* _find_control_at_pos(CanvasItem* p_node,const Point2& p_pos,const Matrix32& p_xform,Matrix32& r_inv_xform);
+ Control* _find_control_at_pos(CanvasItem* p_node,const Point2& p_pos,const Transform2D& p_xform,Transform2D& r_inv_xform);
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);
@@ -208,7 +214,7 @@ protected:
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
- //virtual void _window_input_event(InputEvent p_event);
+ //virtual void _window_gui_input(InputEvent p_event);
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
@@ -338,11 +344,8 @@ public:
Control *get_focus_owner() const;
- void set_ignore_mouse(bool p_ignore);
- bool is_ignoring_mouse() const;
-
- void set_stop_mouse(bool p_stop);
- bool is_stopping_mouse() const;
+ void set_mouse_filter(MouseFilter p_filter);
+ MouseFilter get_mouse_filter() const;
/* SKINNING */
@@ -386,7 +389,7 @@ public:
virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
virtual Rect2 get_item_rect() const;
- virtual Matrix32 get_transform() const;
+ virtual Transform2D get_transform() const;
bool is_toplevel_control() const;
@@ -400,6 +403,8 @@ public:
Control *get_root_parent_control() const;
+ void set_clip_contents(bool p_clip);
+ bool is_clipping_contents();
void set_block_minimum_size_adjust(bool p_block);
bool is_minimum_size_adjust_blocked() const;
@@ -418,5 +423,6 @@ VARIANT_ENUM_CAST(Control::AnchorType);
VARIANT_ENUM_CAST(Control::FocusMode);
VARIANT_ENUM_CAST(Control::SizeFlags);
VARIANT_ENUM_CAST(Control::CursorShape);
+VARIANT_ENUM_CAST(Control::MouseFilter);
#endif
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 15ff334c92..cc6fe7cae8 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,7 +47,7 @@ bool WindowDialog::has_point(const Point2& p_point) const {
}
-void WindowDialog::_input_event(const InputEvent& p_event) {
+void WindowDialog::_gui_input(const InputEvent& p_event) {
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
@@ -141,13 +141,13 @@ TextureButton *WindowDialog::get_close_button() {
void WindowDialog::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("_input_event"),&WindowDialog::_input_event);
- ObjectTypeDB::bind_method( _MD("set_title","title"),&WindowDialog::set_title);
- ObjectTypeDB::bind_method( _MD("get_title"),&WindowDialog::get_title);
- ObjectTypeDB::bind_method( _MD("_closed"),&WindowDialog::_closed);
- ObjectTypeDB::bind_method( _MD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
+ ClassDB::bind_method( _MD("_gui_input"),&WindowDialog::_gui_input);
+ ClassDB::bind_method( _MD("set_title","title"),&WindowDialog::set_title);
+ ClassDB::bind_method( _MD("get_title"),&WindowDialog::get_title);
+ ClassDB::bind_method( _MD("_closed"),&WindowDialog::_closed);
+ ClassDB::bind_method( _MD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"window/title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_title"),_SCS("get_title"));
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"window_title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_title"),_SCS("get_title"));
}
WindowDialog::WindowDialog() {
@@ -203,7 +203,7 @@ void AcceptDialog::_notification(int p_what) {
cancel_pressed();
} if (p_what==NOTIFICATION_RESIZED) {
- _update_child_rect();
+ _update_child_rects();
}
}
@@ -232,6 +232,8 @@ String AcceptDialog::get_text() const {
void AcceptDialog::set_text(String p_text) {
label->set_text(p_text);
+ minimum_size_changed();
+ _update_child_rects();
}
void AcceptDialog::set_hide_on_ok(bool p_hide) {
@@ -251,21 +253,31 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) {
p_line_edit->connect("text_entered", this,"_builtin_text_entered");
}
-void AcceptDialog::_update_child_rect() {
+void AcceptDialog::_update_child_rects() {
+
+ Size2 label_size=label->get_minimum_size();
+ if (label->get_text().empty()) {
+ label_size.height = 0;
+ }
int margin = get_constant("margin","Dialogs");
Size2 size = get_size();
Size2 hminsize = hbc->get_combined_minimum_size();
- Vector2 cpos(margin,margin);
- Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y);
- label->set_pos(cpos);
- label->set_size(csize);
+ Vector2 cpos(margin,margin+label_size.height);
+ 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>();
+ if (!c)
+ continue;
+
+ if (c==hbc || c==label || c==get_close_button())
+ continue;
- if (child) {
+ c->set_pos(cpos);
+ c->set_size(csize);
- child->set_pos(cpos);
- child->set_size(csize);
}
cpos.y+=csize.y+margin;
@@ -280,13 +292,23 @@ Size2 AcceptDialog::get_minimum_size() const {
int margin = get_constant("margin","Dialogs");
Size2 minsize = label->get_combined_minimum_size();
- if (child) {
- Size2 cminsize = child->get_combined_minimum_size();
+
+ for(int i=0;i<get_child_count();i++) {
+ Control *c = get_child(i)->cast_to<Control>();
+ if (!c)
+ continue;
+
+ if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button())
+ continue;
+
+ Size2 cminsize = c->get_combined_minimum_size();
minsize.x=MAX(cminsize.x,minsize.x);
minsize.y=MAX(cminsize.y,minsize.y);
+
}
+
Size2 hminsize = hbc->get_combined_minimum_size();
minsize.x = MAX(hminsize.x,minsize.x);
minsize.y+=hminsize.y;
@@ -299,23 +321,6 @@ Size2 AcceptDialog::get_minimum_size() const {
}
-void AcceptDialog::set_child_rect(Control *p_child) {
-
- ERR_FAIL_COND(p_child->get_parent()!=this);
-
- //p_child->set_area_as_parent_rect(get_constant("margin","Dialogs"));
- child=p_child;
- minimum_size_changed();
- _update_child_rect();
-}
-
-void AcceptDialog::remove_child_notify(Node *p_child) {
-
- if (p_child==child) {
- child=NULL;
- }
-}
-
void AcceptDialog::_custom_action(const String& p_action) {
emit_signal("custom_action",p_action);
@@ -356,25 +361,25 @@ Button* AcceptDialog::add_cancel(const String &p_cancel) {
void AcceptDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_ok"),&AcceptDialog::_ok_pressed);
- ObjectTypeDB::bind_method(_MD("get_ok"),&AcceptDialog::get_ok);
- ObjectTypeDB::bind_method(_MD("get_label"),&AcceptDialog::get_label);
- ObjectTypeDB::bind_method(_MD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
- ObjectTypeDB::bind_method(_MD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
- ObjectTypeDB::bind_method(_MD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
- ObjectTypeDB::bind_method(_MD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
- ObjectTypeDB::bind_method(_MD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
- ObjectTypeDB::bind_method(_MD("_custom_action"),&AcceptDialog::_custom_action);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&AcceptDialog::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&AcceptDialog::get_text);
- ObjectTypeDB::bind_method(_MD("set_child_rect","child:Control"),&AcceptDialog::set_child_rect);
+ ClassDB::bind_method(_MD("_ok"),&AcceptDialog::_ok_pressed);
+ ClassDB::bind_method(_MD("get_ok"),&AcceptDialog::get_ok);
+ ClassDB::bind_method(_MD("get_label"),&AcceptDialog::get_label);
+ ClassDB::bind_method(_MD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
+ ClassDB::bind_method(_MD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
+ ClassDB::bind_method(_MD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
+ ClassDB::bind_method(_MD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
+ ClassDB::bind_method(_MD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
+ ClassDB::bind_method(_MD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
+ ClassDB::bind_method(_MD("_custom_action"),&AcceptDialog::_custom_action);
+ ClassDB::bind_method(_MD("set_text","text"),&AcceptDialog::set_text);
+ ClassDB::bind_method(_MD("get_text"),&AcceptDialog::get_text);
ADD_SIGNAL( MethodInfo("confirmed") );
ADD_SIGNAL( MethodInfo("custom_action",PropertyInfo(Variant::STRING,"action")) );
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog/text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_text"),_SCS("get_text"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog/hide_on_ok"),_SCS("set_hide_on_ok"),_SCS("get_hide_on_ok") );
+ ADD_GROUP("Dialog","dialog");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog_text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_text"),_SCS("get_text"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"),_SCS("set_hide_on_ok"),_SCS("get_hide_on_ok") );
}
@@ -414,8 +419,6 @@ AcceptDialog::AcceptDialog() {
hide_on_ok=true;
set_title(RTR("Alert!"));
-
- child=NULL;
}
@@ -426,7 +429,7 @@ AcceptDialog::~AcceptDialog()
void ConfirmationDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
+ ClassDB::bind_method(_MD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
}
Button *ConfirmationDialog::get_cancel() {
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index d00bb41ff6..6650c5eb5d 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,13 +42,13 @@
class WindowDialog : public Popup {
- OBJ_TYPE(WindowDialog,Popup);
+ GDCLASS(WindowDialog,Popup);
TextureButton *close_button;
String title;
bool dragging;
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _closed();
protected:
virtual void _post_popup();
@@ -73,7 +73,7 @@ public:
class PopupDialog : public Popup {
- OBJ_TYPE(PopupDialog,Popup);
+ GDCLASS(PopupDialog,Popup);
protected:
void _notification(int p_what);
@@ -89,13 +89,12 @@ class LineEdit;
class AcceptDialog : public WindowDialog {
- OBJ_TYPE(AcceptDialog,WindowDialog);
+ GDCLASS(AcceptDialog,WindowDialog);
- Control *child;
HBoxContainer *hbc;
Label *label;
Button *ok;
-// Button *cancel; no more cancel (there is X on tht titlebar)
+ //Button *cancel; no more cancel (there is X on tht titlebar)
bool hide_on_ok;
@@ -103,13 +102,11 @@ class AcceptDialog : public WindowDialog {
void _ok_pressed();
void _close_pressed();
void _builtin_text_entered(const String& p_text);
- void _update_child_rect();
+ void _update_child_rects();
static bool swap_ok_cancel;
- virtual void remove_child_notify(Node *p_child);
-
protected:
@@ -140,8 +137,6 @@ public:
void set_text(String p_text);
String get_text() const;
- void set_child_rect(Control *p_child);
-
AcceptDialog();
~AcceptDialog();
@@ -150,7 +145,7 @@ public:
class ConfirmationDialog : public AcceptDialog {
- OBJ_TYPE(ConfirmationDialog,AcceptDialog);
+ GDCLASS(ConfirmationDialog,AcceptDialog);
Button *cancel;
protected:
static void _bind_methods();
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 6b43425edc..393f14bee2 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -164,7 +164,7 @@ void FileDialog::_action_pressed() {
TreeItem *ti=tree->get_next_selected(NULL);
String fbase=dir_access->get_current_dir();
- DVector<String> files;
+ PoolVector<String> files;
while(ti) {
files.push_back( fbase.plus_file(ti->get_text(0)) );
@@ -186,15 +186,17 @@ void FileDialog::_action_pressed() {
hide();
}else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
-
String path=dir_access->get_current_dir();
- /*if (tree->get_selected()) {
- Dictionary d = tree->get_selected()->get_metadata(0);
+
+ path=path.replace("\\","/");
+
+ if (TreeItem* item = tree->get_selected()) {
+ Dictionary d = item->get_metadata(0);
if (d["dir"]) {
- path=path+"/"+String(d["name"]);
+ path=path.plus_file(d["name"]);
}
- }*/
- path=path.replace("\\","/");
+ }
+
emit_signal("dir_selected",path);
hide();
}
@@ -348,18 +350,18 @@ void FileDialog::update_file_list() {
files.sort_custom<NoCaseComparator>();
while(!dirs.empty()) {
+ String& dir_name = dirs.front()->get();
+ TreeItem *ti=tree->create_item(root);
+ ti->set_text(0,dir_name+"/");
+ ti->set_icon(0,folder);
- if (dirs.front()->get()!=".") {
- TreeItem *ti=tree->create_item(root);
- ti->set_text(0,dirs.front()->get()+"/");
- ti->set_icon(0,folder);
- Dictionary d;
- d["name"]=dirs.front()->get();
- d["dir"]=true;
- ti->set_metadata(0,d);
- }
- dirs.pop_front();
+ Dictionary d;
+ d["name"]=dir_name;
+ d["dir"]=true;
+
+ ti->set_metadata(0,d);
+ dirs.pop_front();
}
dirs.clear();
@@ -401,11 +403,12 @@ void FileDialog::update_file_list() {
while(!files.empty()) {
bool match=patterns.empty();
+ String match_str;
for(List<String>::Element *E=patterns.front();E;E=E->next()) {
if (files.front()->get().matchn(E->get())) {
-
+ match_str=E->get();
match=true;
break;
}
@@ -430,14 +433,14 @@ void FileDialog::update_file_list() {
d["dir"]=false;
ti->set_metadata(0,d);
- if (file->get_text()==files.front()->get())
+ if (file->get_text()==files.front()->get() || match_str==files.front()->get())
ti->select(0);
}
files.pop_front();
}
- if (tree->get_root() && tree->get_root()->get_children())
+ if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected()==NULL)
tree->get_root()->get_children()->select(0);
files.clear();
@@ -612,7 +615,7 @@ void FileDialog::set_access(Access p_access) {
void FileDialog::invalidate() {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
update_file_list();
invalidated=false;
} else {
@@ -683,44 +686,44 @@ bool FileDialog::default_show_hidden_files=false;
void FileDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_unhandled_input"),&FileDialog::_unhandled_input);
-
- ObjectTypeDB::bind_method(_MD("_tree_selected"),&FileDialog::_tree_selected);
- ObjectTypeDB::bind_method(_MD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
- ObjectTypeDB::bind_method(_MD("_dir_entered"),&FileDialog::_dir_entered);
- ObjectTypeDB::bind_method(_MD("_file_entered"),&FileDialog::_file_entered);
- ObjectTypeDB::bind_method(_MD("_action_pressed"),&FileDialog::_action_pressed);
- ObjectTypeDB::bind_method(_MD("_cancel_pressed"),&FileDialog::_cancel_pressed);
- ObjectTypeDB::bind_method(_MD("_filter_selected"),&FileDialog::_filter_selected);
- ObjectTypeDB::bind_method(_MD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
-
- ObjectTypeDB::bind_method(_MD("clear_filters"),&FileDialog::clear_filters);
- ObjectTypeDB::bind_method(_MD("add_filter","filter"),&FileDialog::add_filter);
- ObjectTypeDB::bind_method(_MD("set_filters","filters"),&FileDialog::set_filters);
- ObjectTypeDB::bind_method(_MD("get_filters"),&FileDialog::get_filters);
- ObjectTypeDB::bind_method(_MD("get_current_dir"),&FileDialog::get_current_dir);
- ObjectTypeDB::bind_method(_MD("get_current_file"),&FileDialog::get_current_file);
- ObjectTypeDB::bind_method(_MD("get_current_path"),&FileDialog::get_current_path);
- ObjectTypeDB::bind_method(_MD("set_current_dir","dir"),&FileDialog::set_current_dir);
- ObjectTypeDB::bind_method(_MD("set_current_file","file"),&FileDialog::set_current_file);
- ObjectTypeDB::bind_method(_MD("set_current_path","path"),&FileDialog::set_current_path);
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&FileDialog::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&FileDialog::get_mode);
- ObjectTypeDB::bind_method(_MD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
- ObjectTypeDB::bind_method(_MD("set_access","access"),&FileDialog::set_access);
- ObjectTypeDB::bind_method(_MD("get_access"),&FileDialog::get_access);
- ObjectTypeDB::bind_method(_MD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
- ObjectTypeDB::bind_method(_MD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
- ObjectTypeDB::bind_method(_MD("_select_drive"),&FileDialog::_select_drive);
- ObjectTypeDB::bind_method(_MD("_make_dir"),&FileDialog::_make_dir);
- ObjectTypeDB::bind_method(_MD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
- ObjectTypeDB::bind_method(_MD("_update_file_list"),&FileDialog::update_file_list);
- ObjectTypeDB::bind_method(_MD("_update_dir"),&FileDialog::update_dir);
-
- ObjectTypeDB::bind_method(_MD("invalidate"),&FileDialog::invalidate);
+ ClassDB::bind_method(_MD("_unhandled_input"),&FileDialog::_unhandled_input);
+
+ ClassDB::bind_method(_MD("_tree_selected"),&FileDialog::_tree_selected);
+ ClassDB::bind_method(_MD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
+ ClassDB::bind_method(_MD("_dir_entered"),&FileDialog::_dir_entered);
+ ClassDB::bind_method(_MD("_file_entered"),&FileDialog::_file_entered);
+ ClassDB::bind_method(_MD("_action_pressed"),&FileDialog::_action_pressed);
+ ClassDB::bind_method(_MD("_cancel_pressed"),&FileDialog::_cancel_pressed);
+ ClassDB::bind_method(_MD("_filter_selected"),&FileDialog::_filter_selected);
+ ClassDB::bind_method(_MD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
+
+ ClassDB::bind_method(_MD("clear_filters"),&FileDialog::clear_filters);
+ ClassDB::bind_method(_MD("add_filter","filter"),&FileDialog::add_filter);
+ ClassDB::bind_method(_MD("set_filters","filters"),&FileDialog::set_filters);
+ ClassDB::bind_method(_MD("get_filters"),&FileDialog::get_filters);
+ ClassDB::bind_method(_MD("get_current_dir"),&FileDialog::get_current_dir);
+ ClassDB::bind_method(_MD("get_current_file"),&FileDialog::get_current_file);
+ ClassDB::bind_method(_MD("get_current_path"),&FileDialog::get_current_path);
+ ClassDB::bind_method(_MD("set_current_dir","dir"),&FileDialog::set_current_dir);
+ ClassDB::bind_method(_MD("set_current_file","file"),&FileDialog::set_current_file);
+ ClassDB::bind_method(_MD("set_current_path","path"),&FileDialog::set_current_path);
+ ClassDB::bind_method(_MD("set_mode","mode"),&FileDialog::set_mode);
+ ClassDB::bind_method(_MD("get_mode"),&FileDialog::get_mode);
+ ClassDB::bind_method(_MD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
+ ClassDB::bind_method(_MD("set_access","access"),&FileDialog::set_access);
+ ClassDB::bind_method(_MD("get_access"),&FileDialog::get_access);
+ ClassDB::bind_method(_MD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
+ ClassDB::bind_method(_MD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
+ ClassDB::bind_method(_MD("_select_drive"),&FileDialog::_select_drive);
+ ClassDB::bind_method(_MD("_make_dir"),&FileDialog::_make_dir);
+ ClassDB::bind_method(_MD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
+ ClassDB::bind_method(_MD("_update_file_list"),&FileDialog::update_file_list);
+ ClassDB::bind_method(_MD("_update_dir"),&FileDialog::update_dir);
+
+ ClassDB::bind_method(_MD("invalidate"),&FileDialog::invalidate);
ADD_SIGNAL(MethodInfo("file_selected",PropertyInfo( Variant::STRING,"path")));
- ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::STRING_ARRAY,"paths")));
+ 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 );
@@ -736,7 +739,7 @@ void FileDialog::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"),_SCS("set_mode"),_SCS("get_mode") );
ADD_PROPERTY( PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"),_SCS("set_access"),_SCS("get_access") );
- ADD_PROPERTY( PropertyInfo(Variant::STRING_ARRAY, "filters"),_SCS("set_filters"),_SCS("get_filters") );
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_STRING_ARRAY, "filters"),_SCS("set_filters"),_SCS("get_filters") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "show_hidden_files"),_SCS("set_show_hidden_files"),_SCS("is_showing_hidden_files") );
}
@@ -761,7 +764,7 @@ FileDialog::FileDialog() {
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
- set_child_rect(vbc);
+
mode=MODE_SAVE_FILE;
set_title(RTR("Save a File"));
@@ -825,7 +828,7 @@ FileDialog::FileDialog() {
makedialog->set_title(RTR("Create Folder"));
VBoxContainer *makevb= memnew( VBoxContainer );
makedialog->add_child(makevb);
- makedialog->set_child_rect(makevb);
+
makedirname = memnew( LineEdit );
makevb->add_margin_child(RTR("Name:"),makedirname);
add_child(makedialog);
@@ -865,11 +868,11 @@ FileDialog::~FileDialog() {
void LineEditFileChooser::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_browse"),&LineEditFileChooser::_browse);
- ObjectTypeDB::bind_method(_MD("_chosen"),&LineEditFileChooser::_chosen);
- ObjectTypeDB::bind_method(_MD("get_button:Button"),&LineEditFileChooser::get_button);
- ObjectTypeDB::bind_method(_MD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
- ObjectTypeDB::bind_method(_MD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
+ ClassDB::bind_method(_MD("_browse"),&LineEditFileChooser::_browse);
+ ClassDB::bind_method(_MD("_chosen"),&LineEditFileChooser::_chosen);
+ ClassDB::bind_method(_MD("get_button:Button"),&LineEditFileChooser::get_button);
+ ClassDB::bind_method(_MD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
+ ClassDB::bind_method(_MD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
}
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 150b24cb3f..653b38e40d 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,7 +42,7 @@
*/
class FileDialog : public ConfirmationDialog {
- OBJ_TYPE( FileDialog, ConfirmationDialog );
+ GDCLASS( FileDialog, ConfirmationDialog );
public:
@@ -167,7 +167,7 @@ public:
class LineEditFileChooser : public HBoxContainer {
- OBJ_TYPE( LineEditFileChooser, HBoxContainer );
+ GDCLASS( LineEditFileChooser, HBoxContainer );
Button *button;
LineEdit *line_edit;
FileDialog *dialog;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0de6add8cb..ba1ab1afa8 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -107,15 +107,15 @@ void GraphEdit::get_connection_list(List<Connection> *r_connections) const {
void GraphEdit::set_scroll_ofs(const Vector2& p_ofs) {
setting_scroll_ofs=true;
- h_scroll->set_val(p_ofs.x);
- v_scroll->set_val(p_ofs.y);
+ h_scroll->set_value(p_ofs.x);
+ v_scroll->set_value(p_ofs.y);
_update_scroll();
setting_scroll_ofs=false;
}
Vector2 GraphEdit::get_scroll_ofs() const{
- return Vector2(h_scroll->get_val(),v_scroll->get_val());
+ return Vector2(h_scroll->get_value(),v_scroll->get_value());
}
void GraphEdit::_scroll_moved(double) {
@@ -144,14 +144,14 @@ void GraphEdit::_update_scroll_offset() {
continue;
Point2 pos=gn->get_offset()*zoom;
- pos-=Point2(h_scroll->get_val(),v_scroll->get_val());
+ pos-=Point2(h_scroll->get_value(),v_scroll->get_value());
gn->set_pos(pos);
if (gn->get_scale()!=Vector2(zoom,zoom)) {
gn->set_scale(Vector2(zoom,zoom));
}
}
- connections_layer->set_pos(-Point2(h_scroll->get_val(),v_scroll->get_val())*zoom);
+ connections_layer->set_pos(-Point2(h_scroll->get_value(),v_scroll->get_value()));
set_block_minimum_size_adjust(false);
awaiting_scroll_offset_update=false;
@@ -254,8 +254,9 @@ void GraphEdit::add_child_notify(Node *p_child) {
gn->set_scale(Vector2(zoom,zoom));
gn->connect("offset_changed",this,"_graph_node_moved",varray(gn));
gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
+ gn->connect("item_rect_changed",connections_layer,"update");
_graph_node_moved(gn);
- gn->set_stop_mouse(false);
+ gn->set_mouse_filter(MOUSE_FILTER_PASS);
}
@@ -294,14 +295,13 @@ void GraphEdit::_notification(int p_what) {
zoom_reset->set_icon(get_icon("reset"));
zoom_plus->set_icon(get_icon("more"));
snap_button->set_icon(get_icon("snap"));
-// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
+ //zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
}
if (p_what==NOTIFICATION_DRAW) {
draw_style_box( get_stylebox("bg"),Rect2(Point2(),get_size()) );
- VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
if (is_using_snap()) {
//draw grid
@@ -650,8 +650,8 @@ void GraphEdit::_draw_cos_line(CanvasItem* p_where,const Vector2& p_from, const
cp_offset=MAX(MIN(cp_len-diff,cp_neg_len),-diff*0.5);
}
- Vector2 c1 = Vector2(cp_offset,0);
- Vector2 c2 = Vector2(-cp_offset,0);
+ Vector2 c1 = Vector2(cp_offset*zoom,0);
+ Vector2 c2 = Vector2(-cp_offset*zoom,0);
int lines=0;
_bake_segment2d(p_where,0,1,p_from,c1,p_to,c2,0,3,9,8,p_color,p_to_color,lines);
@@ -726,9 +726,9 @@ void GraphEdit::_connections_layer_draw() {
continue;
}
- Vector2 frompos=gfrom->get_connection_output_pos(E->get().from_port)+gfrom->get_offset();
+ 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();
+ 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);
@@ -792,11 +792,11 @@ void GraphEdit::set_selected(Node* p_child) {
}
}
-void GraphEdit::_input_event(const InputEvent& p_ev) {
+void GraphEdit::_gui_input(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_MOTION && (p_ev.mouse_motion.button_mask&BUTTON_MASK_MIDDLE || (p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
- h_scroll->set_val( h_scroll->get_val() - p_ev.mouse_motion.relative_x );
- v_scroll->set_val( v_scroll->get_val() - p_ev.mouse_motion.relative_y );
+ h_scroll->set_value( h_scroll->get_value() - p_ev.mouse_motion.relative_x );
+ v_scroll->set_value( v_scroll->get_value() - p_ev.mouse_motion.relative_y );
}
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
@@ -912,18 +912,20 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (b.button_index==BUTTON_LEFT && b.pressed) {
GraphNode *gn = NULL;
+ GraphNode *gn_selected = NULL;
for(int i=get_child_count()-1;i>=0;i--) {
- gn=get_child(i)->cast_to<GraphNode>();
+ gn_selected=get_child(i)->cast_to<GraphNode>();
- if (gn) {
+ if (gn_selected) {
- if (gn->is_resizing())
+ if (gn_selected->is_resizing())
continue;
- Rect2 r = gn->get_rect();
+ Rect2 r = gn_selected->get_rect();
r.size*=zoom;
if (r.has_point(get_local_mouse_pos()))
+ gn = gn_selected;
break;
}
}
@@ -1044,18 +1046,19 @@ void GraphEdit::set_zoom(float p_zoom) {
zoom_minus->set_disabled(zoom==MIN_ZOOM);
zoom_plus->set_disabled(zoom==MAX_ZOOM);
- Vector2 sbofs = (Vector2( h_scroll->get_val(), v_scroll->get_val() ) + get_size()/2)/zoom;
+ Vector2 sbofs = (Vector2( h_scroll->get_value(), v_scroll->get_value() ) + get_size()/2)/zoom;
zoom = p_zoom;
top_layer->update();
_update_scroll();
+ connections_layer->update();
- if (is_visible()) {
+ if (is_visible_in_tree()) {
Vector2 ofs = sbofs*zoom - get_size()/2;
- h_scroll->set_val( ofs.x );
- v_scroll->set_val( ofs.y );
+ h_scroll->set_value( ofs.x );
+ v_scroll->set_value( ofs.y );
}
@@ -1177,13 +1180,13 @@ bool GraphEdit::is_using_snap() const{
int GraphEdit::get_snap() const{
- return snap_amount->get_val();
+ return snap_amount->get_value();
}
void GraphEdit::set_snap(int p_snap) {
ERR_FAIL_COND(p_snap<5);
- snap_amount->set_val(p_snap);
+ snap_amount->set_value(p_snap);
update();
}
void GraphEdit::_snap_toggled() {
@@ -1198,44 +1201,44 @@ void GraphEdit::_snap_value_changed(double) {
void GraphEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
- ObjectTypeDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
- ObjectTypeDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
- ObjectTypeDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
- ObjectTypeDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
- ObjectTypeDB::bind_method(_MD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs);
+ ClassDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
+ ClassDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
+ ClassDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
+ ClassDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
+ ClassDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
+ ClassDB::bind_method(_MD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs);
- ObjectTypeDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
- ObjectTypeDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom);
+ ClassDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
+ ClassDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom);
- ObjectTypeDB::bind_method(_MD("set_snap","pixels"),&GraphEdit::set_snap);
- ObjectTypeDB::bind_method(_MD("get_snap"),&GraphEdit::get_snap);
+ ClassDB::bind_method(_MD("set_snap","pixels"),&GraphEdit::set_snap);
+ ClassDB::bind_method(_MD("get_snap"),&GraphEdit::get_snap);
- ObjectTypeDB::bind_method(_MD("set_use_snap","enable"),&GraphEdit::set_use_snap);
- ObjectTypeDB::bind_method(_MD("is_using_snap"),&GraphEdit::is_using_snap);
+ ClassDB::bind_method(_MD("set_use_snap","enable"),&GraphEdit::set_use_snap);
+ ClassDB::bind_method(_MD("is_using_snap"),&GraphEdit::is_using_snap);
- ObjectTypeDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
- ObjectTypeDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
+ ClassDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
+ ClassDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
- ObjectTypeDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
- ObjectTypeDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
+ ClassDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
+ ClassDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
- ObjectTypeDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input);
- ObjectTypeDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus);
- ObjectTypeDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset);
- ObjectTypeDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus);
- ObjectTypeDB::bind_method(_MD("_snap_toggled"),&GraphEdit::_snap_toggled);
- ObjectTypeDB::bind_method(_MD("_snap_value_changed"),&GraphEdit::_snap_value_changed);
+ ClassDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input);
+ ClassDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
+ ClassDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved);
+ ClassDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus);
+ ClassDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset);
+ ClassDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus);
+ ClassDB::bind_method(_MD("_snap_toggled"),&GraphEdit::_snap_toggled);
+ ClassDB::bind_method(_MD("_snap_value_changed"),&GraphEdit::_snap_value_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_update_scroll_offset"),&GraphEdit::_update_scroll_offset);
- ObjectTypeDB::bind_method(_MD("_connections_layer_draw"),&GraphEdit::_connections_layer_draw);
+ ClassDB::bind_method(_MD("_gui_input"),&GraphEdit::_gui_input);
+ ClassDB::bind_method(_MD("_update_scroll_offset"),&GraphEdit::_update_scroll_offset);
+ ClassDB::bind_method(_MD("_connections_layer_draw"),&GraphEdit::_connections_layer_draw);
- ObjectTypeDB::bind_method(_MD("set_selected","node"),&GraphEdit::set_selected);
+ ClassDB::bind_method(_MD("set_selected","node"),&GraphEdit::set_selected);
ADD_SIGNAL(MethodInfo("connection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
ADD_SIGNAL(MethodInfo("disconnection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
@@ -1258,11 +1261,11 @@ GraphEdit::GraphEdit() {
top_layer=NULL;
top_layer=memnew(GraphEditFilter(this));
add_child(top_layer);
- top_layer->set_stop_mouse(false);
+ top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
top_layer->set_area_as_parent_rect();
top_layer->connect("draw",this,"_top_layer_draw");
- top_layer->set_stop_mouse(false);
- top_layer->connect("input_event",this,"_top_layer_input");
+ top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
+ top_layer->connect("gui_input",this,"_top_layer_input");
connections_layer = memnew( Control );
add_child(connections_layer);
@@ -1327,13 +1330,13 @@ GraphEdit::GraphEdit() {
snap_amount->set_min(5);
snap_amount->set_max(100);
snap_amount->set_step(1);
- snap_amount->set_val(20);
+ snap_amount->set_value(20);
snap_amount->connect("value_changed",this,"_snap_value_changed");
zoom_hb->add_child(snap_amount);
setting_scroll_ofs=false;
just_disconected=false;
-
+ set_clip_contents(true);
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index c5174f6699..3e9944332f 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,13 +34,13 @@
#include "scene/gui/slider.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/spin_box.h"
-#include "texture_frame.h"
+#include "scene/gui/texture_rect.h"
class GraphEdit;
class GraphEditFilter : public Control {
- OBJ_TYPE(GraphEditFilter,Control);
+ GDCLASS(GraphEditFilter,Control);
friend class GraphEdit;
GraphEdit *ge;
@@ -54,7 +54,7 @@ public:
class GraphEdit : public Control {
- OBJ_TYPE(GraphEdit,Control);
+ GDCLASS(GraphEdit,Control);
public:
struct Connection {
@@ -123,7 +123,7 @@ private:
void _update_scroll();
void _scroll_moved(double);
- void _input_event(const InputEvent& p_ev);
+ void _gui_input(const InputEvent& p_ev);
Control *connections_layer;
GraphEditFilter *top_layer;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index da298a795a..aa8c875f40 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -217,8 +217,8 @@ void GraphNode::_notification(int p_what) {
sb = get_stylebox( selected ? "selectedframe" : "frame");
}
- sb=sb->duplicate();
- sb->call("set_modulate",modulate);
+ //sb=sb->duplicate();
+ //sb->call("set_modulate",modulate);
Ref<Texture> port =get_icon("port");
Ref<Texture> close =get_icon("close");
Ref<Texture> resizer =get_icon("resizer");
@@ -621,7 +621,7 @@ Color GraphNode::get_connection_output_color(int p_idx) {
return conn_output_cache[p_idx].color;
}
-void GraphNode::_input_event(const InputEvent& p_ev) {
+void GraphNode::_gui_input(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_BUTTON) {
@@ -675,16 +675,6 @@ void GraphNode::_input_event(const InputEvent& p_ev) {
}
-void GraphNode::set_modulate(const Color &p_color) {
-
- modulate=p_color;
- update();
-}
-
-Color GraphNode::get_modulate() const{
-
- return modulate;
-}
void GraphNode::set_overlay(Overlay p_overlay) {
overlay=p_overlay;
@@ -722,50 +712,51 @@ bool GraphNode::is_resizeable() const{
void GraphNode::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
- ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
- ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
+ ClassDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
+ ClassDB::bind_method(_MD("get_title"),&GraphNode::get_title);
+ ClassDB::bind_method(_MD("_gui_input"),&GraphNode::_gui_input);
- ObjectTypeDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right","custom_left","custom_right"),&GraphNode::set_slot,DEFVAL(Ref<Texture>()),DEFVAL(Ref<Texture>()));
- ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
- ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
- ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
- ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
- ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
- ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
- ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
- ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
+ ClassDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right","custom_left","custom_right"),&GraphNode::set_slot,DEFVAL(Ref<Texture>()),DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
+ ClassDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
+ ClassDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
+ ClassDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
+ ClassDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
+ ClassDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
+ ClassDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
+ ClassDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
- ObjectTypeDB::bind_method(_MD("set_comment","comment"),&GraphNode::set_comment);
- ObjectTypeDB::bind_method(_MD("is_comment"),&GraphNode::is_comment);
+ ClassDB::bind_method(_MD("set_comment","comment"),&GraphNode::set_comment);
+ ClassDB::bind_method(_MD("is_comment"),&GraphNode::is_comment);
- ObjectTypeDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
- ObjectTypeDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
+ ClassDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
+ ClassDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
- ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
- ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
+ ClassDB::bind_method(_MD("set_selected","selected"),&GraphNode::set_selected);
+ ClassDB::bind_method(_MD("is_selected"),&GraphNode::is_selected);
- ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
- ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
- ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
- ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
- ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
- ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
+ ClassDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
+ ClassDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
- ObjectTypeDB::bind_method(_MD("set_modulate","color"),&GraphNode::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate);
+ ClassDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
+ ClassDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
+ ClassDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
+ ClassDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
+ ClassDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
+ ClassDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
- ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
- ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
+ ClassDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
+ ClassDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
- ObjectTypeDB::bind_method(_MD("set_overlay","overlay"),&GraphNode::set_overlay);
- ObjectTypeDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay);
+ ClassDB::bind_method(_MD("set_overlay","overlay"),&GraphNode::set_overlay);
+ ClassDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay);
ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"resizeable"),_SCS("set_resizeable"),_SCS("is_resizeable"));
ADD_SIGNAL(MethodInfo("offset_changed"));
ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
@@ -783,9 +774,9 @@ GraphNode::GraphNode() {
overlay=OVERLAY_DISABLED;
show_close=false;
connpos_dirty=true;
- set_stop_mouse(false);
- modulate=Color(1,1,1,1);
+ set_mouse_filter(MOUSE_FILTER_PASS);
comment=false;
resizeable=false;
resizing=false;
+ selected=false;
}
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index cbfd34f556..9cb46fc49c 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class GraphNode : public Container {
- OBJ_TYPE(GraphNode,Container);
+ GDCLASS(GraphNode,Container);
public:
enum Overlay {
@@ -92,14 +92,12 @@ private:
Overlay overlay;
- Color modulate;
-
bool has_point(const Point2& p_point) const;
protected:
- void _input_event(const InputEvent& p_ev);
+ void _gui_input(const InputEvent& p_ev);
void _notification(int p_what);
static void _bind_methods();
@@ -147,9 +145,6 @@ public:
Color get_connection_output_color(int p_idx);
- void set_modulate(const Color& p_color);
- Color get_modulate() const;
-
void set_overlay(Overlay p_overlay);
Overlay get_overlay() const;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 5e6622b3f8..597169ca83 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,7 +53,7 @@ void GridContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
@@ -70,7 +70,7 @@ void GridContainer::_notification(int p_what) {
else
row_minh[row]=ms.height;
- // print_line("store row "+itos(row)+" mw "+itos(ms.height));
+ //print_line("store row "+itos(row)+" mw "+itos(ms.height));
if (c->get_h_size_flags()&SIZE_EXPAND)
col_expanded.insert(col);
@@ -112,7 +112,7 @@ void GridContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
int col = idx % columns;
@@ -136,7 +136,7 @@ void GridContainer::_notification(int p_what) {
Point2 p(col_ofs,row_ofs);
-// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
+ //print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
fit_child_in_rect(c,Rect2(p,s));
//print_line("col: "+itos(col)+" row: "+itos(row)+" rect: "+Rect2(p,s));
@@ -170,8 +170,8 @@ int GridContainer::get_columns() const{
void GridContainer::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
- ObjectTypeDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
+ ClassDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
+ ClassDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
ADD_PROPERTY( PropertyInfo(Variant::INT,"columns",PROPERTY_HINT_RANGE,"1,1024,1"),_SCS("set_columns"),_SCS("get_columns"));
}
@@ -191,7 +191,7 @@ Size2 GridContainer::get_minimum_size() const {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
int col = idx % columns;
@@ -230,6 +230,6 @@ Size2 GridContainer::get_minimum_size() const {
GridContainer::GridContainer() {
- set_stop_mouse(false);
+ set_mouse_filter(MOUSE_FILTER_PASS);
columns=1;
}
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index 588bb17fa1..cc1d04cdb2 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class GridContainer : public Container {
- OBJ_TYPE(GridContainer,Container);
+ GDCLASS(GridContainer,Container);
int columns;
protected:
diff --git a/scene/gui/input_action.cpp b/scene/gui/input_action.cpp
index c4e7a75298..77026dfdb1 100644
--- a/scene/gui/input_action.cpp
+++ b/scene/gui/input_action.cpp
@@ -24,7 +24,7 @@ bool ShortCut::is_shortcut(const InputEvent& p_event) const {
same=(shortcut.key.scancode==p_event.key.scancode && shortcut.key.mod == p_event.key.mod);
} break;
- case InputEvent::JOYSTICK_BUTTON: {
+ case InputEvent::JOYPAD_BUTTON: {
same=(shortcut.joy_button.button_index==p_event.joy_button.button_index);
@@ -34,7 +34,7 @@ bool ShortCut::is_shortcut(const InputEvent& p_event) const {
same=(shortcut.mouse_button.button_index==p_event.mouse_button.button_index);
} break;
- case InputEvent::JOYSTICK_MOTION: {
+ case InputEvent::JOYPAD_MOTION: {
same=(shortcut.joy_motion.axis==p_event.joy_motion.axis && (shortcut.joy_motion.axis_value < 0) == (p_event.joy_motion.axis_value < 0));
@@ -69,7 +69,7 @@ String ShortCut::get_as_text() const {
return str;
} break;
- case InputEvent::JOYSTICK_BUTTON: {
+ case InputEvent::JOYPAD_BUTTON: {
String str = RTR("Device")+" "+itos(shortcut.device)+", "+RTR("Button")+" "+itos(shortcut.joy_button.button_index);
str+=".";
@@ -90,7 +90,7 @@ String ShortCut::get_as_text() const {
return str;
} break;
- case InputEvent::JOYSTICK_MOTION: {
+ case InputEvent::JOYPAD_MOTION: {
int ax = shortcut.joy_motion.axis;
String str = RTR("Device")+" "+itos(shortcut.device)+", "+RTR("Axis")+" "+itos(ax)+".";
@@ -109,13 +109,13 @@ bool ShortCut::is_valid() const {
void ShortCut::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shortcut","event"),&ShortCut::set_shortcut);
- ObjectTypeDB::bind_method(_MD("get_shortcut"),&ShortCut::get_shortcut);
+ ClassDB::bind_method(_MD("set_shortcut","event"),&ShortCut::set_shortcut);
+ ClassDB::bind_method(_MD("get_shortcut"),&ShortCut::get_shortcut);
- ObjectTypeDB::bind_method(_MD("is_valid"),&ShortCut::is_valid);
+ ClassDB::bind_method(_MD("is_valid"),&ShortCut::is_valid);
- ObjectTypeDB::bind_method(_MD("is_shortcut","event"),&ShortCut::is_shortcut);
- ObjectTypeDB::bind_method(_MD("get_as_text"),&ShortCut::get_as_text);
+ ClassDB::bind_method(_MD("is_shortcut","event"),&ShortCut::is_shortcut);
+ ClassDB::bind_method(_MD("get_as_text"),&ShortCut::get_as_text);
ADD_PROPERTY(PropertyInfo(Variant::INPUT_EVENT,"shortcut"),_SCS("set_shortcut"),_SCS("get_shortcut"));
}
diff --git a/scene/gui/input_action.h b/scene/gui/input_action.h
index 8e0e1ef0bd..a83b3a70cd 100644
--- a/scene/gui/input_action.h
+++ b/scene/gui/input_action.h
@@ -5,7 +5,7 @@
class ShortCut : public Resource {
- OBJ_TYPE(ShortCut,Resource);
+ GDCLASS(ShortCut,Resource);
InputEvent shortcut;
protected:
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 89cd509fbd..a3ed0a91cf 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -446,7 +446,7 @@ Size2 ItemList::Item::get_icon_size() const {
return icon_region.size;
}
-void ItemList::_input_event(const InputEvent& p_event) {
+void ItemList::_gui_input(const InputEvent& p_event) {
if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_MOTION) {
defer_select_single=-1;
@@ -471,7 +471,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
Vector2 pos(mb.x,mb.y);
Ref<StyleBox> bg = get_stylebox("bg");
pos-=bg->get_offset();
- pos.y+=scroll_bar->get_val();
+ pos.y+=scroll_bar->get_value();
int closest = -1;
@@ -561,12 +561,12 @@ void ItemList::_input_event(const InputEvent& p_event) {
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
- scroll_bar->set_val( scroll_bar->get_val()-scroll_bar->get_page()/8 );
+ scroll_bar->set_value( scroll_bar->get_value()-scroll_bar->get_page()/8 );
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
- scroll_bar->set_val( scroll_bar->get_val()+scroll_bar->get_page()/8 );
+ scroll_bar->set_value( scroll_bar->get_value()+scroll_bar->get_page()/8 );
}
@@ -578,7 +578,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff<int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec"))*2) {
for(int i=current-1;i>=0;i--) {
@@ -614,7 +614,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff<int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec"))*2) {
for(int i=current+1;i<items.size();i++) {
@@ -725,7 +725,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000));
+ uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000));
search_time_msec = now;
if (diff>max_interval) {
@@ -788,7 +788,6 @@ void ItemList::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
- VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
Ref<StyleBox> bg = get_stylebox("bg");
int mw = scroll_bar->get_minimum_size().x;
@@ -801,7 +800,10 @@ void ItemList::_notification(int p_what) {
Size2 size = get_size();
float page = size.height-bg->get_minimum_size().height;
- int width = size.width - mw - bg->get_minimum_size().width;
+ int width = size.width-bg->get_minimum_size().width;
+ if (scroll_bar->is_visible()){
+ width-=mw+bg->get_margin(MARGIN_RIGHT);
+ }
scroll_bar->set_page(page);
draw_style_box(bg,Rect2(Point2(),size));
@@ -946,7 +948,7 @@ void ItemList::_notification(int p_what) {
scroll_bar->set_max(max);
//print_line("max: "+rtos(max)+" page "+rtos(page));
if (max<=page) {
- scroll_bar->set_val(0);
+ scroll_bar->set_value(0);
scroll_bar->hide();
} else {
scroll_bar->show();
@@ -959,12 +961,28 @@ void ItemList::_notification(int p_what) {
shape_changed=false;
}
+ //ensure_selected_visible needs to be checked before we draw the list.
+ if (ensure_selected_visible && current>=0 && current <=items.size()) {
+
+ Rect2 r = items[current].rect_cache;
+ int from = scroll_bar->get_value();
+ int to = from + scroll_bar->get_page();
+ if (r.pos.y < from) {
+ scroll_bar->set_value(r.pos.y);
+ } else if (r.pos.y+r.size.y > to) {
+ scroll_bar->set_value(r.pos.y+r.size.y - (to-from));
+ }
+
+
+ }
+
+ ensure_selected_visible=false;
Vector2 base_ofs = bg->get_offset();
- base_ofs.y-=int(scroll_bar->get_val());
+ base_ofs.y-=int(scroll_bar->get_value());
- Rect2 clip(Point2(),size-bg->get_minimum_size()+Vector2(0,scroll_bar->get_val()));
+ Rect2 clip(Point2(),size-bg->get_minimum_size()+Vector2(0,scroll_bar->get_value()));
for(int i=0;i<items.size();i++) {
@@ -1147,25 +1165,6 @@ void ItemList::_notification(int p_what) {
for(int i=0;i<separators.size();i++) {
draw_line(Vector2(bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),Vector2(size.width-bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),guide_color);
}
-
-
- if (ensure_selected_visible && current>=0 && current <=items.size()) {
-
- Rect2 r = items[current].rect_cache;
- int from = scroll_bar->get_val();
- int to = from + scroll_bar->get_page();
-
- if (r.pos.y < from) {
- scroll_bar->set_val(r.pos.y);
- } else if (r.pos.y+r.size.y > to) {
- scroll_bar->set_val(r.pos.y+r.size.y - (to-from));
- }
-
-
- }
-
- ensure_selected_visible=false;
-
}
}
@@ -1178,7 +1177,7 @@ int ItemList::get_item_at_pos(const Point2& p_pos, bool p_exact) const {
Vector2 pos=p_pos;
Ref<StyleBox> bg = get_stylebox("bg");
pos-=bg->get_offset();
- pos.y+=scroll_bar->get_val();
+ pos.y+=scroll_bar->get_value();
int closest = -1;
int closest_dist=0x7FFFFFFF;
@@ -1285,83 +1284,83 @@ Vector<int> ItemList::get_selected_items() {
void ItemList::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
+ ClassDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
+ ClassDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text);
+ ClassDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text);
+ ClassDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
+ ClassDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
+ ClassDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
- ObjectTypeDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
+ ClassDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
+ ClassDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
- ObjectTypeDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
- ObjectTypeDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
+ ClassDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
+ ClassDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled);
+ ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
+ ClassDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&ItemList::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&ItemList::get_item_metadata);
+ ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&ItemList::set_item_metadata);
+ ClassDB::bind_method(_MD("get_item_metadata","idx"),&ItemList::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
+ ClassDB::bind_method(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
+ ClassDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
- ObjectTypeDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
+ ClassDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
+ ClassDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
- ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
+ ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
+ ClassDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
- ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
- ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
+ ClassDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
+ ClassDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
+ ClassDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
+ ClassDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
+ ClassDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
+ ClassDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&ItemList::clear);
- ObjectTypeDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text);
+ ClassDB::bind_method(_MD("clear"),&ItemList::clear);
+ ClassDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text);
- ObjectTypeDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
- ObjectTypeDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
+ ClassDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
+ ClassDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
- ObjectTypeDB::bind_method(_MD("set_same_column_width","enable"),&ItemList::set_same_column_width);
- ObjectTypeDB::bind_method(_MD("is_same_column_width"),&ItemList::is_same_column_width);
+ ClassDB::bind_method(_MD("set_same_column_width","enable"),&ItemList::set_same_column_width);
+ ClassDB::bind_method(_MD("is_same_column_width"),&ItemList::is_same_column_width);
- ObjectTypeDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
- ObjectTypeDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines);
+ ClassDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
+ ClassDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines);
- ObjectTypeDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns);
- ObjectTypeDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns);
+ ClassDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns);
+ ClassDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns);
- ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode);
- ObjectTypeDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode);
+ ClassDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode);
+ ClassDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode);
- ObjectTypeDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode);
- ObjectTypeDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode);
+ ClassDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode);
+ ClassDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode);
- ObjectTypeDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
- ObjectTypeDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
+ ClassDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
+ ClassDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
- ObjectTypeDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale);
- ObjectTypeDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale);
+ ClassDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale);
+ ClassDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale);
- ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
+ ClassDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
+ ClassDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
+ ClassDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&ItemList::get_v_scroll);
+ ClassDB::bind_method(_MD("get_v_scroll"),&ItemList::get_v_scroll);
- ObjectTypeDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&ItemList::_input_event);
+ ClassDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed);
+ ClassDB::bind_method(_MD("_gui_input"),&ItemList::_gui_input);
BIND_CONSTANT( ICON_MODE_TOP );
BIND_CONSTANT( ICON_MODE_LEFT );
@@ -1372,6 +1371,8 @@ void ItemList::_bind_methods(){
ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::VECTOR2,"atpos")));
ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::BOOL,"selected")));
ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
+
+ GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000);
}
ItemList::ItemList() {
@@ -1400,6 +1401,7 @@ ItemList::ItemList() {
allow_rmb_select=false;
icon_scale = 1.0f;
+ set_clip_contents(true);
}
ItemList::~ItemList() {
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index cb5908bc79..f4a864c782 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class ItemList : public Control {
- OBJ_TYPE( ItemList, Control );
+ GDCLASS( ItemList, Control );
public:
enum IconMode {
@@ -102,7 +102,7 @@ private:
real_t icon_scale;
void _scroll_changed(double);
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
protected:
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index ec89b7b690..cd500a62bc 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -68,10 +68,18 @@ int Label::get_line_height() const {
void Label::_notification(int p_what) {
+ if (p_what==NOTIFICATION_TRANSLATION_CHANGED) {
+
+ xl_text=XL_MESSAGE(text);
+ minimum_size_changed();
+ update();
+ }
+
if (p_what==NOTIFICATION_DRAW) {
- if (clip || autowrap)
+ if (clip || autowrap) {
VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+ }
if (word_cache_dirty)
regenerate_word_cache();
@@ -85,7 +93,7 @@ void Label::_notification(int p_what) {
Ref<Font> font = get_font("font");
Color font_color = get_color("font_color");
Color font_color_shadow = get_color("font_color_shadow");
- bool use_outlinde = get_constant("shadow_as_outline");
+ bool use_outline = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y"));
int line_spacing = get_constant("line_spacing");
@@ -118,19 +126,19 @@ void Label::_notification(int p_what) {
//nothing
} break;
case VALIGN_CENTER: {
- vbegin=(size.y - lines_visible * font_h) / 2;
+ vbegin=(size.y - (lines_visible * font_h - line_spacing)) / 2;
vsep=0;
} break;
case VALIGN_BOTTOM: {
- vbegin=size.y - lines_visible * font_h;
+ vbegin=size.y - (lines_visible * font_h - line_spacing);
vsep=0;
} break;
case VALIGN_FILL: {
vbegin=0;
if (lines_visible>1) {
- vsep=(size.y - lines_visible * font_h) / (lines_visible - 1);
+ vsep=(size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1);
} else {
vsep=0;
}
@@ -239,15 +247,15 @@ void Label::_notification(int p_what) {
for (int i=0;i<from->word_len;i++) {
if (visible_chars < 0 || chars_total_shadow<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ CharType c = xl_text[i+pos];
+ CharType n = xl_text[i+pos+1];
if (uppercase) {
c=String::char_uppercase(c);
n=String::char_uppercase(c);
}
float move=font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+shadow_ofs, c, n,font_color_shadow );
- if (use_outlinde) {
+ if (use_outline) {
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,shadow_ofs.y), c, n,font_color_shadow );
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
@@ -262,8 +270,8 @@ void Label::_notification(int p_what) {
for (int i=0;i<from->word_len;i++) {
if (visible_chars < 0 || chars_total<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ CharType c = xl_text[i+pos];
+ CharType n = xl_text[i+pos+1];
if (uppercase) {
c=String::char_uppercase(c);
n=String::char_uppercase(c);
@@ -318,9 +326,9 @@ int Label::get_longest_line_width() const {
int max_line_width=0;
int line_width=0;
- for (int i=0;i<text.size();i++) {
+ for (int i=0;i<xl_text.size();i++) {
- CharType current=text[i];
+ CharType current=xl_text[i];
if (uppercase)
current=String::char_uppercase(current);
@@ -334,7 +342,7 @@ int Label::get_longest_line_width() const {
}
} else {
- int char_width=font->get_char_size(current,text[i+1]).width;
+ int char_width=font->get_char_size(current,xl_text[i+1]).width;
line_width+=char_width;
}
@@ -395,9 +403,9 @@ void Label::regenerate_word_cache() {
WordCache *last=NULL;
- for (int i=0;i<text.size()+1;i++) {
+ for (int i=0;i<xl_text.size()+1;i++) {
- CharType current=i<text.length()?text[i]:' '; //always a space at the end, so the algo works
+ CharType current=i<xl_text.length()?xl_text[i]:' '; //always a space at the end, so the algo works
if (uppercase)
current=String::char_uppercase(current);
@@ -437,7 +445,7 @@ void Label::regenerate_word_cache() {
total_char_cache++;
}
- if (i<text.length() && text[i] == ' ') {
+ if (i<xl_text.length() && xl_text[i] == ' ') {
total_char_cache--; // do not count spaces
if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) {
space_count++;
@@ -454,7 +462,7 @@ void Label::regenerate_word_cache() {
word_pos=i;
}
- char_width=font->get_char_size(current,text[i+1]).width;
+ char_width=font->get_char_size(current,xl_text[i+1]).width;
current_word_size+=char_width;
line_width+=char_width;
total_char_cache++;
@@ -540,12 +548,11 @@ Label::VAlign Label::get_valign() const{
void Label::set_text(const String& p_string) {
- String str = XL_MESSAGE(p_string);
- if (text==str)
+ if (text==p_string)
return;
-
- text=str;
+ text=p_string;
+ xl_text=XL_MESSAGE(p_string);
word_cache_dirty=true;
if (percent_visible<1)
visible_chars=get_total_character_count()*percent_visible;
@@ -641,30 +648,30 @@ int Label::get_total_character_count() const {
void Label::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_align","align"),&Label::set_align);
- ObjectTypeDB::bind_method(_MD("get_align"),&Label::get_align);
- ObjectTypeDB::bind_method(_MD("set_valign","valign"),&Label::set_valign);
- ObjectTypeDB::bind_method(_MD("get_valign"),&Label::get_valign);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&Label::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&Label::get_text);
- ObjectTypeDB::bind_method(_MD("set_autowrap","enable"),&Label::set_autowrap);
- ObjectTypeDB::bind_method(_MD("has_autowrap"),&Label::has_autowrap);
- ObjectTypeDB::bind_method(_MD("set_clip_text","enable"),&Label::set_clip_text);
- ObjectTypeDB::bind_method(_MD("is_clipping_text"),&Label::is_clipping_text);
- ObjectTypeDB::bind_method(_MD("set_uppercase","enable"),&Label::set_uppercase);
- ObjectTypeDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
- ObjectTypeDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
- ObjectTypeDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
- ObjectTypeDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
- ObjectTypeDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
- ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
- ObjectTypeDB::bind_method(_MD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
- ObjectTypeDB::bind_method(_MD("get_percent_visible"),&Label::get_percent_visible);
- ObjectTypeDB::bind_method(_MD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
- ObjectTypeDB::bind_method(_MD("get_lines_skipped"),&Label::get_lines_skipped);
- ObjectTypeDB::bind_method(_MD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
- ObjectTypeDB::bind_method(_MD("get_max_lines_visible"),&Label::get_max_lines_visible);
+ ClassDB::bind_method(_MD("set_align","align"),&Label::set_align);
+ ClassDB::bind_method(_MD("get_align"),&Label::get_align);
+ ClassDB::bind_method(_MD("set_valign","valign"),&Label::set_valign);
+ ClassDB::bind_method(_MD("get_valign"),&Label::get_valign);
+ ClassDB::bind_method(_MD("set_text","text"),&Label::set_text);
+ ClassDB::bind_method(_MD("get_text"),&Label::get_text);
+ ClassDB::bind_method(_MD("set_autowrap","enable"),&Label::set_autowrap);
+ ClassDB::bind_method(_MD("has_autowrap"),&Label::has_autowrap);
+ ClassDB::bind_method(_MD("set_clip_text","enable"),&Label::set_clip_text);
+ ClassDB::bind_method(_MD("is_clipping_text"),&Label::is_clipping_text);
+ ClassDB::bind_method(_MD("set_uppercase","enable"),&Label::set_uppercase);
+ ClassDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
+ ClassDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
+ ClassDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
+ ClassDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
+ ClassDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
+ ClassDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
+ ClassDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
+ ClassDB::bind_method(_MD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
+ ClassDB::bind_method(_MD("get_percent_visible"),&Label::get_percent_visible);
+ ClassDB::bind_method(_MD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
+ ClassDB::bind_method(_MD("get_lines_skipped"),&Label::get_lines_skipped);
+ ClassDB::bind_method(_MD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
+ ClassDB::bind_method(_MD("get_max_lines_visible"),&Label::get_max_lines_visible);
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
@@ -692,14 +699,14 @@ Label::Label(const String &p_text) {
align=ALIGN_LEFT;
valign=VALIGN_TOP;
- text="";
+ xl_text="";
word_cache=NULL;
word_cache_dirty=true;
autowrap=false;
line_count=0;
set_v_size_flags(0);
clip=false;
- set_ignore_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_IGNORE);
total_char_cache=0;
visible_chars=-1;
percent_visible=1;
diff --git a/scene/gui/label.h b/scene/gui/label.h
index b472eca1a2..80e4c970f6 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
*/
class Label : public Control {
- OBJ_TYPE( Label, Control );
+ GDCLASS( Label, Control );
public:
enum Align {
@@ -58,6 +58,7 @@ private:
Align align;
VAlign valign;
String text;
+ String xl_text;
bool autowrap;
bool clip;
Size2 minsize;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 9e58199f35..3a72e0e445 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@ static bool _is_text_char(CharType c) {
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_';
}
-void LineEdit::_input_event(InputEvent p_event) {
+void LineEdit::_gui_input(InputEvent p_event) {
switch(p_event.type) {
@@ -96,8 +96,6 @@ void LineEdit::_input_event(InputEvent p_event) {
}
}
- // if (!editable)
- // non_editable_clicked_signal.call();
update();
} else {
@@ -551,8 +549,8 @@ void LineEdit::_notification(int p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
if (get_tree()->is_editor_hint()) {
- cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
- cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
+ 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));
if (!EditorSettings::get_singleton()->is_connected("settings_changed",this,"_editor_settings_changed")) {
EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
@@ -639,6 +637,7 @@ void LineEdit::_notification(int p_what) {
if(text.empty())
font_color.a *= placeholder_alpha;
+ int caret_height = font->get_height() > y_area ? y_area : font->get_height();
while(true) {
//end of string, break!
@@ -657,14 +656,14 @@ void LineEdit::_notification(int p_what) {
bool selected=selection.enabled && char_ofs>=selection.begin && char_ofs<selection.end;
if (selected)
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, y_area)), selection_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color);
font->draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, selected ? font_color_selected : font_color);
if (char_ofs==cursor_pos && draw_caret) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
+ Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
}
x_ofs+=char_width;
@@ -673,7 +672,7 @@ void LineEdit::_notification(int p_what) {
if (char_ofs==cursor_pos && draw_caret) {//may be at the end
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
+ Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -852,7 +851,7 @@ void LineEdit::_reset_caret_blink_timer() {
void LineEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible()) {
+ if (is_visible_in_tree() && has_focus() && window_has_focus) {
update();
}
}
@@ -872,7 +871,7 @@ void LineEdit::delete_char() {
if (cursor_pos==window_pos) {
- // set_window_pos(cursor_pos-get_window_length());
+ //set_window_pos(cursor_pos-get_window_length());
}
_text_changed();
@@ -917,6 +916,7 @@ void LineEdit::set_text(String p_text) {
update();
cursor_pos=0;
window_pos=0;
+ _text_changed();
}
void LineEdit::clear() {
@@ -1226,8 +1226,8 @@ PopupMenu *LineEdit::get_menu() const {
#ifdef TOOLS_ENABLED
void LineEdit::_editor_settings_changed() {
- cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
- cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
+ 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));
}
#endif
@@ -1256,42 +1256,42 @@ void LineEdit::_text_changed() {
void LineEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
+ ClassDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
+ ClassDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
#endif
- ObjectTypeDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
- ObjectTypeDB::bind_method(_MD("get_align"), &LineEdit::get_align);
-
- ObjectTypeDB::bind_method(_MD("_input_event"),&LineEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("clear"),&LineEdit::clear);
- ObjectTypeDB::bind_method(_MD("select_all"),&LineEdit::select_all);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
- ObjectTypeDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
- ObjectTypeDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
- ObjectTypeDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
- ObjectTypeDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
- ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
- ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
- ObjectTypeDB::bind_method(_MD("set_expand_to_text_length","enabled"),&LineEdit::set_expand_to_text_length);
- ObjectTypeDB::bind_method(_MD("get_expand_to_text_length"),&LineEdit::get_expand_to_text_length);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enabled"),&LineEdit::cursor_set_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
- ObjectTypeDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
- ObjectTypeDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
- ObjectTypeDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
- ObjectTypeDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
- ObjectTypeDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
- ObjectTypeDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
- ObjectTypeDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("menu_option","option"),&LineEdit::menu_option);
- ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&LineEdit::get_menu);
+ ClassDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
+ ClassDB::bind_method(_MD("get_align"), &LineEdit::get_align);
+
+ ClassDB::bind_method(_MD("_gui_input"),&LineEdit::_gui_input);
+ ClassDB::bind_method(_MD("clear"),&LineEdit::clear);
+ ClassDB::bind_method(_MD("select_all"),&LineEdit::select_all);
+ ClassDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
+ ClassDB::bind_method(_MD("get_text"),&LineEdit::get_text);
+ ClassDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
+ ClassDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
+ ClassDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
+ ClassDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
+ ClassDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
+ ClassDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
+ ClassDB::bind_method(_MD("set_expand_to_text_length","enabled"),&LineEdit::set_expand_to_text_length);
+ ClassDB::bind_method(_MD("get_expand_to_text_length"),&LineEdit::get_expand_to_text_length);
+ ClassDB::bind_method(_MD("cursor_set_blink_enabled", "enabled"),&LineEdit::cursor_set_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
+ ClassDB::bind_method(_MD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
+ ClassDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
+ ClassDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
+ ClassDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
+ ClassDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
+ ClassDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
+ ClassDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
+ ClassDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
+ ClassDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
+ ClassDB::bind_method(_MD("menu_option","option"),&LineEdit::menu_option);
+ ClassDB::bind_method(_MD("get_menu:PopupMenu"),&LineEdit::get_menu);
ADD_SIGNAL( MethodInfo("text_changed", PropertyInfo( Variant::STRING, "text" )) );
ADD_SIGNAL( MethodInfo("text_entered", PropertyInfo( Variant::STRING, "text" )) );
@@ -1310,16 +1310,18 @@ void LineEdit::_bind_methods() {
BIND_CONSTANT( MENU_MAX );
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder/text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder/alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "secret" ), _SCS("set_secret"),_SCS("is_secret") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "expand_to_len" ), _SCS("set_expand_to_text_length"),_SCS("get_expand_to_text_length") );
ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_focus_mode"), _SCS("get_focus_mode") );
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));;
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+ ADD_GROUP("Placeholder","placeholder_");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder_text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder_alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
+ ADD_GROUP("Caret","caret_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));;
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
}
LineEdit::LineEdit() {
@@ -1337,7 +1339,7 @@ LineEdit::LineEdit() {
set_focus_mode( FOCUS_ALL );
editable=true;
set_default_cursor_shape(CURSOR_IBEAM);
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
draw_caret=true;
caret_blink_enabled=false;
@@ -1357,7 +1359,7 @@ LineEdit::LineEdit() {
menu->add_item(TTR("Clear"),MENU_CLEAR);
menu->add_separator();
menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
- menu->connect("item_pressed",this,"menu_option");
+ menu->connect("id_pressed",this,"menu_option");
expand_to_text_length=false;
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index 47d5706bbe..64c37861d0 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class LineEdit : public Control {
- OBJ_TYPE( LineEdit, Control );
+ GDCLASS( LineEdit, Control );
public:
enum Align {
@@ -119,7 +119,7 @@ private:
void _editor_settings_changed();
#endif
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 62829fd5a4..5b791064a8 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -87,13 +87,13 @@ void LinkButton::_notification(int p_what) {
else
color=get_color("font_color");
- do_underline=true;
+ do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
color=get_color("font_color_hover");
- do_underline=true;
+ do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
@@ -130,18 +130,19 @@ void LinkButton::_notification(int p_what) {
void LinkButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_text","text"),&LinkButton::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&LinkButton::get_text);
+ ClassDB::bind_method(_MD("set_text","text"),&LinkButton::set_text);
+ ClassDB::bind_method(_MD("get_text"),&LinkButton::get_text);
- ObjectTypeDB::bind_method(_MD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
- ObjectTypeDB::bind_method(_MD("get_underline_mode"),&LinkButton::get_underline_mode);
+ ClassDB::bind_method(_MD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
+ ClassDB::bind_method(_MD("get_underline_mode"),&LinkButton::get_underline_mode);
BIND_CONSTANT( UNDERLINE_MODE_ALWAYS );
BIND_CONSTANT( UNDERLINE_MODE_ON_HOVER );
+ BIND_CONSTANT( UNDERLINE_MODE_NEVER );
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), _SCS("set_text"), _SCS("get_text"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
}
diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h
index 9978f66cc0..42d7c05cff 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,12 +35,13 @@
class LinkButton : public BaseButton {
- OBJ_TYPE( LinkButton, BaseButton );
+ GDCLASS( LinkButton, BaseButton );
public:
enum UnderlineMode {
UNDERLINE_MODE_ALWAYS,
- UNDERLINE_MODE_ON_HOVER
+ UNDERLINE_MODE_ON_HOVER,
+ UNDERLINE_MODE_NEVER
};
private:
String text;
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 5f798f445c..be27c40117 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,7 +45,7 @@ Size2 MarginContainer::get_minimum_size() const {
continue;
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 s = c->get_combined_minimum_size();
diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h
index df9a5c9361..542578dd01 100644
--- a/scene/gui/margin_container.h
+++ b/scene/gui/margin_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/gui/container.h"
class MarginContainer : public Container {
- OBJ_TYPE(MarginContainer,Container);
+ GDCLASS(MarginContainer,Container);
protected:
void _notification(int p_what);
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 725f1ddf17..4a366c55c6 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,16 +34,14 @@
void MenuButton::_unhandled_key_input(InputEvent p_event) {
- if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYSTICK_BUTTON)) {
+ if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYPAD_BUTTON)) {
- if (!get_parent() || !is_visible() || is_disabled())
+ if (!get_parent() || !is_visible_in_tree() || is_disabled())
return;
- if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
- return; //ignore because of modal window
+ bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));
-
- if (popup->activate_item_by_event(p_event))
+ if (popup->activate_item_by_event(p_event,global_only))
accept_event();
}
}
@@ -64,12 +62,12 @@ void MenuButton::pressed() {
}
-void MenuButton::_input_event(InputEvent p_event) {
+void MenuButton::_gui_input(InputEvent p_event) {
/*if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
clicked=p_event.mouse_button.pressed;
}
- if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible()) {
+ if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible_in_tree()) {
Point2 gt = Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
gt = get_global_transform().xform(gt);
@@ -81,7 +79,7 @@ void MenuButton::_input_event(InputEvent p_event) {
}*/
- BaseButton::_input_event(p_event);
+ BaseButton::_gui_input(p_event);
}
PopupMenu *MenuButton::get_popup() {
@@ -100,10 +98,10 @@ void MenuButton::_set_items(const Array& p_items) {
void MenuButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_popup:PopupMenu"),&MenuButton::get_popup);
- ObjectTypeDB::bind_method(_MD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("_set_items"),&MenuButton::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&MenuButton::_get_items);
+ ClassDB::bind_method(_MD("get_popup:PopupMenu"),&MenuButton::get_popup);
+ ClassDB::bind_method(_MD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
+ ClassDB::bind_method(_MD("_set_items"),&MenuButton::_set_items);
+ ClassDB::bind_method(_MD("_get_items"),&MenuButton::_get_items);
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
@@ -119,7 +117,7 @@ MenuButton::MenuButton() {
add_child(popup);
popup->set_as_toplevel(true);
set_process_unhandled_key_input(true);
- set_click_on_press(true);
+ set_action_mode(ACTION_MODE_BUTTON_PRESS);
}
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 650e4aba5c..5b5573456f 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class MenuButton : public Button {
- OBJ_TYPE( MenuButton, Button );
+ GDCLASS( MenuButton, Button );
bool clicked;
PopupMenu *popup;
@@ -46,7 +46,7 @@ class MenuButton : public Button {
Array _get_items() const;
void _set_items(const Array& p_items);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
protected:
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 587a68ae37..1b5b21ae92 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -287,32 +287,32 @@ void OptionButton::get_translatable_strings(List<String> *p_strings) const {
void OptionButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_selected"),&OptionButton::_selected);
-
- ObjectTypeDB::bind_method(_MD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&OptionButton::set_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&OptionButton::get_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&OptionButton::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&OptionButton::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&OptionButton::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&OptionButton::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&OptionButton::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&OptionButton::add_separator);
- ObjectTypeDB::bind_method(_MD("clear"),&OptionButton::clear);
- ObjectTypeDB::bind_method(_MD("select","idx"),&OptionButton::select);
- ObjectTypeDB::bind_method(_MD("get_selected"),&OptionButton::get_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_ID"),&OptionButton::get_selected_ID);
- ObjectTypeDB::bind_method(_MD("get_selected_metadata"),&OptionButton::get_selected_metadata);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&OptionButton::remove_item);
- ObjectTypeDB::bind_method(_MD("_select_int"),&OptionButton::_select_int);
-
- ObjectTypeDB::bind_method(_MD("_set_items"),&OptionButton::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&OptionButton::_get_items);
+ ClassDB::bind_method(_MD("_selected"),&OptionButton::_selected);
+
+ ClassDB::bind_method(_MD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
+ ClassDB::bind_method(_MD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
+ ClassDB::bind_method(_MD("set_item_text","idx","text"),&OptionButton::set_item_text);
+ ClassDB::bind_method(_MD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
+ ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
+ ClassDB::bind_method(_MD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
+ ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
+ ClassDB::bind_method(_MD("get_item_text","idx"),&OptionButton::get_item_text);
+ ClassDB::bind_method(_MD("get_item_icon:Texture","idx"),&OptionButton::get_item_icon);
+ ClassDB::bind_method(_MD("get_item_ID","idx"),&OptionButton::get_item_ID);
+ ClassDB::bind_method(_MD("get_item_metadata","idx"),&OptionButton::get_item_metadata);
+ ClassDB::bind_method(_MD("is_item_disabled","idx"),&OptionButton::is_item_disabled);
+ ClassDB::bind_method(_MD("get_item_count"),&OptionButton::get_item_count);
+ ClassDB::bind_method(_MD("add_separator"),&OptionButton::add_separator);
+ ClassDB::bind_method(_MD("clear"),&OptionButton::clear);
+ ClassDB::bind_method(_MD("select","idx"),&OptionButton::select);
+ ClassDB::bind_method(_MD("get_selected"),&OptionButton::get_selected);
+ ClassDB::bind_method(_MD("get_selected_ID"),&OptionButton::get_selected_ID);
+ ClassDB::bind_method(_MD("get_selected_metadata"),&OptionButton::get_selected_metadata);
+ ClassDB::bind_method(_MD("remove_item","idx"),&OptionButton::remove_item);
+ ClassDB::bind_method(_MD("_select_int"),&OptionButton::_select_int);
+
+ ClassDB::bind_method(_MD("_set_items"),&OptionButton::_set_items);
+ ClassDB::bind_method(_MD("_get_items"),&OptionButton::_get_items);
ADD_PROPERTY( PropertyInfo(Variant::INT,"selected"), _SCS("_select_int"),_SCS("get_selected") );
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
@@ -326,7 +326,7 @@ OptionButton::OptionButton() {
popup->hide();
popup->set_as_toplevel(true);
add_child(popup);
- popup->connect("item_pressed", this,"_selected");
+ popup->connect("id_pressed", this,"_selected");
current=-1;
set_text_align(ALIGN_LEFT);
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index 70ebc66a46..681cb5a088 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class OptionButton : public Button {
- OBJ_TYPE( OptionButton, Button );
+ GDCLASS( OptionButton, Button );
PopupMenu *popup;
int current;
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index 682ea5b92c..c4b7199c3e 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@ void Panel::_notification(int p_what) {
Panel::Panel() {
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
}
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index 9e2e7df7f0..34c73960e7 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
*/
class Panel : public Control{
- OBJ_TYPE(Panel,Control);
+ GDCLASS(Panel,Control);
protected:
void _notification(int p_what);
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index b5e3ef8c7b..48270d12c7 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,7 +43,7 @@ Size2 PanelContainer::get_minimum_size() const {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -98,7 +98,7 @@ void PanelContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h
index a40519c9f2..86f390fdf3 100644
--- a/scene/gui/panel_container.h
+++ b/scene/gui/panel_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class PanelContainer : public Container {
- OBJ_TYPE( PanelContainer, Container );
+ GDCLASS( PanelContainer, Container );
protected:
diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_rect.cpp
index 9ad6398359..4e1856778e 100644
--- a/scene/gui/patch_9_frame.cpp
+++ b/scene/gui/patch_9_rect.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* patch_9_frame.cpp */
+/* patch_9_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,11 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "patch_9_frame.h"
+#include "patch_9_rect.h"
#include "servers/visual_server.h"
-void Patch9Frame::_notification(int p_what) {
+void NinePatchRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -39,8 +39,8 @@ void Patch9Frame::_notification(int p_what) {
Size2 s=get_size();
RID ci = get_canvas_item();
- VS::get_singleton()->canvas_item_add_style_box(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
-// draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ VS::get_singleton()->canvas_item_add_nine_patch(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center);
+ //draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
/*
Vector<Point2> points;
@@ -61,68 +61,59 @@ void Patch9Frame::_notification(int p_what) {
}
}
-Size2 Patch9Frame::get_minimum_size() const {
+Size2 NinePatchRect::get_minimum_size() const {
return Size2(margin[MARGIN_LEFT]+margin[MARGIN_RIGHT],margin[MARGIN_TOP]+margin[MARGIN_BOTTOM]);
}
-void Patch9Frame::_bind_methods() {
+void NinePatchRect::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture"), & Patch9Frame::set_texture );
- ObjectTypeDB::bind_method(_MD("get_texture"), & Patch9Frame::get_texture );
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"), & Patch9Frame::set_modulate );
- ObjectTypeDB::bind_method(_MD("get_modulate"), & Patch9Frame::get_modulate );
- ObjectTypeDB::bind_method(_MD("set_patch_margin","margin","value"), & Patch9Frame::set_patch_margin );
- ObjectTypeDB::bind_method(_MD("get_patch_margin","margin"), & Patch9Frame::get_patch_margin );
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Patch9Frame::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Patch9Frame::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_draw_center","draw_center"), & Patch9Frame::set_draw_center );
- ObjectTypeDB::bind_method(_MD("get_draw_center"), & Patch9Frame::get_draw_center );
+ ClassDB::bind_method(_MD("set_texture","texture"), & NinePatchRect::set_texture );
+ ClassDB::bind_method(_MD("get_texture"), & NinePatchRect::get_texture );
+ ClassDB::bind_method(_MD("set_patch_margin","margin","value"), & NinePatchRect::set_patch_margin );
+ ClassDB::bind_method(_MD("get_patch_margin","margin"), & NinePatchRect::get_patch_margin );
+ ClassDB::bind_method(_MD("set_region_rect","rect"),&NinePatchRect::set_region_rect);
+ ClassDB::bind_method(_MD("get_region_rect"),&NinePatchRect::get_region_rect);
+ ClassDB::bind_method(_MD("set_draw_center","draw_center"), & NinePatchRect::set_draw_center );
+ ClassDB::bind_method(_MD("get_draw_center"), & NinePatchRect::get_draw_center );
ADD_SIGNAL(MethodInfo("texture_changed"));
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "draw_center"), _SCS("set_draw_center"),_SCS("get_draw_center") );
ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/left",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/top",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/right",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/bottom",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_BOTTOM );
+
+ ADD_GROUP("Patch Margin","patch_margin_");
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_left",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_top",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_right",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_bottom",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_BOTTOM );
}
-void Patch9Frame::set_texture(const Ref<Texture>& p_tex) {
+void NinePatchRect::set_texture(const Ref<Texture>& p_tex) {
if (texture==p_tex)
return;
texture=p_tex;
update();
- //if (texture.is_valid())
- // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ /*
+ if (texture.is_valid())
+ texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ */
minimum_size_changed();
emit_signal("texture_changed");
}
-Ref<Texture> Patch9Frame::get_texture() const {
+Ref<Texture> NinePatchRect::get_texture() const {
return texture;
}
-void Patch9Frame::set_modulate(const Color& p_tex) {
-
- modulate=p_tex;
- update();
-}
-
-Color Patch9Frame::get_modulate() const{
-
- return modulate;
-}
-void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
+void NinePatchRect::set_patch_margin(Margin p_margin,int p_size) {
ERR_FAIL_INDEX(p_margin,4);
margin[p_margin]=p_size;
@@ -144,13 +135,13 @@ void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
}
}
-int Patch9Frame::get_patch_margin(Margin p_margin) const{
+int NinePatchRect::get_patch_margin(Margin p_margin) const{
ERR_FAIL_INDEX_V(p_margin,4,0);
return margin[p_margin];
}
-void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
+void NinePatchRect::set_region_rect(const Rect2& p_region_rect) {
if (region_rect==p_region_rect)
return;
@@ -161,35 +152,35 @@ void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
_change_notify("region_rect");
}
-Rect2 Patch9Frame::get_region_rect() const {
+Rect2 NinePatchRect::get_region_rect() const {
return region_rect;
}
-void Patch9Frame::set_draw_center(bool p_draw) {
+void NinePatchRect::set_draw_center(bool p_draw) {
draw_center=p_draw;
update();
}
-bool Patch9Frame::get_draw_center() const{
+bool NinePatchRect::get_draw_center() const{
return draw_center;
}
-Patch9Frame::Patch9Frame() {
+NinePatchRect::NinePatchRect() {
margin[MARGIN_LEFT]=0;
margin[MARGIN_RIGHT]=0;
margin[MARGIN_BOTTOM]=0;
margin[MARGIN_TOP]=0;
- modulate=Color(1,1,1,1);
- set_ignore_mouse(true);
+
+ set_mouse_filter(MOUSE_FILTER_IGNORE);
draw_center=true;
}
-Patch9Frame::~Patch9Frame()
+NinePatchRect::~NinePatchRect()
{
}
diff --git a/scene/gui/patch_9_frame.h b/scene/gui/patch_9_rect.h
index 7763db567a..b87f2f64ec 100644
--- a/scene/gui/patch_9_frame.h
+++ b/scene/gui/patch_9_rect.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* patch_9_frame.h */
+/* patch_9_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,14 +33,13 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class Patch9Frame : public Control {
+class NinePatchRect : public Control {
- OBJ_TYPE(Patch9Frame,Control);
+ GDCLASS(NinePatchRect,Control);
bool draw_center;
int margin[4];
Rect2 region_rect;
- Color modulate;
Ref<Texture> texture;
protected:
@@ -53,9 +52,6 @@ public:
void set_texture(const Ref<Texture>& p_tex);
Ref<Texture> get_texture() const;
- void set_modulate(const Color& p_tex);
- Color get_modulate() const;
-
void set_patch_margin(Margin p_margin,int p_size);
int get_patch_margin(Margin p_margin) const;
@@ -65,8 +61,8 @@ public:
void set_draw_center(bool p_enable);
bool get_draw_center() const;
- Patch9Frame();
- ~Patch9Frame();
+ NinePatchRect();
+ ~NinePatchRect();
};
#endif // PATCH_9_FRAME_H
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 5b83c3f8b8..3f0f76f184 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,7 +31,7 @@
-void Popup::_input_event(InputEvent p_event) {
+void Popup::_gui_input(InputEvent p_event) {
}
@@ -39,7 +39,7 @@ void Popup::_input_event(InputEvent p_event) {
void Popup::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (popped_up && !is_visible()) {
+ if (popped_up && !is_visible_in_tree()) {
popped_up=false;
notification(NOTIFICATION_POPUP_HIDE);
emit_signal("popup_hide");
@@ -103,7 +103,7 @@ void Popup::set_as_minsize() {
Control *c=get_child(i)->cast_to<Control>();
if (!c)
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
@@ -144,7 +144,7 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) {
Control *c=get_child(i)->cast_to<Control>();
if (!c)
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
@@ -257,15 +257,16 @@ bool Popup::is_exclusive() const {
void Popup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
- ObjectTypeDB::bind_method(_MD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
- ObjectTypeDB::bind_method(_MD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
- ObjectTypeDB::bind_method(_MD("popup"),&Popup::popup);
- ObjectTypeDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
- ObjectTypeDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
+ ClassDB::bind_method(_MD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
+ ClassDB::bind_method(_MD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
+ ClassDB::bind_method(_MD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
+ ClassDB::bind_method(_MD("popup"),&Popup::popup);
+ ClassDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
+ ClassDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
ADD_SIGNAL( MethodInfo("about_to_show") );
ADD_SIGNAL( MethodInfo("popup_hide") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup/exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
+ ADD_GROUP("Popup","popup_");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup_exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
BIND_CONSTANT(NOTIFICATION_POST_POPUP);
BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
@@ -282,7 +283,7 @@ Popup::Popup() {
String Popup::get_configuration_warning() const {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
return TTR("Popups will hide by default unless you call popup() or any of the popup*() functions. Making them visible for editing is fine though, but they will hide upon running.");
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index dccaf2ae69..17ae4a938a 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class Popup : public Control {
- OBJ_TYPE( Popup, Control );
+ GDCLASS( Popup, Control );
bool exclusive;
bool popped_up;
@@ -45,7 +45,7 @@ protected:
virtual void _post_popup() {}
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
void _fix_size();
static void _bind_methods();
@@ -74,7 +74,7 @@ public:
class PopupPanel : public Popup {
- OBJ_TYPE(PopupPanel,Popup);
+ GDCLASS(PopupPanel,Popup);
protected:
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index b3f18bf8fa..65e7c3ab39 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,12 +89,14 @@ Size2 PopupMenu::get_minimum_size() const {
size.height=font_h;
}
+ size.width+=items[i].h_ofs;
+
if (items[i].checkable) {
size.width+=check_w+hseparation;
}
- String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].text;
+ String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
size.width+=font->get_string_size(text).width;
if (i>0)
size.height+=vseparation;
@@ -106,6 +108,7 @@ Size2 PopupMenu::get_minimum_size() const {
accel_max_w = MAX( accel_w, accel_max_w );
}
+
minsize.height+=size.height;
max_w = MAX( max_w, size.width );
@@ -133,7 +136,7 @@ int PopupMenu::_get_mouse_over(const Point2& p_over) const {
Ref<Font> font = get_font("font");
int vseparation = get_constant("vseparation");
-// int hseparation = get_constant("hseparation");
+ //int hseparation = get_constant("hseparation");
float font_h=font->get_height();
@@ -171,7 +174,7 @@ void PopupMenu::_activate_submenu(int over) {
Popup *pm = n->cast_to<Popup>();
ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu);
ERR_FAIL_COND(!pm);
- if (pm->is_visible())
+ if (pm->is_visible_in_tree())
return; //already visible!
@@ -212,7 +215,7 @@ void PopupMenu::_submenu_timeout() {
}
-void PopupMenu::_input_event(const InputEvent &p_event) {
+void PopupMenu::_gui_input(const InputEvent &p_event) {
switch( p_event.type) {
@@ -305,7 +308,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
ie.type=InputEvent::MOUSE_MOTION;
ie.mouse_motion.x=b.x;
ie.mouse_motion.y=b.y+s;
- _input_event(ie);
+ _gui_input(ie);
}
} break;
case BUTTON_WHEEL_UP: {
@@ -325,7 +328,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
ie.type=InputEvent::MOUSE_MOTION;
ie.mouse_motion.x=b.x;
ie.mouse_motion.y=b.y-s;
- _input_event(ie);
+ _gui_input(ie);
}
@@ -418,7 +421,16 @@ void PopupMenu::_notification(int p_what) {
switch(p_what) {
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+
+ for(int i=0;i<items.size();i++) {
+ items[i].xl_text=XL_MESSAGE(items[i].text);
+ }
+
+ minimum_size_changed();
+ update();
+ } break;
case NOTIFICATION_DRAW: {
RID ci = get_canvas_item();
@@ -450,6 +462,7 @@ void PopupMenu::_notification(int p_what) {
float h;
Size2 icon_size;
+ item_ofs.x+=items[i].h_ofs;
if (!items[i].icon.is_null()) {
icon_size = items[i].icon->get_size();
@@ -461,13 +474,13 @@ void PopupMenu::_notification(int p_what) {
if (i==mouse_over) {
- hover->draw(ci, Rect2( ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
+ hover->draw(ci, Rect2( item_ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
}
if (items[i].separator) {
int sep_h=separator->get_center_size().height+separator->get_minimum_size().height;
- separator->draw(ci, Rect2( ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
+ separator->draw(ci, Rect2( item_ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
}
@@ -492,7 +505,7 @@ void PopupMenu::_notification(int p_what) {
}
item_ofs.y+=font->get_ascent();
- String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].text;
+ String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
if (!items[i].separator) {
font->draw(ci,item_ofs+Point2(0,Math::floor((h-font_h)/2.0)),text,items[i].disabled?font_color_disabled:(i==mouse_over?font_color_hover:font_color));
@@ -533,6 +546,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
Item item;
item.icon=p_icon;
item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
items.push_back(item);
@@ -541,7 +555,8 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
items.push_back(item);
@@ -551,7 +566,8 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu,int p_ID){
Item item;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.ID=p_ID;
item.submenu=p_submenu;
items.push_back(item);
@@ -562,7 +578,8 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
Item item;
item.icon=p_icon;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
item.checkable=true;
@@ -572,7 +589,8 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
item.checkable=true;
@@ -581,7 +599,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel)
}
-void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID) {
+void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon, const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global) {
ERR_FAIL_COND(p_shortcut.is_null());
@@ -591,12 +609,13 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>
item.ID=p_ID;
item.icon=p_icon;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -605,11 +624,12 @@ void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
Item item;
item.ID=p_ID;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon, const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -620,11 +640,12 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<Sho
item.shortcut=p_shortcut;
item.checkable=true;
item.icon=p_icon;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -633,6 +654,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
Item item;
item.ID=p_ID;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
item.checkable=true;
items.push_back(item);
update();
@@ -641,7 +663,8 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
void PopupMenu::set_item_text(int p_idx,const String& p_text) {
ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].text=XL_MESSAGE(p_text);
+ items[p_idx].text=p_text;
+ items[p_idx].xl_text=XL_MESSAGE(p_text);
update();
@@ -701,6 +724,13 @@ void PopupMenu::set_item_submenu(int p_idx, const String& p_submenu) {
update();
}
+void PopupMenu::toggle_item_checked(int p_idx) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].checked = !items[p_idx].checked;
+ update();
+}
+
String PopupMenu::get_item_text(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),"");
@@ -804,12 +834,14 @@ void PopupMenu::set_item_tooltip(int p_idx,const String& p_tooltip) {
update();
}
-void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
+void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut, bool p_global) {
ERR_FAIL_INDEX(p_idx,items.size());
if (items[p_idx].shortcut.is_valid()) {
_unref_shortcut(items[p_idx].shortcut);
}
items[p_idx].shortcut=p_shortcut;
+ items[p_idx].shortcut_is_global=p_global;
+
if (items[p_idx].shortcut.is_valid()) {
_ref_shortcut(items[p_idx].shortcut);
@@ -819,6 +851,15 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
update();
}
+void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].h_ofs=p_offset;
+ update();
+
+}
+
+
bool PopupMenu::is_item_checkable(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),false);
return items[p_idx].checkable;
@@ -829,7 +870,7 @@ int PopupMenu::get_item_count() const {
return items.size();
}
-bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
+bool PopupMenu::activate_item_by_event(const InputEvent& p_event, bool p_for_global_only) {
uint32_t code=0;
if (p_event.type==InputEvent::KEY) {
@@ -853,7 +894,7 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
continue;
- if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event)) {
+ if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event) && (items[i].shortcut_is_global || !p_for_global_only)) {
activate_item(i);
return true;
}
@@ -872,7 +913,7 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
if(!pm)
continue;
- if(pm->activate_item_by_event(p_event)) {
+ if(pm->activate_item_by_event(p_event,p_for_global_only)) {
return true;
}
}
@@ -886,17 +927,31 @@ void PopupMenu::activate_item(int p_item) {
ERR_FAIL_INDEX(p_item,items.size());
ERR_FAIL_COND(items[p_item].separator);
int id = items[p_item].ID>=0?items[p_item].ID:p_item;
- emit_signal("item_pressed",id);
+ emit_signal("id_pressed",id);
+ emit_signal("index_pressed",p_item);
//hide all parent PopupMenue's
Node *next = get_parent();
PopupMenu *pop = next->cast_to<PopupMenu>();
while (pop) {
- pop->hide();
- next = next->get_parent();
- pop = next->cast_to<PopupMenu>();
+ // We close all parents that are chained together,
+ // with hide_on_item_selection enabled
+ if(hide_on_item_selection && pop->is_hide_on_item_selection()) {
+ pop->hide();
+ next = next->get_parent();
+ pop = next->cast_to<PopupMenu>();
+ }
+ else {
+ // Break out of loop when the next parent has
+ // hide_on_item_selection disabled
+ break;
+ }
+ }
+ // Hides popup by default; unless otherwise specified
+ // by using set_hide_on_item_selection
+ if (hide_on_item_selection) {
+ hide();
}
- hide();
}
@@ -1012,6 +1067,16 @@ void PopupMenu::_set_items(const Array& p_items){
}
+// Hide on item selection determines whether or not the popup will close after item selection
+void PopupMenu::set_hide_on_item_selection(bool p_enabled) {
+
+ hide_on_item_selection=p_enabled;
+}
+
+bool PopupMenu::is_hide_on_item_selection() {
+
+ return hide_on_item_selection;
+}
String PopupMenu::get_tooltip(const Point2& p_pos) const {
@@ -1032,8 +1097,8 @@ void PopupMenu::get_translatable_strings(List<String> *p_strings) const {
for(int i=0;i<items.size();i++) {
- if (items[i].text!="")
- p_strings->push_back(items[i].text);
+ if (items[i].xl_text!="")
+ p_strings->push_back(items[i].xl_text);
}
}
@@ -1049,55 +1114,67 @@ void PopupMenu::clear_autohide_areas(){
void PopupMenu::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&PopupMenu::_input_event);
- ObjectTypeDB::bind_method(_MD("add_icon_item","texture","label","id","accel"),&PopupMenu::add_icon_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_item","label","id","accel"),&PopupMenu::add_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_icon_check_item","texture","label","id","accel"),&PopupMenu::add_icon_check_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
-
- ObjectTypeDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_check_shortcut,DEFVAL(-1));
-
-
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
- ObjectTypeDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
- ObjectTypeDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
- ObjectTypeDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
- ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
- ObjectTypeDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
- ObjectTypeDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
- ObjectTypeDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
- ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&PopupMenu::clear);
-
- ObjectTypeDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&PopupMenu::_get_items);
-
- ObjectTypeDB::bind_method(_MD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
+ ClassDB::bind_method(_MD("_gui_input"),&PopupMenu::_gui_input);
+ ClassDB::bind_method(_MD("add_icon_item","texture","label","id","accel"),&PopupMenu::add_icon_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_item","label","id","accel"),&PopupMenu::add_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_icon_check_item","texture","label","id","accel"),&PopupMenu::add_icon_check_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
+
+ ClassDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_check_shortcut,DEFVAL(-1),DEFVAL(false));
+
+ ClassDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
+ ClassDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
+ ClassDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
+ ClassDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
+ ClassDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
+ ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
+ ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
+ ClassDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
+ ClassDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
+ ClassDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
+ ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
+ ClassDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut","global"),&PopupMenu::set_item_shortcut,DEFVAL(false));
+
+ ClassDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
+
+ ClassDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
+ ClassDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
+ ClassDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
+ ClassDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
+ ClassDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
+ ClassDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
+ ClassDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
+ ClassDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
+ ClassDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
+ ClassDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
+ ClassDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
+ ClassDB::bind_method(_MD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
+ ClassDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+
+ ClassDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
+
+ ClassDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
+
+ ClassDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
+ ClassDB::bind_method(_MD("clear"),&PopupMenu::clear);
+
+ ClassDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
+ ClassDB::bind_method(_MD("_get_items"),&PopupMenu::_get_items);
+
+ ClassDB::bind_method(_MD("set_hide_on_item_selection","enable"),&PopupMenu::set_hide_on_item_selection);
+ ClassDB::bind_method(_MD("is_hide_on_item_selection"),&PopupMenu::is_hide_on_item_selection);
+
+ ClassDB::bind_method(_MD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL, "hide_on_item_selection" ), _SCS("set_hide_on_item_selection"), _SCS("is_hide_on_item_selection") );
- ADD_SIGNAL( MethodInfo("item_pressed", PropertyInfo( Variant::INT,"ID") ) );
+ ADD_SIGNAL( MethodInfo("id_pressed", PropertyInfo( Variant::INT,"ID") ) );
+ ADD_SIGNAL( MethodInfo("index_pressed", PropertyInfo( Variant::INT,"index") ) );
}
@@ -1114,6 +1191,7 @@ PopupMenu::PopupMenu() {
set_focus_mode(FOCUS_ALL);
set_as_toplevel(true);
+ set_hide_on_item_selection(true);
submenu_timer = memnew( Timer );
submenu_timer->set_wait_time(0.3);
@@ -1125,5 +1203,3 @@ PopupMenu::PopupMenu() {
PopupMenu::~PopupMenu() {
}
-
-
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index f35e91d4e4..b5fca9a451 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,11 +39,12 @@
class PopupMenu : public Popup {
- OBJ_TYPE(PopupMenu, Popup );
+ GDCLASS(PopupMenu, Popup );
struct Item {
Ref<Texture> icon;
String text;
+ String xl_text;
bool checked;
bool checkable;
bool separator;
@@ -54,9 +55,11 @@ class PopupMenu : public Popup {
String tooltip;
uint32_t accel;
int _ofs_cache;
+ int h_ofs;
Ref<ShortCut> shortcut;
+ bool shortcut_is_global;
- Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; }
+ Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; h_ofs=0; shortcut_is_global=false; }
};
@@ -69,11 +72,12 @@ class PopupMenu : public Popup {
String _get_accel_text(int p_item) const;
int _get_mouse_over(const Point2& p_over) const;
virtual Size2 get_minimum_size() const;
- void _input_event(const InputEvent &p_event);
+ void _gui_input(const InputEvent &p_event);
void _activate_submenu(int over);
void _submenu_timeout();
bool invalidated_click;
+ bool hide_on_item_selection;
Vector2 moved;
Array _get_items() const;
@@ -98,10 +102,10 @@ public:
void add_check_item(const String& p_label,int p_ID=-1,uint32_t p_accel=0);
void add_submenu_item(const String& p_label,const String& p_submenu, int p_ID=-1);
- void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
+ void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
void set_item_text(int p_idx,const String& p_text);
void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
@@ -114,7 +118,10 @@ public:
void set_item_as_separator(int p_idx, bool p_separator);
void set_item_as_checkable(int p_idx, bool p_checkable);
void set_item_tooltip(int p_idx,const String& p_tooltip);
- void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut,bool p_global=false);
+ void set_item_h_offset(int p_idx, int p_offset);
+
+ void toggle_item_checked(int p_idx);
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
@@ -132,7 +139,7 @@ public:
int get_item_count() const;
- bool activate_item_by_event(const InputEvent& p_event);
+ bool activate_item_by_event(const InputEvent& p_event,bool p_for_global_only=false);
void activate_item(int p_item);
void remove_item(int p_idx);
@@ -151,6 +158,8 @@ public:
void clear_autohide_areas();
void set_invalidate_click_until_motion();
+ void set_hide_on_item_selection(bool p_enabled);
+ bool is_hide_on_item_selection();
PopupMenu();
~PopupMenu();
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 8af94c3638..0f99d4f19e 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,7 +53,7 @@ void ProgressBar::_notification(int p_what) {
Color font_color=get_color("font_color");
draw_style_box(bg,Rect2(Point2(),get_size()));
- float r = get_unit_value();
+ float r = get_as_ratio();
int mp = fg->get_minimum_size().width;
int p = r*get_size().width-mp;
if (p>0) {
@@ -62,7 +62,7 @@ void ProgressBar::_notification(int p_what) {
}
if (percent_visible) {
- String txt=itos(int(get_unit_value()*100))+"%";
+ String txt=itos(int(get_as_ratio()*100))+"%";
font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
}
}
@@ -82,9 +82,10 @@ bool ProgressBar::is_percent_visible() const{
void ProgressBar::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
- ObjectTypeDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent/visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
+ ClassDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
+ ClassDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
+ ADD_GROUP("Percent","percent_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent_visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
}
ProgressBar::ProgressBar() {
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index f50df346ac..01306a2ac4 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ProgressBar : public Range {
- OBJ_TYPE( ProgressBar, Range );
+ GDCLASS( ProgressBar, Range );
bool percent_visible;
protected:
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index e056c55f71..d5c1034c9c 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -66,7 +66,7 @@ void Range::Shared::emit_changed(const char *p_what) {
}
-void Range::set_val(double p_val) {
+void Range::set_value(double p_val) {
if(_rounded_values){
p_val = Math::round(p_val);
@@ -88,14 +88,14 @@ void Range::set_val(double p_val) {
void Range::set_min(double p_min) {
shared->min=p_min;
- set_val(shared->val);
+ set_value(shared->val);
shared->emit_changed("range/min");
}
void Range::set_max(double p_max) {
shared->max=p_max;
- set_val(shared->val);
+ set_value(shared->val);
shared->emit_changed("range/max");
@@ -109,12 +109,12 @@ void Range::set_step(double p_step) {
void Range::set_page(double p_page) {
shared->page=p_page;
- set_val(shared->val);
+ set_value(shared->val);
shared->emit_changed("range/page");
}
-double Range::get_val() const {
+double Range::get_value() const {
return shared->val;
}
@@ -135,31 +135,40 @@ double Range::get_page() const {
return shared->page;
}
-void Range::set_unit_value(double p_value) {
- if (shared->exp_unit_value && get_min()>0) {
+void Range::set_as_ratio(double p_value) {
+
+ double v;
+
+ if (shared->exp_ratio && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
-
- set_val( v );
+ v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
- set_val( (get_max() - get_min()) * p_value + get_min() );
+
+ double percent = (get_max() - get_min()) * p_value;
+ if (get_step() > 0) {
+ double steps = round(percent / get_step());
+ v = steps * get_step() + get_min();
+ } else {
+ v = percent + get_min();
+ }
}
+ set_value( v );
}
-double Range::get_unit_value() const {
+double Range::get_as_ratio() const {
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_ratio && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::log(get_val())/Math::log(2);
+ double v = Math::log(get_value())/Math::log(2);
return (v - exp_min) / (exp_max - exp_min);
} else {
- return (get_val() - get_min()) / (get_max() - get_min());
+ return (get_value() - get_min()) / (get_max() - get_min());
}
}
@@ -213,59 +222,57 @@ void Range::_unref_shared() {
void Range::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_val"),&Range::get_val);
- ObjectTypeDB::bind_method(_MD("get_value"),&Range::get_val);
- ObjectTypeDB::bind_method(_MD("get_min"),&Range::get_min);
- ObjectTypeDB::bind_method(_MD("get_max"),&Range::get_max);
- ObjectTypeDB::bind_method(_MD("get_step"),&Range::get_step);
- ObjectTypeDB::bind_method(_MD("get_page"),&Range::get_page);
- ObjectTypeDB::bind_method(_MD("get_unit_value"),&Range::get_unit_value);
- ObjectTypeDB::bind_method(_MD("set_val","value"),&Range::set_val);
- ObjectTypeDB::bind_method(_MD("set_value","value"),&Range::set_val);
- ObjectTypeDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
- ObjectTypeDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
- ObjectTypeDB::bind_method(_MD("set_step","step"),&Range::set_step);
- ObjectTypeDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
- ObjectTypeDB::bind_method(_MD("set_unit_value","value"),&Range::set_unit_value);
- ObjectTypeDB::bind_method(_MD("set_rounded_values","enabled"),&Range::set_rounded_values);
- ObjectTypeDB::bind_method(_MD("is_rounded_values"),&Range::is_rounded_values);
- ObjectTypeDB::bind_method(_MD("set_exp_unit_value","enabled"),&Range::set_exp_unit_value);
- ObjectTypeDB::bind_method(_MD("is_unit_value_exp"),&Range::is_unit_value_exp);
-
- ObjectTypeDB::bind_method(_MD("share","with"),&Range::_share);
- ObjectTypeDB::bind_method(_MD("unshare"),&Range::unshare);
+ ClassDB::bind_method(_MD("get_value"),&Range::get_value);
+ ClassDB::bind_method(_MD("get_min"),&Range::get_min);
+ ClassDB::bind_method(_MD("get_max"),&Range::get_max);
+ ClassDB::bind_method(_MD("get_step"),&Range::get_step);
+ ClassDB::bind_method(_MD("get_page"),&Range::get_page);
+ ClassDB::bind_method(_MD("get_as_ratio"),&Range::get_as_ratio);
+ ClassDB::bind_method(_MD("set_value","value"),&Range::set_value);
+ ClassDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
+ ClassDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
+ ClassDB::bind_method(_MD("set_step","step"),&Range::set_step);
+ ClassDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
+ ClassDB::bind_method(_MD("set_as_ratio","value"),&Range::set_as_ratio);
+ ClassDB::bind_method(_MD("set_use_rounded_values","enabled"),&Range::set_use_rounded_values);
+ ClassDB::bind_method(_MD("is_using_rounded_values"),&Range::is_using_rounded_values);
+ ClassDB::bind_method(_MD("set_exp_ratio","enabled"),&Range::set_exp_ratio);
+ ClassDB::bind_method(_MD("is_ratio_exp"),&Range::is_ratio_exp);
+
+ ClassDB::bind_method(_MD("share","with"),&Range::_share);
+ ClassDB::bind_method(_MD("unshare"),&Range::unshare);
ADD_SIGNAL( MethodInfo("value_changed", PropertyInfo(Variant::REAL,"value")));
ADD_SIGNAL( MethodInfo("changed"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/min" ), _SCS("set_min"), _SCS("get_min") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/max" ), _SCS("set_max"), _SCS("get_max") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/step" ), _SCS("set_step"), _SCS("get_step") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/page" ), _SCS("set_page"), _SCS("get_page") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/value" ), _SCS("set_val"), _SCS("get_val") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "range/exp_edit" ), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "range/rounded" ), _SCS("set_rounded_values"), _SCS("is_rounded_values") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "min_value" ), _SCS("set_min"), _SCS("get_min") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "max_value" ), _SCS("set_max"), _SCS("get_max") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "step" ), _SCS("set_step"), _SCS("get_step") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "page" ), _SCS("set_page"), _SCS("get_page") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "value" ), _SCS("set_value"), _SCS("get_value") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_ratio"), _SCS("is_ratio_exp") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_use_rounded_values"), _SCS("is_using_rounded_values") );
}
-void Range::set_rounded_values(bool p_enable) {
+void Range::set_use_rounded_values(bool p_enable) {
_rounded_values = p_enable;
}
-bool Range::is_rounded_values() const {
+bool Range::is_using_rounded_values() const {
return _rounded_values;
}
-void Range::set_exp_unit_value(bool p_enable) {
+void Range::set_exp_ratio(bool p_enable) {
- shared->exp_unit_value=p_enable;
+ shared->exp_ratio=p_enable;
}
-bool Range::is_unit_value_exp() const {
+bool Range::is_ratio_exp() const {
- return shared->exp_unit_value;
+ return shared->exp_ratio;
}
@@ -278,7 +285,7 @@ Range::Range()
shared->step=1;
shared->page=0;
shared->owners.insert(this);
- shared->exp_unit_value=false;
+ shared->exp_ratio=false;
_rounded_values = false;
}
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 85c3687b7d..5f274a6901 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,13 +35,13 @@
*/
class Range : public Control {
- OBJ_TYPE( Range, Control );
+ GDCLASS( Range, Control );
struct Shared {
double val,min,max;
double step,page;
- bool exp_unit_value;
+ bool exp_ratio;
Set<Range*> owners;
void emit_value_changed();
void emit_changed(const char *p_what="");
@@ -66,25 +66,25 @@ protected:
bool _rounded_values;
public:
- void set_val(double p_val);
+ void set_value(double p_val);
void set_min(double p_min);
void set_max(double p_max);
void set_step(double p_step);
void set_page(double p_page);
- void set_unit_value(double p_value);
+ void set_as_ratio(double p_value);
- double get_val() const;
+ double get_value() const;
double get_min() const;
double get_max() const;
double get_step() const;
double get_page() const;
- double get_unit_value() const;
+ double get_as_ratio() const;
- void set_rounded_values(bool p_enable);
- bool is_rounded_values() const;
+ void set_use_rounded_values(bool p_enable);
+ bool is_using_rounded_values() const;
- void set_exp_unit_value(bool p_enable);
- bool is_unit_value_exp() const;
+ void set_exp_ratio(bool p_enable);
+ bool is_ratio_exp() const;
void share(Range *p_range);
void unshare();
diff --git a/scene/gui/reference_frame.cpp b/scene/gui/reference_rect.cpp
index d037664a62..ff4cdf04fd 100644
--- a/scene/gui/reference_frame.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* reference_frame.cpp */
+/* reference_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,9 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "reference_frame.h"
+#include "reference_rect.h"
-void ReferenceFrame::_notification(int p_what) {
+void ReferenceRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -39,6 +39,6 @@ void ReferenceFrame::_notification(int p_what) {
}
}
-ReferenceFrame::ReferenceFrame()
+ReferenceRect::ReferenceRect()
{
}
diff --git a/scene/gui/reference_frame.h b/scene/gui/reference_rect.h
index 5d3694e6e8..be493f346c 100644
--- a/scene/gui/reference_frame.h
+++ b/scene/gui/reference_rect.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* reference_frame.h */
+/* reference_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,20 +26,20 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef REFERENCE_FRAME_H
-#define REFERENCE_FRAME_H
+#ifndef REFERENCE_RECT_H
+#define REFERENCE_RECT_H
#include "scene/gui/control.h"
-class ReferenceFrame : public Control {
+class ReferenceRect : public Control {
- OBJ_TYPE( ReferenceFrame, Control);
+ GDCLASS( ReferenceRect, Control);
protected:
void _notification(int p_what);
public:
- ReferenceFrame();
+ ReferenceRect();
};
-#endif // REFERENCE_FRAME_H
+#endif // REFERENCE_RECT_H
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 73a3cda5f3..434fb36e24 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -610,7 +610,7 @@ void RichTextLabel::_scroll_changed(double) {
if (updating_scroll)
return;
- if (scroll_follow && vscroll->get_val()>=(vscroll->get_max()-vscroll->get_page()))
+ if (scroll_follow && vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page()))
scroll_following=true;
else
scroll_following=false;
@@ -687,15 +687,13 @@ void RichTextLabel::_notification(int p_what) {
RID ci=get_canvas_item();
Size2 size = get_size();
- VisualServer::get_singleton()->canvas_item_set_clip(ci,true);
-
if (has_focus()) {
VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true);
draw_style_box(get_stylebox("focus"),Rect2(Point2(),size));
VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,false);
}
- int ofs = vscroll->get_val();
+ int ofs = vscroll->get_value();
//todo, change to binary search
@@ -734,7 +732,7 @@ void RichTextLabel::_find_click(ItemFrame* p_frame,const Point2i& p_click,Item *
Size2 size = get_size();
- int ofs = vscroll->get_val();
+ int ofs = vscroll->get_value();
//todo, change to binary search
int from_line = 0;
@@ -789,7 +787,7 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2& p_pos) const
}
-void RichTextLabel::_input_event(InputEvent p_event) {
+void RichTextLabel::_gui_input(InputEvent p_event) {
switch(p_event.type) {
@@ -838,12 +836,12 @@ void RichTextLabel::_input_event(InputEvent p_event) {
if (b.button_index==BUTTON_WHEEL_UP) {
if (scroll_active)
- vscroll->set_val( vscroll->get_val()-vscroll->get_page()/8 );
+ vscroll->set_value( vscroll->get_value()-vscroll->get_page()/8 );
}
if (b.button_index==BUTTON_WHEEL_DOWN) {
if (scroll_active)
- vscroll->set_val( vscroll->get_val()+vscroll->get_page()/8 );
+ vscroll->set_value( vscroll->get_value()+vscroll->get_page()/8 );
}
} break;
case InputEvent::KEY: {
@@ -854,33 +852,33 @@ void RichTextLabel::_input_event(InputEvent p_event) {
switch(k.scancode) {
case KEY_PAGEUP: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() - vscroll->get_page() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() - vscroll->get_page() );
} break;
case KEY_PAGEDOWN: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() + vscroll->get_page() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() + vscroll->get_page() );
} break;
case KEY_UP: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() - get_font("normal_font")->get_height() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() - get_font("normal_font")->get_height() );
} break;
case KEY_DOWN: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() + get_font("normal_font")->get_height() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() + get_font("normal_font")->get_height() );
} break;
case KEY_HOME: {
- if (vscroll->is_visible())
- vscroll->set_val( 0 );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( 0 );
} break;
case KEY_END: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_max() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_max() );
} break;
case KEY_INSERT:
case KEY_C: {
@@ -1113,7 +1111,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame* p_frame) {
vscroll->set_max(total_height);
vscroll->set_page(size.height);
if (scroll_follow && scroll_following)
- vscroll->set_val(total_height-size.height);
+ vscroll->set_value(total_height-size.height);
updating_scroll=false;
@@ -1179,7 +1177,8 @@ void RichTextLabel::add_text(const String& p_text) {
item->line=current_frame->lines.size();
_add_item(item,false);
current_frame->lines.resize(current_frame->lines.size()+1);
- current_frame->lines[current_frame->lines.size()-1].from=item;
+ if (item->type!=ITEM_NEWLINE)
+ current_frame->lines[current_frame->lines.size()-1].from=item;
_invalidate_current_line(current_frame);
}
@@ -1410,7 +1409,7 @@ bool RichTextLabel::is_meta_underlined() const {
void RichTextLabel::set_offset(int p_pixel) {
- vscroll->set_val(p_pixel);
+ vscroll->set_value(p_pixel);
}
void RichTextLabel::set_scroll_active(bool p_active) {
@@ -1430,7 +1429,7 @@ bool RichTextLabel::is_scroll_active() const {
void RichTextLabel::set_scroll_follow(bool p_follow) {
scroll_follow=p_follow;
- if (!vscroll->is_visible() || vscroll->get_val()>=(vscroll->get_max()-vscroll->get_page()))
+ if (!vscroll->is_visible_in_tree() || vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page()))
scroll_following=true;
}
@@ -1727,7 +1726,7 @@ void RichTextLabel::scroll_to_line(int p_line) {
ERR_FAIL_INDEX(p_line,main->lines.size());
_validate_line_caches(main);
- vscroll->set_val(main->lines[p_line].height_accum_cache-main->lines[p_line].height_cache);
+ vscroll->set_value(main->lines[p_line].height_accum_cache-main->lines[p_line].height_cache);
}
@@ -1794,7 +1793,7 @@ bool RichTextLabel::search(const String& p_string,bool p_from_selection) {
}
item=item->parent;
}
- vscroll->set_val(offset-fh);
+ vscroll->set_value(offset-fh);
return true;
}
@@ -1901,61 +1900,62 @@ String RichTextLabel::get_text() {
void RichTextLabel::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&RichTextLabel::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
- ObjectTypeDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
- ObjectTypeDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
- ObjectTypeDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
- ObjectTypeDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
- ObjectTypeDB::bind_method(_MD("push_font","font"),&RichTextLabel::push_font);
- ObjectTypeDB::bind_method(_MD("push_color","color"),&RichTextLabel::push_color);
- ObjectTypeDB::bind_method(_MD("push_align","align"),&RichTextLabel::push_align);
- ObjectTypeDB::bind_method(_MD("push_indent","level"),&RichTextLabel::push_indent);
- ObjectTypeDB::bind_method(_MD("push_list","type"),&RichTextLabel::push_list);
- ObjectTypeDB::bind_method(_MD("push_meta","data"),&RichTextLabel::push_meta);
- ObjectTypeDB::bind_method(_MD("push_underline"),&RichTextLabel::push_underline);
- ObjectTypeDB::bind_method(_MD("push_table","columns"),&RichTextLabel::push_table);
- ObjectTypeDB::bind_method(_MD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
- ObjectTypeDB::bind_method(_MD("push_cell"),&RichTextLabel::push_cell);
- ObjectTypeDB::bind_method(_MD("pop"),&RichTextLabel::pop);
+ ClassDB::bind_method(_MD("_gui_input"),&RichTextLabel::_gui_input);
+ ClassDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
+ ClassDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
+ ClassDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
+ ClassDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
+ ClassDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
+ ClassDB::bind_method(_MD("push_font","font"),&RichTextLabel::push_font);
+ ClassDB::bind_method(_MD("push_color","color"),&RichTextLabel::push_color);
+ ClassDB::bind_method(_MD("push_align","align"),&RichTextLabel::push_align);
+ ClassDB::bind_method(_MD("push_indent","level"),&RichTextLabel::push_indent);
+ ClassDB::bind_method(_MD("push_list","type"),&RichTextLabel::push_list);
+ ClassDB::bind_method(_MD("push_meta","data"),&RichTextLabel::push_meta);
+ ClassDB::bind_method(_MD("push_underline"),&RichTextLabel::push_underline);
+ ClassDB::bind_method(_MD("push_table","columns"),&RichTextLabel::push_table);
+ ClassDB::bind_method(_MD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
+ ClassDB::bind_method(_MD("push_cell"),&RichTextLabel::push_cell);
+ ClassDB::bind_method(_MD("pop"),&RichTextLabel::pop);
- ObjectTypeDB::bind_method(_MD("clear"),&RichTextLabel::clear);
+ ClassDB::bind_method(_MD("clear"),&RichTextLabel::clear);
- ObjectTypeDB::bind_method(_MD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
- ObjectTypeDB::bind_method(_MD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
+ ClassDB::bind_method(_MD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
+ ClassDB::bind_method(_MD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
- ObjectTypeDB::bind_method(_MD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
- ObjectTypeDB::bind_method(_MD("is_scroll_active"),&RichTextLabel::is_scroll_active);
+ ClassDB::bind_method(_MD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
+ ClassDB::bind_method(_MD("is_scroll_active"),&RichTextLabel::is_scroll_active);
- ObjectTypeDB::bind_method(_MD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
- ObjectTypeDB::bind_method(_MD("is_scroll_following"),&RichTextLabel::is_scroll_following);
+ ClassDB::bind_method(_MD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
+ ClassDB::bind_method(_MD("is_scroll_following"),&RichTextLabel::is_scroll_following);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&RichTextLabel::get_v_scroll);
+ ClassDB::bind_method(_MD("get_v_scroll"),&RichTextLabel::get_v_scroll);
- ObjectTypeDB::bind_method(_MD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
+ ClassDB::bind_method(_MD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
- ObjectTypeDB::bind_method(_MD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
- ObjectTypeDB::bind_method(_MD("get_tab_size"),&RichTextLabel::get_tab_size);
+ ClassDB::bind_method(_MD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
+ ClassDB::bind_method(_MD("get_tab_size"),&RichTextLabel::get_tab_size);
- ObjectTypeDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
- ObjectTypeDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
+ ClassDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
+ ClassDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
- ObjectTypeDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
- ObjectTypeDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
+ ClassDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
+ ClassDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
- ObjectTypeDB::bind_method(_MD("set_bbcode","text"),&RichTextLabel::set_bbcode);
- ObjectTypeDB::bind_method(_MD("get_bbcode"),&RichTextLabel::get_bbcode);
+ ClassDB::bind_method(_MD("set_bbcode","text"),&RichTextLabel::set_bbcode);
+ ClassDB::bind_method(_MD("get_bbcode"),&RichTextLabel::get_bbcode);
- ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&RichTextLabel::set_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_visible_characters"),&RichTextLabel::get_visible_characters);
+ ClassDB::bind_method(_MD("set_visible_characters","amount"),&RichTextLabel::set_visible_characters);
+ ClassDB::bind_method(_MD("get_visible_characters"),&RichTextLabel::get_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_total_character_count"),&RichTextLabel::get_total_character_count);
+ ClassDB::bind_method(_MD("get_total_character_count"),&RichTextLabel::get_total_character_count);
- ObjectTypeDB::bind_method(_MD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
- ObjectTypeDB::bind_method(_MD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
+ ClassDB::bind_method(_MD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
+ ClassDB::bind_method(_MD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"bbcode/enabled"),_SCS("set_use_bbcode"),_SCS("is_using_bbcode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"bbcode/bbcode",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_bbcode"),_SCS("get_bbcode"));
+ ADD_GROUP("BBCode","bbcode_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"bbcode_enabled"),_SCS("set_use_bbcode"),_SCS("is_using_bbcode"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"bbcode_text",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_bbcode"),_SCS("get_bbcode"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"visible_characters",PROPERTY_HINT_RANGE,"-1,128000,1"),_SCS("set_visible_characters"),_SCS("get_visible_characters"));
ADD_SIGNAL( MethodInfo("meta_clicked",PropertyInfo(Variant::NIL,"meta")));
@@ -2044,6 +2044,7 @@ RichTextLabel::RichTextLabel() {
visible_characters=-1;
+ set_clip_contents(true);
}
RichTextLabel::~RichTextLabel() {
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 5147905a0e..39032185f8 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class RichTextLabel : public Control {
- OBJ_TYPE( RichTextLabel, Control );
+ GDCLASS( RichTextLabel, Control );
public:
enum Align {
@@ -267,7 +267,7 @@ private:
void _update_scroll();
void _scroll_changed(double);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
Item *_get_next_item(Item* p_item, bool p_free=false);
bool use_bbcode;
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index d8365feb24..fc406ff0f5 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@ void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
focus_by_default=p_can_focus;
}
-void ScrollBar::_input_event(InputEvent p_event) {
+void ScrollBar::_gui_input(InputEvent p_event) {
switch(p_event.type) {
@@ -51,20 +51,24 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (b.button_index==5 && b.pressed) {
- //if (orientation==VERTICAL)
- // set_val( get_val() + get_page() / 4.0 );
- //else
- set_val( get_val() + get_page() / 4.0 );
+ /*
+ if (orientation==VERTICAL)
+ set_val( get_val() + get_page() / 4.0 );
+ else
+ */
+ set_value( get_value() + get_page() / 4.0 );
accept_event();
}
if (b.button_index==4 && b.pressed) {
- //if (orientation==HORIZONTAL)
- // set_val( get_val() - get_page() / 4.0 );
- //else
- set_val( get_val() - get_page() / 4.0 );
+ /*
+ if (orientation==HORIZONTAL)
+ set_val( get_val() - get_page() / 4.0 );
+ else
+ */
+ set_value( get_value() - get_page() / 4.0 );
accept_event();
}
@@ -87,13 +91,13 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (ofs < decr_size ) {
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
break;
}
if (ofs > total-incr_size ) {
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
break;
}
@@ -101,7 +105,7 @@ void ScrollBar::_input_event(InputEvent p_event) {
if ( ofs < grabber_ofs ) {
- set_val( get_val() - get_page() );
+ set_value( get_value() - get_page() );
break;
}
@@ -112,12 +116,12 @@ void ScrollBar::_input_event(InputEvent p_event) {
drag.active=true;
drag.pos_at_click=grabber_ofs+ofs;
- drag.value_at_click=get_unit_value();
+ drag.value_at_click=get_as_ratio();
update();
} else {
- set_val( get_val() + get_page() );
+ set_value( get_value() + get_page() );
}
@@ -145,7 +149,7 @@ void ScrollBar::_input_event(InputEvent p_event) {
double diff = (ofs-drag.pos_at_click) / get_area_size();
- set_unit_value( drag.value_at_click + diff );
+ set_as_ratio( drag.value_at_click + diff );
} else {
@@ -194,14 +198,14 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
} break;
case KEY_RIGHT: {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
} break;
case KEY_UP: {
@@ -209,7 +213,7 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
} break;
@@ -217,17 +221,17 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
} break;
case KEY_HOME: {
- set_val( get_min() );
+ set_value( get_min() );
} break;
case KEY_END: {
- set_val( get_max() );
+ set_value( get_max() );
} break;
@@ -302,8 +306,8 @@ void ScrollBar::_notification(int p_what) {
}
if (drag_slave) {
- drag_slave->connect("input_event",this,"_drag_slave_input");
- drag_slave->connect("exit_tree",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ drag_slave->connect("gui_input",this,"_drag_slave_input");
+ drag_slave->connect("tree_exited",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
}
@@ -311,8 +315,8 @@ void ScrollBar::_notification(int p_what) {
if (p_what==NOTIFICATION_EXIT_TREE) {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
- drag_slave->disconnect("exit_tree",this,"_drag_slave_exit");
+ drag_slave->disconnect("gui_input",this,"_drag_slave_input");
+ drag_slave->disconnect("tree_exited",this,"_drag_slave_exit");
}
drag_slave=NULL;
@@ -325,7 +329,7 @@ void ScrollBar::_notification(int p_what) {
if (drag_slave_touching_deaccel) {
- Vector2 pos = Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+ Vector2 pos = Vector2(orientation==HORIZONTAL?get_value():0,orientation==VERTICAL?get_value():0);
pos+=drag_slave_speed*get_fixed_process_delta_time();
bool turnoff=false;
@@ -342,7 +346,7 @@ void ScrollBar::_notification(int p_what) {
turnoff=true;
}
- set_val(pos.x);
+ set_value(pos.x);
float sgn_x = drag_slave_speed.x<0? -1 : 1;
float val_x = Math::abs(drag_slave_speed.x);
@@ -367,7 +371,7 @@ void ScrollBar::_notification(int p_what) {
turnoff=true;
}
- set_val(pos.y);
+ set_value(pos.y);
float sgn_y = drag_slave_speed.y<0? -1 : 1;
float val_y = Math::abs(drag_slave_speed.y);
@@ -425,8 +429,10 @@ double ScrollBar::get_grabber_size() const {
return 0;
float page = (get_page()>0)? get_page() : 0;
-// if (grabber_range < get_step())
-// grabber_range=get_step();
+ /*
+ if (grabber_range < get_step())
+ grabber_range=get_step();
+ */
double area_size=get_area_size();
double grabber_size = page / range * area_size;
@@ -497,7 +503,7 @@ double ScrollBar::get_click_pos(const Point2& p_pos) const {
double ScrollBar::get_grabber_offset() const {
- return (get_area_size()) * get_unit_value();
+ return (get_area_size()) * get_as_ratio();
}
@@ -546,7 +552,7 @@ float ScrollBar::get_custom_step() const {
void ScrollBar::_drag_slave_exit() {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
+ drag_slave->disconnect("gui_input",this,"_drag_slave_input");
}
drag_slave=NULL;
}
@@ -580,7 +586,7 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
drag_slave_accum=Vector2();
last_drag_slave_accum=Vector2();
//drag_slave_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
- drag_slave_from= Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+ drag_slave_from= Vector2(orientation==HORIZONTAL?get_value():0,orientation==VERTICAL?get_value():0);
drag_slave_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_slave_touching_deaccel=false;
@@ -619,13 +625,17 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
Vector2 diff = drag_slave_from+drag_slave_accum;
if (orientation==HORIZONTAL)
- set_val(diff.x);
- //else
- // drag_slave_accum.x=0;
+ set_value(diff.x);
+ /*
+ else
+ drag_slave_accum.x=0;
+ */
if (orientation==VERTICAL)
- set_val(diff.y);
- //else
- // drag_slave_accum.y=0;
+ set_value(diff.y);
+ /*
+ else
+ drag_slave_accum.y=0;
+ */
time_since_motion=0;
}
@@ -638,8 +648,8 @@ void ScrollBar::set_drag_slave(const NodePath& p_path) {
if (is_inside_tree()) {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
- drag_slave->disconnect("exit_tree",this,"_drag_slave_exit");
+ drag_slave->disconnect("gui_input",this,"_drag_slave_input");
+ drag_slave->disconnect("tree_exited",this,"_drag_slave_exit");
}
}
@@ -654,8 +664,8 @@ void ScrollBar::set_drag_slave(const NodePath& p_path) {
}
if (drag_slave) {
- drag_slave->connect("input_event",this,"_drag_slave_input");
- drag_slave->connect("exit_tree",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ drag_slave->connect("gui_input",this,"_drag_slave_input");
+ drag_slave->connect("tree_exited",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
}
}
}
@@ -804,11 +814,11 @@ bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b.pr
void ScrollBar::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollBar::_input_event);
- ObjectTypeDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
- ObjectTypeDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
- ObjectTypeDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
- ObjectTypeDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
+ ClassDB::bind_method(_MD("_gui_input"),&ScrollBar::_gui_input);
+ ClassDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
+ ClassDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
+ ClassDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
+ ClassDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_step",PROPERTY_HINT_RANGE,"-1,4096"), _SCS("set_custom_step"),_SCS("get_custom_step"));
@@ -832,7 +842,7 @@ ScrollBar::ScrollBar(Orientation p_orientation)
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 c68db02b33..be8b394957 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class ScrollBar : public Range {
- OBJ_TYPE( ScrollBar, Range );
+ GDCLASS( ScrollBar, Range );
enum HiliteStatus {
HILITE_NONE,
@@ -87,7 +87,7 @@ class ScrollBar : public Range {
void _drag_slave_exit();
void _drag_slave_input(const InputEvent& p_input);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
protected:
void _notification(int p_what);
@@ -109,7 +109,7 @@ public:
class HScrollBar : public ScrollBar {
- OBJ_TYPE( HScrollBar, ScrollBar );
+ GDCLASS( HScrollBar, ScrollBar );
public:
HScrollBar() : ScrollBar(HORIZONTAL) { set_v_size_flags(0); }
@@ -117,7 +117,7 @@ public:
class VScrollBar : public ScrollBar {
- OBJ_TYPE( VScrollBar, ScrollBar );
+ GDCLASS( VScrollBar, ScrollBar );
public:
VScrollBar() : ScrollBar(VERTICAL) { set_h_size_flags(0); }
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 479bb96fe2..b3ed9b209a 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -59,10 +59,10 @@ Size2 ScrollContainer::get_minimum_size() const {
}
}
- if (h_scroll->is_visible()) {
+ if (h_scroll->is_visible_in_tree()) {
min_size.y+=h_scroll->get_minimum_size().y;
}
- if (v_scroll->is_visible()) {
+ if (v_scroll->is_visible_in_tree()) {
min_size.x+=v_scroll->get_minimum_size().x;
}
return min_size;
@@ -79,23 +79,31 @@ void ScrollContainer::_cancel_drag() {
drag_from=Vector2();
}
-void ScrollContainer::_input_event(const InputEvent& p_input_event) {
+void ScrollContainer::_gui_input(const InputEvent& p_gui_input) {
- switch(p_input_event.type) {
+ switch(p_gui_input.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input_event.mouse_button;
+ const InputEventMouseButton &mb=p_gui_input.mouse_button;
- if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed && v_scroll->is_visible()) {
-
- v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
+ if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) {
+ if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){
+ // only horizontal is enabled, scroll horizontally
+ h_scroll->set_value( h_scroll->get_value()-h_scroll->get_page()/8 );
+ } else if (v_scroll->is_visible_in_tree()) {
+ v_scroll->set_value( v_scroll->get_value()-v_scroll->get_page()/8 );
+ }
}
- if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed && v_scroll->is_visible()) {
-
- v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
+ if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) {
+ if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){
+ // only horizontal is enabled, scroll horizontally
+ h_scroll->set_value( h_scroll->get_value()+h_scroll->get_page()/8 );
+ } else if (v_scroll->is_visible_in_tree()) {
+ v_scroll->set_value( v_scroll->get_value()+v_scroll->get_page()/8 );
+ }
}
if(!OS::get_singleton()->has_touchscreen_ui_hint())
@@ -120,7 +128,7 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) {
drag_speed=Vector2();
drag_accum=Vector2();
last_drag_accum=Vector2();
- drag_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
+ drag_from=Vector2(h_scroll->get_value(),v_scroll->get_value());
drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_touching_deaccel=false;
time_since_motion=0;
@@ -150,7 +158,7 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ const InputEventMouseMotion &mm=p_gui_input.mouse_motion;
if (drag_touching && ! drag_touching_deaccel) {
@@ -159,11 +167,11 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) {
Vector2 diff = drag_from+drag_accum;
if (scroll_h)
- h_scroll->set_val(diff.x);
+ h_scroll->set_value(diff.x);
else
drag_accum.x=0;
if (scroll_v)
- v_scroll->set_val(diff.y);
+ v_scroll->set_value(diff.y);
else
drag_accum.y=0;
time_since_motion=0;
@@ -208,10 +216,10 @@ void ScrollContainer::_notification(int p_what) {
child_max_size = Size2(0, 0);
Size2 size = get_size();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
size.y-=h_scroll->get_minimum_size().y;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
size.x-=h_scroll->get_minimum_size().x;
for(int i=0;i<get_child_count();i++) {
@@ -228,14 +236,14 @@ void ScrollContainer::_notification(int p_what) {
child_max_size.y = MAX(child_max_size.y, minsize.y);
Rect2 r = Rect2(-scroll,minsize);
- if (!(scroll_h || h_scroll->is_visible())) {
+ if (!(scroll_h || h_scroll->is_visible_in_tree())) {
r.pos.x=0;
if (c->get_h_size_flags()&SIZE_EXPAND)
r.size.width=MAX(size.width,minsize.width);
else
r.size.width=minsize.width;
}
- if (!(scroll_v || v_scroll->is_visible())) {
+ if (!(scroll_v || v_scroll->is_visible_in_tree())) {
r.pos.y=0;
r.size.height=size.height;
if (c->get_v_size_flags()&SIZE_EXPAND)
@@ -253,7 +261,6 @@ void ScrollContainer::_notification(int p_what) {
update_scrollbars();
- VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
}
if (p_what==NOTIFICATION_FIXED_PROCESS) {
@@ -262,7 +269,7 @@ void ScrollContainer::_notification(int p_what) {
if (drag_touching_deaccel) {
- Vector2 pos = Vector2(h_scroll->get_val(),v_scroll->get_val());
+ Vector2 pos = Vector2(h_scroll->get_value(),v_scroll->get_value());
pos+=drag_speed*get_fixed_process_delta_time();
bool turnoff_h=false;
@@ -287,9 +294,9 @@ void ScrollContainer::_notification(int p_what) {
}
if (scroll_h)
- h_scroll->set_val(pos.x);
+ h_scroll->set_value(pos.x);
if (scroll_v)
- v_scroll->set_val(pos.y);
+ v_scroll->set_value(pos.y);
float sgn_x = drag_speed.x<0? -1 : 1;
float val_x = Math::abs(drag_speed.x);
@@ -351,7 +358,7 @@ void ScrollContainer::update_scrollbars() {
} else {
v_scroll->show();
- scroll.y=v_scroll->get_val();
+ scroll.y=v_scroll->get_value();
}
@@ -368,14 +375,14 @@ void ScrollContainer::update_scrollbars() {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- scroll.x=h_scroll->get_val();
+ scroll.x=h_scroll->get_value();
}
}
void ScrollContainer::_scroll_moved(float) {
- scroll.x=h_scroll->get_val();
- scroll.y=v_scroll->get_val();
+ scroll.x=h_scroll->get_value();
+ scroll.y=v_scroll->get_value();
queue_sort();
update();
@@ -407,42 +414,66 @@ bool ScrollContainer::is_v_scroll_enabled() const{
int ScrollContainer::get_v_scroll() const {
- return v_scroll->get_val();
+ return v_scroll->get_value();
}
void ScrollContainer::set_v_scroll(int p_pos) {
- v_scroll->set_val(p_pos);
+ v_scroll->set_value(p_pos);
_cancel_drag();
}
int ScrollContainer::get_h_scroll() const {
- return h_scroll->get_val();
+ return h_scroll->get_value();
}
void ScrollContainer::set_h_scroll(int p_pos) {
- h_scroll->set_val(p_pos);
+ h_scroll->set_value(p_pos);
_cancel_drag();
}
+String ScrollContainer::get_configuration_warning() const {
+
+ int found=0;
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Control *c = get_child(i)->cast_to<Control>();
+ if (!c)
+ continue;
+ if (c->is_set_as_toplevel())
+ continue;
+ if (c == h_scroll || c == v_scroll)
+ continue;
+
+ found++;
+ }
+
+ if (found!=1)
+ return TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox,HBox,etc), or a Control and set the custom minimum size manually.");
+ else
+ return "";
+}
+
void ScrollContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&ScrollContainer::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
- ObjectTypeDB::bind_method(_MD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
- ObjectTypeDB::bind_method(_MD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
- ObjectTypeDB::bind_method(_MD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
- ObjectTypeDB::bind_method(_MD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
- ObjectTypeDB::bind_method(_MD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
- ObjectTypeDB::bind_method(_MD("get_h_scroll"),&ScrollContainer::get_h_scroll);
- ObjectTypeDB::bind_method(_MD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&ScrollContainer::get_v_scroll);
-
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll/horizontal"), _SCS("set_enable_h_scroll"),_SCS("is_h_scroll_enabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll/vertical"), _SCS("set_enable_v_scroll"),_SCS("is_v_scroll_enabled"));
+ ClassDB::bind_method(_MD("_scroll_moved"),&ScrollContainer::_scroll_moved);
+ ClassDB::bind_method(_MD("_gui_input"),&ScrollContainer::_gui_input);
+ ClassDB::bind_method(_MD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
+ ClassDB::bind_method(_MD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
+ ClassDB::bind_method(_MD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
+ ClassDB::bind_method(_MD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
+ ClassDB::bind_method(_MD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
+ ClassDB::bind_method(_MD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
+ ClassDB::bind_method(_MD("get_h_scroll"),&ScrollContainer::get_h_scroll);
+ ClassDB::bind_method(_MD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
+ ClassDB::bind_method(_MD("get_v_scroll"),&ScrollContainer::get_v_scroll);
+
+ ADD_GROUP("Scroll","scroll_");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_horizontal"), _SCS("set_enable_h_scroll"),_SCS("is_h_scroll_enabled"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_vertical"), _SCS("set_enable_v_scroll"),_SCS("is_v_scroll_enabled"));
};
@@ -465,6 +496,6 @@ ScrollContainer::ScrollContainer() {
scroll_h=true;
scroll_v=true;
-
+ set_clip_contents(true);
};
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 50ae236714..114cd06306 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class ScrollContainer : public Container {
- OBJ_TYPE(ScrollContainer, Container);
+ GDCLASS(ScrollContainer, Container);
HScrollBar* h_scroll;
VScrollBar* v_scroll;
@@ -64,7 +64,7 @@ protected:
Size2 get_minimum_size() const;
- void _input_event(const InputEvent& p_input_event);
+ void _gui_input(const InputEvent& p_gui_input);
void _notification(int p_what);
void _scroll_moved(float);
@@ -86,6 +86,9 @@ public:
bool is_v_scroll_enabled() const;
virtual bool clips_input() const;
+
+ virtual String get_configuration_warning() const;
+
ScrollContainer();
};
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 626b093a2f..32bd2239fc 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/gui/separator.h b/scene/gui/separator.h
index 7a7dc92b93..5fb17e1c2e 100644
--- a/scene/gui/separator.h
+++ b/scene/gui/separator.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
#include "scene/gui/control.h"
class Separator : public Control {
- OBJ_TYPE( Separator, Control );
+ GDCLASS( Separator, Control );
protected:
@@ -54,7 +54,7 @@ public:
class VSeparator : public Separator {
- OBJ_TYPE( VSeparator, Separator );
+ GDCLASS( VSeparator, Separator );
public:
@@ -64,7 +64,7 @@ public:
class HSeparator : public Separator {
- OBJ_TYPE( HSeparator, Separator );
+ GDCLASS( HSeparator, Separator );
public:
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 3b9ca40bd8..ad6e8786d7 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@ Size2 Slider::get_minimum_size() const {
return ms;
}
-void Slider::_input_event(InputEvent p_event) {
+void Slider::_gui_input(InputEvent p_event) {
@@ -53,19 +53,19 @@ void Slider::_input_event(InputEvent p_event) {
double grab_height = (double)grabber->get_size().height;
double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
if (orientation==VERTICAL)
- set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
+ set_as_ratio( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
else
- set_unit_value(((double)grab.pos - (grab_width/2.0)) / max);
+ set_as_ratio(((double)grab.pos - (grab_width/2.0)) / max);
grab.active=true;
- grab.uvalue=get_unit_value();
+ grab.uvalue=get_as_ratio();
} else {
grab.active=false;
}
} else if (mb.pressed && mb.button_index==BUTTON_WHEEL_UP) {
- set_val( get_val() + get_step());
+ set_value( get_value() + get_step());
} else if (mb.pressed && mb.button_index==BUTTON_WHEEL_DOWN) {
- set_val( get_val() - get_step());
+ set_value( get_value() - get_step());
}
} else if (p_event.type==InputEvent::MOUSE_MOTION) {
@@ -81,7 +81,7 @@ void Slider::_input_event(InputEvent p_event) {
if (areasize<=0)
return;
float umotion = motion / float(areasize);
- set_unit_value( grab.uvalue + umotion );
+ set_as_ratio( grab.uvalue + umotion );
}
} else {
@@ -89,26 +89,26 @@ void Slider::_input_event(InputEvent p_event) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_right") && p_event.is_pressed()) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_up") && p_event.is_pressed()) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_down") && p_event.is_pressed()) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.type==InputEvent::KEY) {
@@ -122,12 +122,12 @@ void Slider::_input_event(InputEvent p_event) {
case KEY_HOME: {
- set_val( get_min() );
+ set_value( get_min() );
accept_event();
} break;
case KEY_END: {
- set_val( get_max() );
+ set_value( get_max() );
accept_event();
} break;
@@ -164,8 +164,10 @@ void Slider::_notification(int p_what) {
if (orientation==VERTICAL) {
style->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
+ /*
+ if (mouse_inside||has_focus())
+ focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
+ */
float areasize = size.height - grabber->get_size().height;
if (ticks>1) {
int tickarea = size.height - tick->get_height();
@@ -176,11 +178,13 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*areasize - grabber->get_size().height));
+ grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_as_ratio()*areasize - grabber->get_size().height));
} else {
style->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ /*
+ if (mouse_inside||has_focus())
+ focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ */
float areasize = size.width - grabber->get_size().width;
if (ticks>1) {
@@ -192,7 +196,7 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2));
+ grabber->draw(ci,Point2i(get_as_ratio()*areasize,size.height/2-grabber->get_size().height/2));
}
} break;
@@ -231,12 +235,12 @@ void Slider::set_ticks_on_borders(bool _tob){
void Slider::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Slider::_input_event);
- ObjectTypeDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
+ ClassDB::bind_method(_MD("_gui_input"),&Slider::_gui_input);
+ ClassDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
+ ClassDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
- ObjectTypeDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
+ ClassDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
+ ClassDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
ADD_PROPERTY( PropertyInfo( Variant::INT, "tick_count", PROPERTY_HINT_RANGE,"0,4096,1"), _SCS("set_ticks"), _SCS("get_ticks") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "ticks_on_borders" ), _SCS("set_ticks_on_borders"), _SCS("get_ticks_on_borders") );
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index cf009b9a75..89eb32737b 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Slider : public Range {
- OBJ_TYPE( Slider, Range );
+ GDCLASS( Slider, Range );
struct Grab {
int pos;
@@ -49,7 +49,7 @@ class Slider : public Range {
protected:
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
static void _bind_methods();
bool ticks_on_borders;
@@ -74,7 +74,7 @@ public:
class HSlider : public Slider {
- OBJ_TYPE( HSlider, Slider );
+ GDCLASS( HSlider, Slider );
public:
HSlider() : Slider(HORIZONTAL) { set_v_size_flags(0);}
@@ -82,7 +82,7 @@ public:
class VSlider : public Slider {
- OBJ_TYPE( VSlider, Slider );
+ GDCLASS( VSlider, Slider );
public:
VSlider() : Slider(VERTICAL) { set_h_size_flags(0);}
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 98e1a32aef..ec6be0d19d 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@ Size2 SpinBox::get_minimum_size() const {
void SpinBox::_value_changed(double) {
- String value = String::num(get_val(),Math::step_decimals(get_step()));
+ String value = String::num(get_value(),Math::step_decimals(get_step()));
if (prefix!="")
value=prefix+" "+value;
if (suffix!="")
@@ -49,9 +49,14 @@ void SpinBox::_value_changed(double) {
void SpinBox::_text_entered(const String& p_string) {
- //if (!p_string.is_numeric())
- // return;
- set_val( p_string.to_double() );
+ /*
+ if (!p_string.is_numeric())
+ return;
+ */
+ String value = p_string;
+ if (prefix!="" && p_string.begins_with(prefix))
+ value = p_string.substr(prefix.length(), p_string.length()-prefix.length());
+ set_value( value.to_double() );
_value_changed(0);
}
@@ -73,7 +78,7 @@ void SpinBox::_range_click_timeout() {
if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
bool up = get_local_mouse_pos().y < (get_size().height/2);
- set_val( get_val() + (up?get_step():-get_step()));
+ set_value( get_value() + (up?get_step():-get_step()));
if (range_click_timer->is_one_shot()) {
range_click_timer->set_wait_time(0.075);
@@ -87,8 +92,11 @@ void SpinBox::_range_click_timeout() {
}
-void SpinBox::_input_event(const InputEvent& p_event) {
+void SpinBox::_gui_input(const InputEvent& p_event) {
+ if (!is_editable()) {
+ return;
+ }
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) {
const InputEventMouseButton &mb=p_event.mouse_button;
@@ -101,25 +109,30 @@ void SpinBox::_input_event(const InputEvent& p_event) {
case BUTTON_LEFT: {
- set_val( get_val() + (up?get_step():-get_step()));
+ set_value( get_value() + (up?get_step():-get_step()));
range_click_timer->set_wait_time(0.6);
range_click_timer->set_one_shot(true);
range_click_timer->start();
+ line_edit->grab_focus();
} break;
case BUTTON_RIGHT: {
- set_val( (up?get_max():get_min()) );
-
+ set_value( (up?get_max():get_min()) );
+ line_edit->grab_focus();
} break;
case BUTTON_WHEEL_UP: {
-
- set_val( get_val() + get_step() );
+ if (line_edit->has_focus()) {
+ set_value( get_value() + get_step() );
+ accept_event();
+ }
} break;
case BUTTON_WHEEL_DOWN: {
-
- set_val( get_val() - get_step() );
+ if (line_edit->has_focus()) {
+ set_value( get_value() - get_step() );
+ accept_event();
+ }
} break;
}
}
@@ -155,13 +168,13 @@ void SpinBox::_input_event(const InputEvent& p_event) {
drag.mouse_pos=cpos;
drag.base_val=CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max());
- set_val( drag.base_val);
+ set_value( drag.base_val);
} else if (drag.mouse_pos.distance_to(cpos)>2) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
drag.enabled=true;
- drag.base_val=get_val();
+ drag.base_val=get_value();
drag.mouse_pos=cpos;
drag.capture_pos=cpos;
@@ -240,19 +253,19 @@ bool SpinBox::is_editable() const {
void SpinBox::_bind_methods() {
- //ObjectTypeDB::bind_method(_MD("_value_changed"),&SpinBox::_value_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&SpinBox::_input_event);
- ObjectTypeDB::bind_method(_MD("_text_entered"),&SpinBox::_text_entered);
- ObjectTypeDB::bind_method(_MD("set_suffix","suffix"),&SpinBox::set_suffix);
- ObjectTypeDB::bind_method(_MD("get_suffix"),&SpinBox::get_suffix);
- ObjectTypeDB::bind_method(_MD("set_prefix","prefix"),&SpinBox::set_prefix);
- ObjectTypeDB::bind_method(_MD("get_prefix"),&SpinBox::get_prefix);
- ObjectTypeDB::bind_method(_MD("set_editable","editable"),&SpinBox::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable"),&SpinBox::is_editable);
- ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
- ObjectTypeDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
- ObjectTypeDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
- ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
+ //ClassDB::bind_method(_MD("_value_changed"),&SpinBox::_value_changed);
+ ClassDB::bind_method(_MD("_gui_input"),&SpinBox::_gui_input);
+ ClassDB::bind_method(_MD("_text_entered"),&SpinBox::_text_entered);
+ ClassDB::bind_method(_MD("set_suffix","suffix"),&SpinBox::set_suffix);
+ ClassDB::bind_method(_MD("get_suffix"),&SpinBox::get_suffix);
+ ClassDB::bind_method(_MD("set_prefix","prefix"),&SpinBox::set_prefix);
+ ClassDB::bind_method(_MD("get_prefix"),&SpinBox::get_prefix);
+ ClassDB::bind_method(_MD("set_editable","editable"),&SpinBox::set_editable);
+ ClassDB::bind_method(_MD("is_editable"),&SpinBox::is_editable);
+ ClassDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
+ ClassDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
+ ClassDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
+ ClassDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable"));
@@ -271,8 +284,8 @@ SpinBox::SpinBox() {
line_edit->set_area_as_parent_rect();
//connect("value_changed",this,"_value_changed");
line_edit->connect("text_entered",this,"_text_entered",Vector<Variant>(),CONNECT_DEFERRED);
- line_edit->connect("focus_exit",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED);
- line_edit->connect("input_event",this,"_line_edit_input");
+ line_edit->connect("focus_exited",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED);
+ line_edit->connect("gui_input",this,"_line_edit_input");
drag.enabled=false;
range_click_timer = memnew( Timer );
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index acaea822ab..9974ec47bc 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SpinBox : public Range {
- OBJ_TYPE( SpinBox, Range );
+ GDCLASS( SpinBox, Range );
LineEdit *line_edit;
int last_w;
@@ -64,7 +64,7 @@ class SpinBox : public Range {
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 6b36a60ea2..a39ad2fe99 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,7 +47,7 @@ Control *SplitContainer::_getch(int p_idx) const {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -299,7 +299,7 @@ void SplitContainer::_notification(int p_what) {
}
}
-void SplitContainer::_input_event(const InputEvent& p_event) {
+void SplitContainer::_gui_input(const InputEvent& p_event) {
if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility!=DRAGGER_VISIBLE)
return;
@@ -422,21 +422,21 @@ bool SplitContainer::is_collapsed() const {
void SplitContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&SplitContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("set_split_offset","offset"),&SplitContainer::set_split_offset);
- ObjectTypeDB::bind_method(_MD("get_split_offset"),&SplitContainer::get_split_offset);
+ ClassDB::bind_method(_MD("_gui_input"),&SplitContainer::_gui_input);
+ ClassDB::bind_method(_MD("set_split_offset","offset"),&SplitContainer::set_split_offset);
+ ClassDB::bind_method(_MD("get_split_offset"),&SplitContainer::get_split_offset);
- ObjectTypeDB::bind_method(_MD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
- ObjectTypeDB::bind_method(_MD("is_collapsed"),&SplitContainer::is_collapsed);
+ ClassDB::bind_method(_MD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
+ ClassDB::bind_method(_MD("is_collapsed"),&SplitContainer::is_collapsed);
- ObjectTypeDB::bind_method(_MD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
- ObjectTypeDB::bind_method(_MD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
+ ClassDB::bind_method(_MD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
+ ClassDB::bind_method(_MD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
ADD_SIGNAL( MethodInfo("dragged",PropertyInfo(Variant::INT,"offset")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split/offset"),_SCS("set_split_offset"),_SCS("get_split_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"split/collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split/dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),_SCS("set_dragger_visibility"),_SCS("get_dragger_visibility"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"split_offset"),_SCS("set_split_offset"),_SCS("get_split_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),_SCS("set_dragger_visibility"),_SCS("get_dragger_visibility"));
BIND_CONSTANT( DRAGGER_VISIBLE );
BIND_CONSTANT( DRAGGER_HIDDEN );
diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h
index d2dc42165e..03b6b1a167 100644
--- a/scene/gui/split_container.h
+++ b/scene/gui/split_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class SplitContainer : public Container {
- OBJ_TYPE(SplitContainer,Container);
+ GDCLASS(SplitContainer,Container);
public:
enum DraggerVisibility {
DRAGGER_VISIBLE,
@@ -59,7 +59,7 @@ private:
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
static void _bind_methods();
public:
@@ -86,7 +86,7 @@ VARIANT_ENUM_CAST(SplitContainer::DraggerVisibility);
class HSplitContainer : public SplitContainer {
- OBJ_TYPE(HSplitContainer,SplitContainer);
+ GDCLASS(HSplitContainer,SplitContainer);
public:
@@ -96,7 +96,7 @@ public:
class VSplitContainer : public SplitContainer {
- OBJ_TYPE(VSplitContainer,SplitContainer);
+ GDCLASS(VSplitContainer,SplitContainer);
public:
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 8557500488..52d26b29de 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -65,7 +65,7 @@ int TabContainer::_get_top_margin() const {
-void TabContainer::_input_event(const InputEvent& p_event) {
+void TabContainer::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON &&
p_event.mouse_button.pressed &&
@@ -680,7 +680,7 @@ Size2 TabContainer::get_minimum_size() const {
if (c->is_set_as_toplevel())
continue;
- if (!c->is_visible())
+ if (!c->is_visible_in_tree())
continue;
Size2 cms = c->get_combined_minimum_size();
@@ -714,24 +714,24 @@ Popup* TabContainer::get_popup() const {
void TabContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&TabContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("get_tab_count"),&TabContainer::get_tab_count);
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"),&TabContainer::set_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab"),&TabContainer::get_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab_control:Control"),&TabContainer::get_current_tab_control);
- ObjectTypeDB::bind_method(_MD("get_tab_control:Control","idx"),&TabContainer::get_tab_control);
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&TabContainer::set_tab_align);
- ObjectTypeDB::bind_method(_MD("get_tab_align"),&TabContainer::get_tab_align);
- ObjectTypeDB::bind_method(_MD("set_tabs_visible","visible"),&TabContainer::set_tabs_visible);
- ObjectTypeDB::bind_method(_MD("are_tabs_visible"),&TabContainer::are_tabs_visible);
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"),&TabContainer::set_tab_title);
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&TabContainer::get_tab_title);
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&TabContainer::set_tab_icon);
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&TabContainer::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("set_popup","popup:Popup"),&TabContainer::set_popup);
- ObjectTypeDB::bind_method(_MD("get_popup:Popup"),&TabContainer::get_popup);
-
- ObjectTypeDB::bind_method(_MD("_child_renamed_callback"),&TabContainer::_child_renamed_callback);
+ ClassDB::bind_method(_MD("_gui_input"),&TabContainer::_gui_input);
+ ClassDB::bind_method(_MD("get_tab_count"),&TabContainer::get_tab_count);
+ ClassDB::bind_method(_MD("set_current_tab","tab_idx"),&TabContainer::set_current_tab);
+ ClassDB::bind_method(_MD("get_current_tab"),&TabContainer::get_current_tab);
+ ClassDB::bind_method(_MD("get_current_tab_control:Control"),&TabContainer::get_current_tab_control);
+ ClassDB::bind_method(_MD("get_tab_control:Control","idx"),&TabContainer::get_tab_control);
+ ClassDB::bind_method(_MD("set_tab_align","align"),&TabContainer::set_tab_align);
+ ClassDB::bind_method(_MD("get_tab_align"),&TabContainer::get_tab_align);
+ ClassDB::bind_method(_MD("set_tabs_visible","visible"),&TabContainer::set_tabs_visible);
+ ClassDB::bind_method(_MD("are_tabs_visible"),&TabContainer::are_tabs_visible);
+ ClassDB::bind_method(_MD("set_tab_title","tab_idx","title"),&TabContainer::set_tab_title);
+ ClassDB::bind_method(_MD("get_tab_title","tab_idx"),&TabContainer::get_tab_title);
+ ClassDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&TabContainer::set_tab_icon);
+ ClassDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&TabContainer::get_tab_icon);
+ ClassDB::bind_method(_MD("set_popup","popup:Popup"),&TabContainer::set_popup);
+ ClassDB::bind_method(_MD("get_popup:Popup"),&TabContainer::get_popup);
+
+ ClassDB::bind_method(_MD("_child_renamed_callback"),&TabContainer::_child_renamed_callback);
ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
ADD_SIGNAL(MethodInfo("pre_popup_pressed"));
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 979ce927a0..8b6ca7704e 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#include "scene/gui/popup.h"
class TabContainer : public Control {
- OBJ_TYPE( TabContainer, Control );
+ GDCLASS( TabContainer, Control );
public:
enum TabAlign {
@@ -61,7 +61,7 @@ private:
protected:
void _child_renamed_callback();
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index eb060aa6b8..98d3f6230d 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -76,7 +76,7 @@ Size2 Tabs::get_minimum_size() const {
}
-void Tabs::_input_event(const InputEvent& p_event) {
+void Tabs::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_MOTION) {
@@ -649,19 +649,19 @@ void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
void Tabs::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Tabs::_input_event);
- ObjectTypeDB::bind_method(_MD("get_tab_count"),&Tabs::get_tab_count);
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab"),&Tabs::get_current_tab);
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
- ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
- ObjectTypeDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
- ObjectTypeDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
+ ClassDB::bind_method(_MD("_gui_input"),&Tabs::_gui_input);
+ ClassDB::bind_method(_MD("get_tab_count"),&Tabs::get_tab_count);
+ ClassDB::bind_method(_MD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
+ ClassDB::bind_method(_MD("get_current_tab"),&Tabs::get_current_tab);
+ ClassDB::bind_method(_MD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
+ ClassDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
+ ClassDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
+ ClassDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
+ ClassDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
+ ClassDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
+ ClassDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
+ ClassDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
+ ClassDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed",PropertyInfo(Variant::INT,"tab")));
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 5a4533c3d2..9ba32297dc 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Tabs : public Control {
- OBJ_TYPE( Tabs, Control );
+ GDCLASS( Tabs, Control );
public:
enum TabAlign {
@@ -92,7 +92,7 @@ private:
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8a9ed98a5f..8efff21fc9 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -347,7 +347,7 @@ void TextEdit::_update_scrollbars() {
v_scroll->show();
v_scroll->set_max(total_rows);
v_scroll->set_page(visible_rows);
- v_scroll->set_val(cursor.line_ofs);
+ v_scroll->set_value(cursor.line_ofs);
} else {
cursor.line_ofs = 0;
@@ -359,7 +359,7 @@ void TextEdit::_update_scrollbars() {
h_scroll->show();
h_scroll->set_max(total_width);
h_scroll->set_page(visible_width);
- h_scroll->set_val(cursor.x_ofs);
+ h_scroll->set_value(cursor.x_ofs);
} else {
@@ -482,12 +482,20 @@ void TextEdit::_notification(int p_what) {
Color color = cache.font_color;
int in_region=-1;
+ if (line_length_guideline) {
+ int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
+ if (x>xmargin_beg && x<xmargin_end) {
+ Color guideline_color(color.r,color.g,color.b,color.a*0.25f);
+ VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),guideline_color);
+ }
+ }
+
if (syntax_coloring) {
- if (custom_bg_color.a>0.01) {
+ if (cache.background_color.a>0.01) {
Point2i ofs = Point2i(cache.style_normal->get_offset())/2.0;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),custom_bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),cache.background_color);
}
//compute actual region to start (may be inside say, a comment).
//slow in very large documments :( but ok for source!
@@ -685,6 +693,8 @@ void TextEdit::_notification(int p_what) {
// get the highlighted words
String highlighted_text = get_selection_text();
+ String line_num_padding = line_numbers_zero_padded ? "0" : " ";
+
for (int i=0;i<visible_rows;i++) {
int line=i+cursor.line_ofs;
@@ -750,7 +760,7 @@ void TextEdit::_notification(int p_what) {
if (cache.line_number_w) {
String fc = String::num(line+1);
while (fc.length() < line_number_char_count) {
- fc="0"+fc;
+ fc=line_num_padding+fc;
}
cache.font->draw(ci,Point2(cache.style_normal->get_margin(MARGIN_LEFT)+cache.breakpoint_gutter_width,ofs_y+cache.font->get_ascent()),fc,cache.line_number_color);
@@ -897,7 +907,7 @@ void TextEdit::_notification(int p_what) {
else if (in_function_name)
color=cache.function_color;
else if (is_symbol)
- color=symbol_color;
+ color=cache.symbol_color;
else if (is_number)
color=cache.number_color;
@@ -1245,15 +1255,19 @@ void TextEdit::_notification(int p_what) {
}
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
+ if (raised_from_completion) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ }
} break;
case NOTIFICATION_FOCUS_EXIT: {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
-
+ if (raised_from_completion) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ }
} break;
-
}
}
@@ -1454,13 +1468,13 @@ void TextEdit::_get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) co
r_col=col;
}
-void TextEdit::_input_event(const InputEvent& p_input_event) {
+void TextEdit::_gui_input(const InputEvent& p_gui_input) {
- switch(p_input_event.type) {
+ switch(p_gui_input.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input_event.mouse_button;
+ const InputEventMouseButton &mb=p_gui_input.mouse_button;
if (completion_active && completion_rect.has_point(Point2(mb.x,mb.y))) {
@@ -1501,16 +1515,16 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (mb.pressed) {
if (mb.button_index==BUTTON_WHEEL_UP && !mb.mod.command) {
- v_scroll->set_val( v_scroll->get_val() -3 );
+ v_scroll->set_value( v_scroll->get_value() -3 );
}
if (mb.button_index==BUTTON_WHEEL_DOWN && !mb.mod.command) {
- v_scroll->set_val( v_scroll->get_val() +3 );
+ v_scroll->set_value( v_scroll->get_value() +3 );
}
if (mb.button_index==BUTTON_WHEEL_LEFT) {
- h_scroll->set_val( h_scroll->get_val() -3 );
+ h_scroll->set_value( h_scroll->get_value() -3 );
}
if (mb.button_index==BUTTON_WHEEL_RIGHT) {
- h_scroll->set_val( h_scroll->get_val() +3 );
+ h_scroll->set_value( h_scroll->get_value() +3 );
}
if (mb.button_index==BUTTON_LEFT) {
@@ -1651,7 +1665,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
update();
}
- if (mb.button_index==BUTTON_RIGHT) {
+ if (mb.button_index==BUTTON_RIGHT && context_menu_enabled) {
menu->set_pos(get_global_transform().xform(get_local_mouse_pos()));
menu->set_size(Vector2(1,1));
@@ -1671,7 +1685,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ const InputEventMouseMotion &mm=p_gui_input.mouse_motion;
if (select_identifiers_enabled) {
if (mm.mod.command && mm.button_mask==0) {
@@ -1714,7 +1728,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
case InputEvent::KEY: {
- InputEventKey k=p_input_event.key;
+ InputEventKey k=p_gui_input.key;
#ifdef OSX_ENABLED
@@ -3022,7 +3036,7 @@ void TextEdit::adjust_viewport_to_cursor() {
cursor.line_ofs=cursor.line;
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
visible_width-=v_scroll->get_combined_minimum_size().width;
visible_width-=20; // give it a little more space
@@ -3030,7 +3044,7 @@ void TextEdit::adjust_viewport_to_cursor() {
//printf("rowofs %i, visrows %i, cursor.line %i\n",cursor.line_ofs,get_visible_rows(),cursor.line);
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
if (cursor.line>=(cursor.line_ofs+visible_rows))
@@ -3064,12 +3078,12 @@ void TextEdit::center_viewport_to_cursor() {
cursor.line_ofs=cursor.line;
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
visible_width-=v_scroll->get_combined_minimum_size().width;
visible_width-=20; // give it a little more space
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
int max_ofs = text.size()-(scroll_past_end_of_file_enabled?1:visible_rows);
@@ -3191,10 +3205,10 @@ void TextEdit::_scroll_moved(double p_to_val) {
if (updating_scrolls)
return;
- if (h_scroll->is_visible())
- cursor.x_ofs=h_scroll->get_val();
- if (v_scroll->is_visible())
- cursor.line_ofs=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ cursor.x_ofs=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ cursor.line_ofs=v_scroll->get_value();
update();
}
@@ -3313,7 +3327,7 @@ void TextEdit::set_text(String p_text){
cursor_set_column(0);
update();
setting_text=false;
-
+ _text_changed_emit();
//get_range()->set(0);
};
@@ -3444,7 +3458,7 @@ void TextEdit::_reset_caret_blink_timer() {
void TextEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible()) {
+ if (is_visible_in_tree() && has_focus() && window_has_focus) {
update();
}
}
@@ -3475,6 +3489,8 @@ void TextEdit::_update_caches() {
cache.word_highlighted_color=get_color("word_highlighted_color");
cache.search_result_color=get_color("search_result_color");
cache.search_result_border_color=get_color("search_result_border_color");
+ cache.symbol_color=get_color("symbol_color");
+ cache.background_color=get_color("background_color");
cache.line_spacing=get_constant("line_spacing");
cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon=get_icon("tab");
@@ -3486,15 +3502,8 @@ void TextEdit::_update_caches() {
void TextEdit::clear_colors() {
keywords.clear();
- color_regions.clear();;
+ color_regions.clear();
text.clear_caches();
- custom_bg_color=Color(0,0,0,0);
-}
-
-void TextEdit::set_custom_bg_color(const Color& p_color) {
-
- custom_bg_color=p_color;
- update();
}
void TextEdit::add_keyword_color(const String& p_keyword,const Color& p_color) {
@@ -3512,12 +3521,6 @@ void TextEdit::add_color_region(const String& p_begin_key,const String& p_end_ke
}
-void TextEdit::set_symbol_color(const Color& p_color) {
-
- symbol_color=p_color;
- update();
-}
-
void TextEdit::set_syntax_coloring(bool p_enabled) {
syntax_coloring=p_enabled;
@@ -3780,7 +3783,7 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
if (col > 0 && _is_text_char(p_search[col-1])) {
col = -1;
- } else if (_is_text_char(p_search[col+p_key.length()])) {
+ } else if ((col + p_key.length()) < p_search.length() && _is_text_char(p_search[col+p_key.length()])) {
col = -1;
}
}
@@ -3791,11 +3794,11 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
return col;
}
-DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
+PoolVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
int col,line;
if (search(p_key,p_search_flags,p_from_line,p_from_column,col,line)) {
- DVector<int> result;
+ PoolVector<int> result;
result.resize(2);
result.set(0,line);
result.set(1,col);
@@ -3803,7 +3806,7 @@ DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags,
} else {
- return DVector<int>();
+ return PoolVector<int>();
}
}
@@ -4152,21 +4155,21 @@ void TextEdit::tag_saved_version() {
int TextEdit::get_v_scroll() const {
- return v_scroll->get_val();
+ return v_scroll->get_value();
}
void TextEdit::set_v_scroll(int p_scroll) {
- v_scroll->set_val(p_scroll);
+ v_scroll->set_value(p_scroll);
cursor.line_ofs=p_scroll;
}
int TextEdit::get_h_scroll() const {
- return h_scroll->get_val();
+ return h_scroll->get_value();
}
void TextEdit::set_h_scroll(int p_scroll) {
- h_scroll->set_val(p_scroll);
+ h_scroll->set_value(p_scroll);
}
void TextEdit::set_completion(bool p_enabled,const Vector<String>& p_prefixes) {
@@ -4197,12 +4200,17 @@ void TextEdit::_confirm_completion() {
void TextEdit::_cancel_code_hint() {
+
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ raised_from_completion = false;
completion_hint="";
update();
}
void TextEdit::_cancel_completion() {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ raised_from_completion = false;
if (!completion_active)
return;
@@ -4222,7 +4230,6 @@ void TextEdit::_update_completion_candidates() {
String l = text[cursor.line];
int cofs = CLAMP(cursor.column,0,l.length());
-
String s;
//look for keywords first
@@ -4271,14 +4278,14 @@ void TextEdit::_update_completion_candidates() {
while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
s=String::chr(l[cofs-1])+s;
- if (l[cofs-1]=='\'' || l[cofs-1]=='"')
+ if (l[cofs-1]=='\'' || l[cofs-1]=='"' || l[cofs-1]=='$')
break;
cofs--;
}
}
- 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_strings[0].begins_with("\"")) {
cancel = true;
}
@@ -4300,8 +4307,9 @@ void TextEdit::_update_completion_candidates() {
_cancel_completion();
return;
}
+
if (s.is_subsequence_ofi(completion_strings[i])) {
- // don't remove duplicates if no input is provided
+ // don't remove duplicates if no input is provided
if (s != "" && completion_options.find(completion_strings[i]) != -1) {
continue;
}
@@ -4337,6 +4345,7 @@ void TextEdit::_update_completion_candidates() {
if (completion_options.size()==0) {
//no options to complete, cancel
_cancel_completion();
+
return;
}
@@ -4348,7 +4357,7 @@ void TextEdit::_update_completion_candidates() {
if (completion_options.size()==1) {
//one option to complete, just complete it automagically
_confirm_completion();
- // insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
+ //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
_cancel_completion();
return;
@@ -4382,6 +4391,8 @@ void TextEdit::query_code_comple() {
void TextEdit::set_code_hint(const String& p_hint) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ raised_from_completion = true;
completion_hint=p_hint;
completion_hint_offset=-0xFFFF;
update();
@@ -4389,7 +4400,8 @@ void TextEdit::set_code_hint(const String& p_hint) {
void TextEdit::code_complete(const Vector<String> &p_strings) {
-
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ raised_from_completion = true;
completion_strings=p_strings;
completion_active=true;
completion_current="";
@@ -4500,10 +4512,26 @@ void TextEdit::set_show_line_numbers(bool p_show) {
update();
}
+void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
+
+ line_numbers_zero_padded=p_zero_padded;
+ update();
+}
+
bool TextEdit::is_show_line_numbers_enabled() const {
return line_numbers;
}
+void TextEdit::set_show_line_length_guideline(bool p_show) {
+ line_length_guideline=p_show;
+ update();
+}
+
+void TextEdit::set_line_length_guideline_column(int p_column) {
+ line_length_guideline_col=p_column;
+ update();
+}
+
void TextEdit::set_draw_breakpoint_gutter(bool p_draw) {
draw_breakpoint_gutter = p_draw;
update();
@@ -4569,6 +4597,9 @@ bool TextEdit::is_selecting_identifiers_on_hover_enabled() const {
return select_identifiers_enabled;
}
+void TextEdit::set_context_menu_enabled(bool p_enable) {
+ context_menu_enabled = p_enable;
+}
PopupMenu *TextEdit::get_menu() const {
return menu;
@@ -4577,90 +4608,90 @@ PopupMenu *TextEdit::get_menu() const {
void TextEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&TextEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&TextEdit::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
- ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
- ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
- ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
- ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
+ ClassDB::bind_method(_MD("_gui_input"),&TextEdit::_gui_input);
+ ClassDB::bind_method(_MD("_scroll_moved"),&TextEdit::_scroll_moved);
+ ClassDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
+ ClassDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
+ ClassDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
+ ClassDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
+ ClassDB::bind_method(_MD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
BIND_CONSTANT( SEARCH_MATCH_CASE );
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
BIND_CONSTANT( SEARCH_BACKWARDS );
/*
- ObjectTypeDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
- ObjectTypeDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
+ ClassDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
+ ClassDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
*/
- ObjectTypeDB::bind_method(_MD("set_text","text"),&TextEdit::set_text);
- ObjectTypeDB::bind_method(_MD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
-
- ObjectTypeDB::bind_method(_MD("get_line_count"),&TextEdit::get_line_count);
- ObjectTypeDB::bind_method(_MD("get_text"),&TextEdit::get_text);
- ObjectTypeDB::bind_method(_MD("get_line","line"),&TextEdit::get_line);
-
- ObjectTypeDB::bind_method(_MD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
-
- ObjectTypeDB::bind_method(_MD("cursor_get_column"),&TextEdit::cursor_get_column);
- ObjectTypeDB::bind_method(_MD("cursor_get_line"),&TextEdit::cursor_get_line);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
- ObjectTypeDB::bind_method(_MD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
-
- ObjectTypeDB::bind_method(_MD("set_readonly","enable"),&TextEdit::set_readonly);
- ObjectTypeDB::bind_method(_MD("set_wrap","enable"),&TextEdit::set_wrap);
- ObjectTypeDB::bind_method(_MD("set_max_chars","amount"),&TextEdit::set_max_chars);
-
- ObjectTypeDB::bind_method(_MD("cut"),&TextEdit::cut);
- ObjectTypeDB::bind_method(_MD("copy"),&TextEdit::copy);
- ObjectTypeDB::bind_method(_MD("paste"),&TextEdit::paste);
- ObjectTypeDB::bind_method(_MD("select_all"),&TextEdit::select_all);
- ObjectTypeDB::bind_method(_MD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
-
- ObjectTypeDB::bind_method(_MD("is_selection_active"),&TextEdit::is_selection_active);
- ObjectTypeDB::bind_method(_MD("get_selection_from_line"),&TextEdit::get_selection_from_line);
- ObjectTypeDB::bind_method(_MD("get_selection_from_column"),&TextEdit::get_selection_from_column);
- ObjectTypeDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
- ObjectTypeDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
- ObjectTypeDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
- ObjectTypeDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
- ObjectTypeDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
-
- ObjectTypeDB::bind_method(_MD("undo"),&TextEdit::undo);
- ObjectTypeDB::bind_method(_MD("redo"),&TextEdit::redo);
- ObjectTypeDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
-
- ObjectTypeDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
- ObjectTypeDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
- ObjectTypeDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
- ObjectTypeDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
-
-
- ObjectTypeDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
- ObjectTypeDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_symbol_color","color"),&TextEdit::set_symbol_color);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","color"),&TextEdit::set_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
- ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
- ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
+ ClassDB::bind_method(_MD("set_text","text"),&TextEdit::set_text);
+ ClassDB::bind_method(_MD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
+
+ ClassDB::bind_method(_MD("get_line_count"),&TextEdit::get_line_count);
+ ClassDB::bind_method(_MD("get_text"),&TextEdit::get_text);
+ ClassDB::bind_method(_MD("get_line","line"),&TextEdit::get_line);
+
+ ClassDB::bind_method(_MD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
+ ClassDB::bind_method(_MD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
+
+ ClassDB::bind_method(_MD("cursor_get_column"),&TextEdit::cursor_get_column);
+ ClassDB::bind_method(_MD("cursor_get_line"),&TextEdit::cursor_get_line);
+ ClassDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
+ ClassDB::bind_method(_MD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
+ ClassDB::bind_method(_MD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
+ ClassDB::bind_method(_MD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
+
+ ClassDB::bind_method(_MD("set_readonly","enable"),&TextEdit::set_readonly);
+ ClassDB::bind_method(_MD("set_wrap","enable"),&TextEdit::set_wrap);
+ ClassDB::bind_method(_MD("set_max_chars","amount"),&TextEdit::set_max_chars);
+
+ ClassDB::bind_method(_MD("cut"),&TextEdit::cut);
+ ClassDB::bind_method(_MD("copy"),&TextEdit::copy);
+ ClassDB::bind_method(_MD("paste"),&TextEdit::paste);
+ ClassDB::bind_method(_MD("select_all"),&TextEdit::select_all);
+ ClassDB::bind_method(_MD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
+
+ ClassDB::bind_method(_MD("is_selection_active"),&TextEdit::is_selection_active);
+ ClassDB::bind_method(_MD("get_selection_from_line"),&TextEdit::get_selection_from_line);
+ ClassDB::bind_method(_MD("get_selection_from_column"),&TextEdit::get_selection_from_column);
+ ClassDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
+ ClassDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
+ ClassDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
+ ClassDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
+ ClassDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
+
+ ClassDB::bind_method(_MD("undo"),&TextEdit::undo);
+ ClassDB::bind_method(_MD("redo"),&TextEdit::redo);
+ ClassDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
+
+ ClassDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
+ ClassDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
+
+ ClassDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
+ ClassDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
+
+ ClassDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
+ ClassDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
+
+
+ ClassDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
+ ClassDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
+ ClassDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
+ ClassDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
+ ClassDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), _SCS("set_syntax_coloring"), _SCS("is_syntax_coloring_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), _SCS("set_show_line_numbers"), _SCS("is_show_line_numbers_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), _SCS("set_highlight_all_occurrences"), _SCS("is_highlight_all_occurrences_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/block_caret"), _SCS("cursor_set_block_mode"), _SCS("cursor_is_block_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+
+ ADD_GROUP("Caret","caret_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), _SCS("cursor_set_block_mode"), _SCS("cursor_is_block_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
ADD_SIGNAL(MethodInfo("cursor_changed"));
ADD_SIGNAL(MethodInfo("text_changed"));
@@ -4677,6 +4708,7 @@ void TextEdit::_bind_methods() {
BIND_CONSTANT( MENU_MAX );
+ GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec",3);
}
TextEdit::TextEdit() {
@@ -4700,8 +4732,8 @@ TextEdit::TextEdit() {
tab_size=4;
text.set_tab_size(tab_size);
text.clear();
- // text.insert(1,"Mongolia..");
- // text.insert(2,"PAIS GENEROSO!!");
+ //text.insert(1,"Mongolia..");
+ //text.insert(2,"PAIS GENEROSO!!");
text.set_color_regions(&color_regions);
h_scroll = memnew( HScrollBar );
@@ -4734,11 +4766,10 @@ TextEdit::TextEdit() {
caret_blink_timer->connect("timeout", this,"_toggle_draw_caret");
cursor_set_blink_enabled(false);
- custom_bg_color=Color(0,0,0,0);
idle_detect = memnew( Timer );
add_child(idle_detect);
idle_detect->set_one_shot(true);
- idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
+ idle_detect->set_wait_time(GLOBAL_GET("gui/timers/text_edit_idle_detect_sec"));
idle_detect->connect("timeout", this,"_push_current_op");
click_select_held = memnew( Timer );
@@ -4778,6 +4809,9 @@ TextEdit::TextEdit() {
completion_line_ofs=0;
tooltip_obj=NULL;
line_numbers=false;
+ line_numbers_zero_padded=false;
+ line_length_guideline=false;
+ line_length_guideline_col=80;
draw_breakpoint_gutter=false;
next_operation_is_complex=false;
scroll_past_end_of_file_enabled=false;
@@ -4789,6 +4823,9 @@ TextEdit::TextEdit() {
window_has_focus=true;
select_identifiers_enabled=false;
+ raised_from_completion = false;
+
+ context_menu_enabled=true;
menu = memnew( PopupMenu );
add_child(menu);
menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
@@ -4799,7 +4836,7 @@ TextEdit::TextEdit() {
menu->add_item(TTR("Clear"),MENU_CLEAR);
menu->add_separator();
menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
- menu->connect("item_pressed",this,"menu_option");
+ menu->connect("id_pressed",this,"menu_option");
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index cb49618f18..6113fd72c2 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
class TextEdit : public Control {
- OBJ_TYPE( TextEdit, Control );
+ GDCLASS( TextEdit, Control );
struct Cursor {
int last_fit_x;
@@ -95,6 +95,8 @@ class TextEdit : public Control {
Color word_highlighted_color;
Color search_result_color;
Color search_result_border_color;
+ Color symbol_color;
+ Color background_color;
int row_height;
int line_spacing;
@@ -187,9 +189,7 @@ class TextEdit : public Control {
//syntax coloring
- Color symbol_color;
HashMap<String,Color> keywords;
- Color custom_bg_color;
Vector<ColorRegion> color_regions;
@@ -232,6 +232,9 @@ class TextEdit : public Control {
bool text_changed_dirty;
bool undo_enabled;
bool line_numbers;
+ bool line_numbers_zero_padded;
+ bool line_length_guideline;
+ int line_length_guideline_col;
bool draw_breakpoint_gutter;
int breakpoint_gutter_width;
@@ -244,6 +247,8 @@ class TextEdit : public Control {
bool insert_mode;
bool select_identifiers_enabled;
+ bool raised_from_completion;
+
String hilighted_word;
uint64_t last_dblclk;
@@ -269,6 +274,8 @@ class TextEdit : public Control {
int search_result_line;
int search_result_col;
+ bool context_menu_enabled;
+
int get_visible_rows() const;
int get_char_count();
@@ -287,7 +294,7 @@ class TextEdit : public Control {
void _scroll_lines_up();
void _scroll_lines_down();
-// void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
+ //void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
Size2 get_minimum_size() const;
int get_row_height() const;
@@ -309,7 +316,7 @@ class TextEdit : public Control {
int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column);
- DVector<int> _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const;
+ PoolVector<int> _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const;
PopupMenu *menu;
@@ -319,8 +326,6 @@ class TextEdit : public Control {
void _confirm_completion();
void _update_completion_candidates();
- void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
-
protected:
virtual String get_tooltip(const Point2& p_pos) const;
@@ -328,7 +333,7 @@ protected:
void _insert_text(int p_line, int p_column,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 _input_event(const InputEvent& p_input);
+ void _gui_input(const InputEvent& p_input);
void _notification(int p_what);
void _consume_pair_symbol(CharType ch);
@@ -360,6 +365,8 @@ public:
virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
+
//void delete_char();
//void delete_line();
@@ -464,8 +471,6 @@ public:
void add_keyword_color(const String& p_keyword,const Color& p_color);
void add_color_region(const String& p_begin_key=String(),const String& p_end_key=String(),const Color &p_color=Color(),bool p_line_only=false);
- void set_symbol_color(const Color& p_color);
- void set_custom_bg_color(const Color& p_color);
void clear_colors();
int get_v_scroll() const;
@@ -483,6 +488,11 @@ public:
void set_show_line_numbers(bool p_show);
bool is_show_line_numbers_enabled() const;
+ void set_line_numbers_zero_padded(bool p_zero_padded);
+
+ void set_show_line_length_guideline(bool p_show);
+ void set_line_length_guideline_column(int p_column);
+
void set_draw_breakpoint_gutter(bool p_draw);
bool is_drawing_breakpoint_gutter() const;
@@ -499,6 +509,7 @@ public:
void set_select_identifiers_on_hover(bool p_enable);
bool is_selecting_identifiers_on_hover_enabled() const;
+ void set_context_menu_enabled(bool p_enable);
PopupMenu *get_menu() const;
String get_text_for_completion();
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index df2f5edd48..03e37e9d9f 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -120,13 +120,13 @@ void TextureButton::_notification(int p_what) {
if (texdraw.is_valid()) {
Rect2 drect(Point2(),texdraw->get_size()*scale);
- draw_texture_rect(texdraw,drect,false,modulate);
+ draw_texture_rect(texdraw,drect,false);
}
if (has_focus() && focused.is_valid()) {
Rect2 drect(Point2(),focused->get_size()*scale);
- draw_texture_rect(focused,drect,false,modulate);
+ draw_texture_rect(focused,drect,false);
};
@@ -136,32 +136,30 @@ void TextureButton::_notification(int p_what) {
void TextureButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
- ObjectTypeDB::bind_method(_MD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
- ObjectTypeDB::bind_method(_MD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
- ObjectTypeDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
- ObjectTypeDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
- ObjectTypeDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate);
-
- ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
- ObjectTypeDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
- ObjectTypeDB::bind_method(_MD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
- ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
- ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
- ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate);
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
- ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ClassDB::bind_method(_MD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
+ ClassDB::bind_method(_MD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
+ ClassDB::bind_method(_MD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
+ ClassDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
+ ClassDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
+ ClassDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
+ ClassDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
+
+ ClassDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
+ ClassDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
+ ClassDB::bind_method(_MD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
+ ClassDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
+ ClassDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
+ ClassDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
+ ClassDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
+
+ ADD_GROUP("Textures","texture_");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"texture_scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
}
@@ -241,17 +239,7 @@ Size2 TextureButton::get_texture_scale() const{
return scale;
}
-void TextureButton::set_modulate(const Color& p_modulate) {
- modulate=p_modulate;
- update();
-}
-
-Color TextureButton::get_modulate() const {
- return modulate;
-}
-
-
TextureButton::TextureButton() {
scale=Size2(1.0, 1.0);
- modulate=Color(1,1,1);
+
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 0556df8061..ef4d4d5b5b 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
#include "scene/resources/bit_mask.h"
class TextureButton : public BaseButton {
- OBJ_TYPE( TextureButton, BaseButton );
+ GDCLASS( TextureButton, BaseButton );
Ref<Texture> normal;
Ref<Texture> pressed;
@@ -42,8 +42,6 @@ class TextureButton : public BaseButton {
Ref<Texture> focused;
Ref<BitMap> click_mask;
Size2 scale;
- Color modulate;
-
protected:
@@ -71,9 +69,6 @@ public:
void set_texture_scale(Size2 p_scale);
Size2 get_texture_scale() const;
- void set_modulate(const Color& p_modulate);
- Color get_modulate() const;
-
TextureButton();
};
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 2c576b6ba5..f6a33b5643 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -135,24 +135,24 @@ void TextureProgress::_notification(int p_what){
Size2 s = progress->get_size();
switch (mode) {
case FILL_LEFT_TO_RIGHT: {
- Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_RIGHT_TO_LEFT: {
- Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(s.x-s.x*get_as_ratio(),0),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_TOP_TO_BOTTOM: {
- Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_BOTTOM_TO_TOP: {
- Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(0,s.y-s.y*get_as_ratio()),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE: {
- float val=get_unit_value()*rad_max_degrees/360;
+ float val=get_as_ratio()*rad_max_degrees/360;
if (val==1) {
Rect2 region=Rect2(Point2(),s);
draw_texture_rect_region(progress,region,region);
@@ -192,7 +192,7 @@ void TextureProgress::_notification(int p_what){
}
} break;
default:
- draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)));
+ draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)),Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)));
}
@@ -255,34 +255,36 @@ Point2 TextureProgress::get_radial_center_offset()
void TextureProgress::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_under_texture","tex"),&TextureProgress::set_under_texture);
- ObjectTypeDB::bind_method(_MD("get_under_texture"),&TextureProgress::get_under_texture);
+ ClassDB::bind_method(_MD("set_under_texture","tex"),&TextureProgress::set_under_texture);
+ ClassDB::bind_method(_MD("get_under_texture"),&TextureProgress::get_under_texture);
- ObjectTypeDB::bind_method(_MD("set_progress_texture","tex"),&TextureProgress::set_progress_texture);
- ObjectTypeDB::bind_method(_MD("get_progress_texture"),&TextureProgress::get_progress_texture);
+ ClassDB::bind_method(_MD("set_progress_texture","tex"),&TextureProgress::set_progress_texture);
+ ClassDB::bind_method(_MD("get_progress_texture"),&TextureProgress::get_progress_texture);
- ObjectTypeDB::bind_method(_MD("set_over_texture","tex"),&TextureProgress::set_over_texture);
- ObjectTypeDB::bind_method(_MD("get_over_texture"),&TextureProgress::get_over_texture);
+ ClassDB::bind_method(_MD("set_over_texture","tex"),&TextureProgress::set_over_texture);
+ ClassDB::bind_method(_MD("get_over_texture"),&TextureProgress::get_over_texture);
- ObjectTypeDB::bind_method(_MD("set_fill_mode","mode"),&TextureProgress::set_fill_mode);
- ObjectTypeDB::bind_method(_MD("get_fill_mode"), &TextureProgress::get_fill_mode);
+ ClassDB::bind_method(_MD("set_fill_mode","mode"),&TextureProgress::set_fill_mode);
+ ClassDB::bind_method(_MD("get_fill_mode"), &TextureProgress::get_fill_mode);
- ObjectTypeDB::bind_method(_MD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
- ObjectTypeDB::bind_method(_MD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
+ ClassDB::bind_method(_MD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
+ ClassDB::bind_method(_MD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
- ObjectTypeDB::bind_method(_MD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
- ObjectTypeDB::bind_method(_MD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
+ ClassDB::bind_method(_MD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
+ ClassDB::bind_method(_MD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
- ObjectTypeDB::bind_method(_MD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
- ObjectTypeDB::bind_method(_MD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
+ ClassDB::bind_method(_MD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
+ ClassDB::bind_method(_MD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_under_texture"),_SCS("get_under_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_over_texture"),_SCS("get_over_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_progress_texture"),_SCS("get_progress_texture"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),_SCS("set_fill_mode"),_SCS("get_fill_mode"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill/initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_radial_initial_angle"),_SCS("get_radial_initial_angle"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill/fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_fill_degrees"),_SCS("get_fill_degrees"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_fill/center_offset"),_SCS("set_radial_center_offset"),_SCS("get_radial_center_offset"));
+ ADD_GROUP("Textures","texture_");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_under_texture"),_SCS("get_under_texture"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_over_texture"),_SCS("get_over_texture"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_progress_texture"),_SCS("get_progress_texture"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"fill_mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),_SCS("set_fill_mode"),_SCS("get_fill_mode"));
+ ADD_GROUP("Radial Fill","radial_");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_radial_initial_angle"),_SCS("get_radial_initial_angle"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_fill_degrees"),_SCS("get_fill_degrees"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_center_offset"),_SCS("set_radial_center_offset"),_SCS("get_radial_center_offset"));
BIND_CONSTANT( FILL_LEFT_TO_RIGHT );
BIND_CONSTANT( FILL_RIGHT_TO_LEFT );
diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h
index a4bbd71e94..02794354ef 100644
--- a/scene/gui/texture_progress.h
+++ b/scene/gui/texture_progress.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class TextureProgress : public Range {
- OBJ_TYPE( TextureProgress, Range );
+ GDCLASS( TextureProgress, Range );
Ref<Texture> under;
Ref<Texture> progress;
diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_rect.cpp
index 4aa45af863..cbb077ef5d 100644
--- a/scene/gui/texture_frame.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* texture_frame.cpp */
+/* texture_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,10 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "texture_frame.h"
+#include "texture_rect.h"
#include "servers/visual_server.h"
-void TextureFrame::_notification(int p_what) {
+void TextureRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -40,22 +40,22 @@ void TextureFrame::_notification(int p_what) {
switch(stretch_mode) {
case STRETCH_SCALE_ON_EXPAND: {
Size2 s=expand?get_size():texture->get_size();
- draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),s),false);
} break;
case STRETCH_SCALE: {
- draw_texture_rect(texture,Rect2(Point2(),get_size()),false,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),get_size()),false);
} break;
case STRETCH_TILE: {
- draw_texture_rect(texture,Rect2(Point2(),get_size()),true,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),get_size()),true);
} break;
case STRETCH_KEEP: {
- draw_texture_rect(texture,Rect2(Point2(),texture->get_size()),false,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),texture->get_size()),false);
} break;
case STRETCH_KEEP_CENTERED: {
Vector2 ofs = (get_size() - texture->get_size())/2;
- draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false,modulate);
+ draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false);
} break;
case STRETCH_KEEP_ASPECT_CENTERED:
case STRETCH_KEEP_ASPECT: {
@@ -85,27 +85,24 @@ void TextureFrame::_notification(int p_what) {
}
}
-Size2 TextureFrame::get_minimum_size() const {
+Size2 TextureRect::get_minimum_size() const {
if (!expand && !texture.is_null())
return texture->get_size();
else
return Size2();
}
-void TextureFrame::_bind_methods() {
+void TextureRect::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture"), & TextureFrame::set_texture );
- ObjectTypeDB::bind_method(_MD("get_texture"), & TextureFrame::get_texture );
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"), & TextureFrame::set_modulate );
- ObjectTypeDB::bind_method(_MD("get_modulate"), & TextureFrame::get_modulate );
- ObjectTypeDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand );
- ObjectTypeDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand );
- ObjectTypeDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureFrame::set_stretch_mode );
- ObjectTypeDB::bind_method(_MD("get_stretch_mode"), & TextureFrame::get_stretch_mode );
+ ClassDB::bind_method(_MD("set_texture","texture"), & TextureRect::set_texture );
+ ClassDB::bind_method(_MD("get_texture"), & TextureRect::get_texture );
+ ClassDB::bind_method(_MD("set_expand","enable"), & TextureRect::set_expand );
+ ClassDB::bind_method(_MD("has_expand"), & TextureRect::has_expand );
+ ClassDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureRect::set_stretch_mode );
+ ClassDB::bind_method(_MD("get_stretch_mode"), & TextureRect::get_stretch_mode );
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") );
@@ -120,65 +117,55 @@ void TextureFrame::_bind_methods() {
}
-void TextureFrame::set_texture(const Ref<Texture>& p_tex) {
+void TextureRect::set_texture(const Ref<Texture>& p_tex) {
texture=p_tex;
update();
- //if (texture.is_valid())
- // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ /*
+ if (texture.is_valid())
+ texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ */
minimum_size_changed();
}
-Ref<Texture> TextureFrame::get_texture() const {
+Ref<Texture> TextureRect::get_texture() const {
return texture;
}
-void TextureFrame::set_modulate(const Color& p_tex) {
- modulate=p_tex;
- update();
-}
-
-Color TextureFrame::get_modulate() const{
-
- return modulate;
-}
-
-
-void TextureFrame::set_expand(bool p_expand) {
+void TextureRect::set_expand(bool p_expand) {
expand=p_expand;
update();
minimum_size_changed();
}
-bool TextureFrame::has_expand() const {
+bool TextureRect::has_expand() const {
return expand;
}
-void TextureFrame::set_stretch_mode(StretchMode p_mode) {
+void TextureRect::set_stretch_mode(StretchMode p_mode) {
stretch_mode=p_mode;
update();
}
-TextureFrame::StretchMode TextureFrame::get_stretch_mode() const {
+TextureRect::StretchMode TextureRect::get_stretch_mode() const {
return stretch_mode;
}
-TextureFrame::TextureFrame() {
+TextureRect::TextureRect() {
expand=false;
- modulate=Color(1,1,1,1);
- set_ignore_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_IGNORE);
stretch_mode=STRETCH_SCALE_ON_EXPAND;
}
-TextureFrame::~TextureFrame()
+TextureRect::~TextureRect()
{
}
diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_rect.h
index 0b47202532..e95d742759 100644
--- a/scene/gui/texture_frame.h
+++ b/scene/gui/texture_rect.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* texture_frame.h */
+/* texture_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,9 +33,9 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class TextureFrame : public Control {
+class TextureRect : public Control {
- OBJ_TYPE(TextureFrame,Control);
+ GDCLASS(TextureRect,Control);
public:
enum StretchMode {
STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility
@@ -49,7 +49,6 @@ public:
};
private:
bool expand;
- Color modulate;
Ref<Texture> texture;
StretchMode stretch_mode;
protected:
@@ -63,8 +62,6 @@ public:
void set_texture(const Ref<Texture>& p_tex);
Ref<Texture> get_texture() const;
- void set_modulate(const Color& p_tex);
- Color get_modulate() const;
void set_expand(bool p_expand);
bool has_expand() const;
@@ -72,10 +69,10 @@ public:
void set_stretch_mode(StretchMode p_mode);
StretchMode get_stretch_mode() const;
- TextureFrame();
- ~TextureFrame();
+ TextureRect();
+ ~TextureRect();
};
-VARIANT_ENUM_CAST( TextureFrame::StretchMode );
+VARIANT_ENUM_CAST( TextureRect::StretchMode );
#endif // TEXTURE_FRAME_H
diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp
index fd27800384..817b506f10 100644
--- a/scene/gui/tool_button.cpp
+++ b/scene/gui/tool_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h
index f48d7d413c..ddeb34273b 100644
--- a/scene/gui/tool_button.h
+++ b/scene/gui/tool_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/gui/button.h"
class ToolButton : public Button {
- OBJ_TYPE(ToolButton,Button);
+ GDCLASS(ToolButton,Button);
public:
ToolButton();
};
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 20794b2faa..58c829690f 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "os/keyboard.h"
#include "globals.h"
#include "os/input.h"
+#include "scene/main/viewport.h"
@@ -568,6 +569,15 @@ void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){
}
+void TreeItem::set_button_color(int p_column,int p_idx,const Color& p_color) {
+
+ ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX( p_idx, cells[p_column].buttons.size() );
+ cells[p_column].buttons[p_idx].color=p_color;
+ _changed_notify(p_column);
+
+}
+
void TreeItem::set_editable(int p_column,bool p_editable) {
ERR_FAIL_INDEX( p_column, cells.size() );
@@ -647,76 +657,76 @@ Color TreeItem::get_custom_bg_color(int p_column) const {
void TreeItem::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
- ObjectTypeDB::bind_method(_MD("get_cell_mode","column"),&TreeItem::get_cell_mode);
+ ClassDB::bind_method(_MD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
+ ClassDB::bind_method(_MD("get_cell_mode","column"),&TreeItem::get_cell_mode);
- ObjectTypeDB::bind_method(_MD("set_checked","column","checked"),&TreeItem::set_checked);
- ObjectTypeDB::bind_method(_MD("is_checked","column"),&TreeItem::is_checked);
+ ClassDB::bind_method(_MD("set_checked","column","checked"),&TreeItem::set_checked);
+ ClassDB::bind_method(_MD("is_checked","column"),&TreeItem::is_checked);
- ObjectTypeDB::bind_method(_MD("set_text","column","text"),&TreeItem::set_text);
- ObjectTypeDB::bind_method(_MD("get_text","column"),&TreeItem::get_text);
+ ClassDB::bind_method(_MD("set_text","column","text"),&TreeItem::set_text);
+ ClassDB::bind_method(_MD("get_text","column"),&TreeItem::get_text);
- ObjectTypeDB::bind_method(_MD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","column"),&TreeItem::get_icon);
+ ClassDB::bind_method(_MD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
+ ClassDB::bind_method(_MD("get_icon:Texture","column"),&TreeItem::get_icon);
- ObjectTypeDB::bind_method(_MD("set_icon_region","column","region"),&TreeItem::set_icon_region);
- ObjectTypeDB::bind_method(_MD("get_icon_region","column"),&TreeItem::get_icon_region);
+ ClassDB::bind_method(_MD("set_icon_region","column","region"),&TreeItem::set_icon_region);
+ ClassDB::bind_method(_MD("get_icon_region","column"),&TreeItem::get_icon_region);
- ObjectTypeDB::bind_method(_MD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
- ObjectTypeDB::bind_method(_MD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
+ ClassDB::bind_method(_MD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
+ ClassDB::bind_method(_MD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
- ObjectTypeDB::bind_method(_MD("set_range","column","value"),&TreeItem::set_range);
- ObjectTypeDB::bind_method(_MD("get_range","column"),&TreeItem::get_range);
- ObjectTypeDB::bind_method(_MD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_range_config","column"),&TreeItem::_get_range_config);
+ ClassDB::bind_method(_MD("set_range","column","value"),&TreeItem::set_range);
+ ClassDB::bind_method(_MD("get_range","column"),&TreeItem::get_range);
+ ClassDB::bind_method(_MD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_range_config","column"),&TreeItem::_get_range_config);
- ObjectTypeDB::bind_method(_MD("set_metadata","column","meta"),&TreeItem::set_metadata);
- ObjectTypeDB::bind_method(_MD("get_metadata","column"),&TreeItem::get_metadata);
+ ClassDB::bind_method(_MD("set_metadata","column","meta"),&TreeItem::set_metadata);
+ ClassDB::bind_method(_MD("get_metadata","column"),&TreeItem::get_metadata);
- ObjectTypeDB::bind_method(_MD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
+ ClassDB::bind_method(_MD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
- ObjectTypeDB::bind_method(_MD("set_collapsed","enable"),&TreeItem::set_collapsed);
- ObjectTypeDB::bind_method(_MD("is_collapsed"),&TreeItem::is_collapsed);
+ ClassDB::bind_method(_MD("set_collapsed","enable"),&TreeItem::set_collapsed);
+ ClassDB::bind_method(_MD("is_collapsed"),&TreeItem::is_collapsed);
- ObjectTypeDB::bind_method(_MD("get_next:TreeItem"),&TreeItem::get_next);
- ObjectTypeDB::bind_method(_MD("get_prev:TreeItem"),&TreeItem::get_prev);
- ObjectTypeDB::bind_method(_MD("get_parent:TreeItem"),&TreeItem::get_parent);
- ObjectTypeDB::bind_method(_MD("get_children:TreeItem"),&TreeItem::get_children);
+ ClassDB::bind_method(_MD("get_next:TreeItem"),&TreeItem::get_next);
+ ClassDB::bind_method(_MD("get_prev:TreeItem"),&TreeItem::get_prev);
+ ClassDB::bind_method(_MD("get_parent:TreeItem"),&TreeItem::get_parent);
+ ClassDB::bind_method(_MD("get_children:TreeItem"),&TreeItem::get_children);
- ObjectTypeDB::bind_method(_MD("get_next_visible:TreeItem"),&TreeItem::get_next_visible);
- ObjectTypeDB::bind_method(_MD("get_prev_visible:TreeItem"),&TreeItem::get_prev_visible);
+ ClassDB::bind_method(_MD("get_next_visible:TreeItem"),&TreeItem::get_next_visible);
+ ClassDB::bind_method(_MD("get_prev_visible:TreeItem"),&TreeItem::get_prev_visible);
- ObjectTypeDB::bind_method(_MD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
+ ClassDB::bind_method(_MD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
- ObjectTypeDB::bind_method(_MD("set_selectable","column","selectable"),&TreeItem::set_selectable);
- ObjectTypeDB::bind_method(_MD("is_selectable","column"),&TreeItem::is_selectable);
+ ClassDB::bind_method(_MD("set_selectable","column","selectable"),&TreeItem::set_selectable);
+ ClassDB::bind_method(_MD("is_selectable","column"),&TreeItem::is_selectable);
- ObjectTypeDB::bind_method(_MD("is_selected","column"),&TreeItem::is_selected);
- ObjectTypeDB::bind_method(_MD("select","column"),&TreeItem::select);
- ObjectTypeDB::bind_method(_MD("deselect","column"),&TreeItem::deselect);
+ ClassDB::bind_method(_MD("is_selected","column"),&TreeItem::is_selected);
+ ClassDB::bind_method(_MD("select","column"),&TreeItem::select);
+ ClassDB::bind_method(_MD("deselect","column"),&TreeItem::deselect);
- ObjectTypeDB::bind_method(_MD("set_editable","column","enabled"),&TreeItem::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable","column"),&TreeItem::is_editable);
+ ClassDB::bind_method(_MD("set_editable","column","enabled"),&TreeItem::set_editable);
+ ClassDB::bind_method(_MD("is_editable","column"),&TreeItem::is_editable);
- ObjectTypeDB::bind_method(_MD("set_custom_color","column","color"),&TreeItem::set_custom_color);
- ObjectTypeDB::bind_method(_MD("clear_custom_color","column"),&TreeItem::clear_custom_color);
+ ClassDB::bind_method(_MD("set_custom_color","column","color"),&TreeItem::set_custom_color);
+ ClassDB::bind_method(_MD("clear_custom_color","column"),&TreeItem::clear_custom_color);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
+ ClassDB::bind_method(_MD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
+ ClassDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
+ ClassDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
- ObjectTypeDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
- ObjectTypeDB::bind_method(_MD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
- ObjectTypeDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
- ObjectTypeDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
+ ClassDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
+ ClassDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
+ ClassDB::bind_method(_MD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
+ ClassDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
+ ClassDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
- ObjectTypeDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
- ObjectTypeDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
+ ClassDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
+ ClassDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
- ObjectTypeDB::bind_method(_MD("move_to_top"),&TreeItem::move_to_top);
- ObjectTypeDB::bind_method(_MD("move_to_bottom"),&TreeItem::move_to_bottom);
+ ClassDB::bind_method(_MD("move_to_top"),&TreeItem::move_to_top);
+ ClassDB::bind_method(_MD("move_to_bottom"),&TreeItem::move_to_bottom);
BIND_CONSTANT( CELL_MODE_STRING );
BIND_CONSTANT( CELL_MODE_CHECK );
@@ -829,6 +839,8 @@ void Tree::update_cache() {
cache.guide_width=get_constant("guide_width");
cache.draw_relationship_lines=get_constant("draw_relationship_lines");
cache.relationship_line_color=get_color("relationship_line_color");
+ cache.scroll_border=get_constant("scroll_border");
+ cache.scroll_speed=get_constant("scroll_speed");
cache.title_button = get_stylebox("title_button_normal");
cache.title_button_pressed = get_stylebox("title_button_pressed");
@@ -937,8 +949,10 @@ void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,cons
}
-// if (p_tool)
-// rect.size.x-=Math::floor(rect.size.y/2);
+ /*
+ if (p_tool)
+ rect.size.x-=Math::floor(rect.size.y/2);
+ */
Ref<Font> font = cache.font;
@@ -1017,7 +1031,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
}
//draw separation.
-// if (p_item->get_parent()!=root || !hide_root)
+ //if (p_item->get_parent()!=root || !hide_root)
Ref<Font> font = cache.font;
@@ -1058,7 +1072,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
o.y+=(label_h-s.height)/2;
o+=cache.button_pressed->get_offset();
- b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):Color(1,1,1,1));
+ b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):p_item->cells[i].buttons[j].color);
w-=s.width+cache.button_margin;
bw+=s.width+cache.button_margin;
}
@@ -1103,7 +1117,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
} else {
cache.selected->draw(ci,r );
}
- if (text_editor->is_visible()){
+ if (text_editor->is_visible_in_tree()){
text_editor->set_pos(get_global_pos() + r.pos);
}
}
@@ -1250,7 +1264,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
} break;
case TreeItem::CELL_MODE_CUSTOM: {
- // int option = (int)p_item->cells[i].val;
+ //int option = (int)p_item->cells[i].val;
@@ -1328,7 +1342,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
int root_ofs = children_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
int parent_ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h/2)-cache.offset+p_draw_ofs;
- if (c->get_children() > 0)
+ if (c->get_children() != NULL)
root_pos -= Point2i(cache.arrow->get_width(),0);
Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width()/2, p_pos.y + label_h/2 + cache.arrow->get_height()/2)-cache.offset+p_draw_ofs;
@@ -1393,11 +1407,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (select_mode==SELECT_ROW) {
-
- if (p_selected==p_current) {
-
- if (!c.selected) {
-
+ if (p_selected==p_current && !c.selected) {
c.selected=true;
selected_item=p_selected;
selected_col=0;
@@ -1406,25 +1416,20 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
emit_signal("item_selected");
emitted_row=true;
}
- //if (p_col==i)
- // p_current->selected_signal.call(p_col);
- }
+ /*
+ if (p_col==i)
+ p_current->selected_signal.call(p_col);
+ */
- } else {
-
- if (c.selected) {
+ } else if (c.selected) {
c.selected=false;
//p_current->deselected_signal.call(p_col);
- }
-
}
-
} else if (select_mode==SELECT_SINGLE || select_mode==SELECT_MULTI) {
if (!r_in_range && &selected_cell==&c) {
-
if (!selected_cell.selected) {
selected_cell.selected=true;
@@ -1435,6 +1440,8 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
emit_signal("cell_selected");
if (select_mode==SELECT_MULTI)
emit_signal("multi_selected",p_current,i,true);
+ else if(select_mode == SELECT_SINGLE)
+ emit_signal("item_selected");
} else if (select_mode==SELECT_MULTI && (selected_item!=p_selected || selected_col!=i)) {
@@ -1669,9 +1676,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
}
}
- //if (!c.selected && select_mode==SELECT_MULTI) {
- // emit_signal("multi_selected",p_item,col,true);
- //}
+ /*
+ if (!c.selected && select_mode==SELECT_MULTI) {
+ emit_signal("multi_selected",p_item,col,true);
+ }
+ */
update();
}
@@ -1701,16 +1710,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
} break;
case TreeItem::CELL_MODE_CHECK: {
- Ref<Texture> checked = cache.checked;
bring_up_editor=false; //checkboxes are not edited with editor
- if (x>=0 && x<= checked->get_width()+cache.hseparation ) {
-
-
- p_item->set_checked(col,!c.checked);
- item_edited(col,p_item);
- click_handled=true;
- //p_item->edited_signal.call(col);
- }
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ click_handled = true;
+ //p_item->edited_signal.call(col);
} break;
case TreeItem::CELL_MODE_RANGE:
@@ -1957,7 +1961,7 @@ void Tree::popup_select(int p_option) {
-void Tree::_input_event(InputEvent p_event) {
+void Tree::_gui_input(InputEvent p_event) {
switch (p_event.type) {
@@ -1999,7 +2003,7 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case KEY_LEFT: {
-// TreeItem *next = NULL;
+ //TreeItem *next = NULL;
if (!selected_item)
break;
if (select_mode==SELECT_ROW)
@@ -2029,7 +2033,7 @@ void Tree::_input_event(InputEvent p_event) {
next=selected_item->get_next_visible();
-// if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
+ //if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
if (last_keypress!=0) {
//incr search next
int col;
@@ -2279,10 +2283,10 @@ void Tree::_input_event(InputEvent p_event) {
mpos.y-=_get_title_button_height();
if (mpos.y>=0) {
- if (h_scroll->is_visible())
- mpos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- mpos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ mpos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ mpos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,mpos,col,h,section);
@@ -2331,7 +2335,7 @@ void Tree::_input_event(InputEvent p_event) {
drag_accum-=b.relative_y;
- v_scroll->set_val(drag_from+drag_accum);
+ v_scroll->set_value(drag_from+drag_accum);
drag_speed=-b.speed_y;
}
@@ -2365,19 +2369,11 @@ void Tree::_input_event(InputEvent p_event) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
} else {
-
- if (delayed_text_editor) {
- uint64_t diff = OS::get_singleton()->get_ticks_msec() - first_selection_time;
- if (diff >= 400 && diff <= 800)
- edit_selected();
- // fast double click
- else if (diff < 400) {
- emit_signal("item_double_clicked");
- }
-
- first_selection_time = OS::get_singleton()->get_ticks_msec();
- } else {
+ Rect2 rect = get_selected()->get_meta("__focus_rect");
+ if (rect.has_point(Point2(p_event.mouse_button.x,p_event.mouse_button.y))) {
edit_selected();
+ } else {
+ emit_signal("item_double_clicked");
}
}
pressing_for_editor=false;
@@ -2415,6 +2411,9 @@ void Tree::_input_event(InputEvent p_event) {
}
+ if (range_drag_enabled)
+ break;
+
switch(b.button_index) {
case BUTTON_RIGHT:
case BUTTON_LEFT: {
@@ -2477,8 +2476,8 @@ void Tree::_input_event(InputEvent p_event) {
if (!click_handled) {
drag_speed=0;
drag_accum=0;
-// last_drag_accum=0;
- drag_from=v_scroll->get_val();
+ //last_drag_accum=0;
+ drag_from=v_scroll->get_value();
drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_touching_deaccel=false;
if (drag_touching) {
@@ -2490,11 +2489,11 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case BUTTON_WHEEL_UP: {
- v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
+ v_scroll->set_value( v_scroll->get_value()-v_scroll->get_page()/8 );
} break;
case BUTTON_WHEEL_DOWN: {
- v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
+ v_scroll->set_value( v_scroll->get_value()+v_scroll->get_page()/8 );
} break;
}
@@ -2573,8 +2572,8 @@ bool Tree::edit_selected() {
value_editor->set_min( c.min );
value_editor->set_max( c.max );
value_editor->set_step( c.step );
- value_editor->set_val( c.val );
- value_editor->set_exp_unit_value( c.expr );
+ value_editor->set_value( c.val );
+ value_editor->set_exp_ratio( c.expr );
updating_value_editor=false;
}
@@ -2633,7 +2632,7 @@ void Tree::update_scrollbars() {
v_scroll->show();
v_scroll->set_max(min.height);
v_scroll->set_page(size.height - hmin.height - tbh);
- cache.offset.y=v_scroll->get_val();
+ cache.offset.y=v_scroll->get_value();
}
if (min.width < size.width - vmin.width) {
@@ -2645,7 +2644,7 @@ void Tree::update_scrollbars() {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- cache.offset.x=h_scroll->get_val();
+ cache.offset.x=h_scroll->get_value();
}
}
@@ -2681,11 +2680,17 @@ void Tree::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAG_END) {
drop_mode_flags=0;
+ scrolling = false;
+ set_fixed_process(false);
update();
}
if (p_what==NOTIFICATION_DRAG_BEGIN) {
single_select_defer=NULL;
+ if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_pos() - get_global_pos())) {
+ scrolling = true;
+ set_fixed_process(true);
+ }
}
if (p_what==NOTIFICATION_FIXED_PROCESS) {
@@ -2693,7 +2698,7 @@ void Tree::_notification(int p_what) {
if (drag_touching_deaccel) {
- float pos = v_scroll->get_val();
+ float pos = v_scroll->get_value();
pos+=drag_speed*get_fixed_process_delta_time();
bool turnoff=false;
@@ -2710,7 +2715,7 @@ void Tree::_notification(int p_what) {
}
- v_scroll->set_val(pos);
+ v_scroll->set_value(pos);
float sgn = drag_speed<0? -1 : 1;
float val = Math::abs(drag_speed);
val-=1000*get_fixed_process_delta_time();
@@ -2731,6 +2736,28 @@ void Tree::_notification(int p_what) {
}
}
+
+ if (scrolling) {
+ Point2 point = get_viewport()->get_mouse_pos() - get_global_pos();
+ if (point.x < cache.scroll_border) {
+ point.x -= cache.scroll_border;
+ } else if (point.x > get_size().width - cache.scroll_border) {
+ point.x -= get_size().width - cache.scroll_border;
+ } else {
+ point.x = 0;
+ }
+ if (point.y < cache.scroll_border) {
+ point.y -= cache.scroll_border;
+ } else if (point.y > get_size().height - cache.scroll_border) {
+ point.y -= get_size().height - cache.scroll_border;
+ } else {
+ point.y = 0;
+ }
+ point *= cache.scroll_speed * get_fixed_process_delta_time();
+ point += get_scroll();
+ h_scroll->set_value(point.x);
+ v_scroll->set_value(point.y);
+ }
}
if (p_what==NOTIFICATION_DRAW) {
@@ -2739,8 +2766,6 @@ void Tree::_notification(int p_what) {
update_scrollbars();
RID ci = get_canvas_item();
- VisualServer::get_singleton()->canvas_item_set_clip(ci,true);
-
Ref<StyleBox> bg = cache.bg;
Ref<StyleBox> bg_focus = get_stylebox("bg_focus");
@@ -2768,13 +2793,10 @@ void Tree::_notification(int p_what) {
}
int ofs=0;
-// int from_y=exposed.pos.y+bg->get_margin(MARGIN_TOP);
-// int size_y=exposed.size.height-bg->get_minimum_size().height;
for (int i=0;i<(columns.size()-1-1);i++) {
ofs+=get_column_width(i);
- //get_painter()->draw_fill_rect( Point2(ofs+cache.hseparation/2, from_y), Size2( 1, size_y ),color( COLOR_TREE_GRID) );
}
if (show_column_titles) {
@@ -2895,8 +2917,6 @@ void Tree::item_selected(int p_column,TreeItem *p_item) {
p_item->cells[p_column].selected=true;
//emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select
- if (delayed_text_editor)
- first_selection_time = OS::get_singleton()->get_ticks_msec();
} else {
@@ -2907,8 +2927,7 @@ void Tree::item_selected(int p_column,TreeItem *p_item) {
void Tree::item_deselected(int p_column,TreeItem *p_item) {
- if (select_mode==SELECT_MULTI) {
-
+ if (select_mode==SELECT_MULTI || select_mode == SELECT_SINGLE) {
p_item->cells[p_column].selected=false;
}
update();
@@ -3000,8 +3019,10 @@ int Tree::get_edited_column() const {
TreeItem* Tree::get_next_selected( TreeItem* p_item) {
- //if (!p_item)
- // return NULL;
+ /*
+ if (!p_item)
+ return NULL;
+ */
if (!root)
return NULL;
@@ -3053,7 +3074,7 @@ int Tree::get_column_width(int p_column) const {
int expand_area=get_size().width-(bg->get_margin(MARGIN_LEFT)+bg->get_margin(MARGIN_RIGHT));
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
expand_area-=v_scroll->get_combined_minimum_size().width;
int expanding_columns=0;
@@ -3169,10 +3190,10 @@ void Tree::ensure_cursor_is_visible() {
int h = compute_item_height(selected)+cache.vseparation;
int screenh=get_size().height-h_scroll->get_combined_minimum_size().height;
- if (ofs+h>v_scroll->get_val()+screenh)
+ if (ofs+h>v_scroll->get_value()+screenh)
v_scroll->call_deferred("set_val", ofs-screenh+h);
- else if (ofs < v_scroll->get_val())
- v_scroll->set_val(ofs);
+ else if (ofs < v_scroll->get_value())
+ v_scroll->set_value(ofs);
}
int Tree::get_pressed_button() const {
@@ -3238,10 +3259,10 @@ String Tree::get_column_title(int p_column) const {
Point2 Tree::get_scroll() const {
Point2 ofs;
- if (h_scroll->is_visible())
- ofs.x=h_scroll->get_val();
- if (v_scroll->is_visible())
- ofs.y=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ ofs.x=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ ofs.y=v_scroll->get_value();
return ofs;
}
@@ -3284,7 +3305,7 @@ void Tree::_do_incr_search(const String& p_add) {
uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec
uint64_t diff = time - last_keypress;
- if (diff > uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000)))
+ if (diff > uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000)))
incr_search=p_add;
else
incr_search+=p_add;
@@ -3379,10 +3400,10 @@ int Tree::get_column_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return -1;
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3406,10 +3427,10 @@ int Tree::get_drop_section_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return -100;
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3433,10 +3454,10 @@ TreeItem* Tree::get_item_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return NULL;
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3461,10 +3482,10 @@ String Tree::get_tooltip(const Point2& p_pos) const {
if (pos.y<0)
return Control::get_tooltip(p_pos);
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3546,74 +3567,61 @@ bool Tree::get_allow_rmb_select() const{
}
-void Tree::set_delayed_text_editor(bool enabled) {
- delayed_text_editor = enabled;
-}
-
-bool Tree::is_delayed_text_editor_enabled() const {
- return delayed_text_editor;
-}
-
-
void Tree::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
- ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event);
- ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
- ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
- ObjectTypeDB::bind_method(_MD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
- ObjectTypeDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
-
- ObjectTypeDB::bind_method(_MD("clear"),&Tree::clear);
- ObjectTypeDB::bind_method(_MD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
-
- ObjectTypeDB::bind_method(_MD("get_root:TreeItem"),&Tree::get_root);
- ObjectTypeDB::bind_method(_MD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
- ObjectTypeDB::bind_method(_MD("set_column_expand","column","expand"),&Tree::set_column_expand);
- ObjectTypeDB::bind_method(_MD("get_column_width","column"),&Tree::get_column_width);
+ ClassDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
+ ClassDB::bind_method(_MD("_gui_input"),&Tree::_gui_input);
+ ClassDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
+ ClassDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
+ ClassDB::bind_method(_MD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
+ ClassDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
+ ClassDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("set_hide_root","enable"),&Tree::set_hide_root);
- ObjectTypeDB::bind_method(_MD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
- ObjectTypeDB::bind_method(_MD("get_selected:TreeItem"),&Tree::get_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_column"),&Tree::get_selected_column);
- ObjectTypeDB::bind_method(_MD("get_pressed_button"),&Tree::get_pressed_button);
- ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&Tree::set_select_mode);
+ ClassDB::bind_method(_MD("clear"),&Tree::clear);
+ ClassDB::bind_method(_MD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("set_columns","amount"),&Tree::set_columns);
- ObjectTypeDB::bind_method(_MD("get_columns"),&Tree::get_columns);
+ ClassDB::bind_method(_MD("get_root:TreeItem"),&Tree::get_root);
+ ClassDB::bind_method(_MD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
+ ClassDB::bind_method(_MD("set_column_expand","column","expand"),&Tree::set_column_expand);
+ ClassDB::bind_method(_MD("get_column_width","column"),&Tree::get_column_width);
- ObjectTypeDB::bind_method(_MD("get_edited:TreeItem"),&Tree::get_edited);
- ObjectTypeDB::bind_method(_MD("get_edited_column"),&Tree::get_edited_column);
- ObjectTypeDB::bind_method(_MD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
- ObjectTypeDB::bind_method(_MD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
- ObjectTypeDB::bind_method(_MD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
+ ClassDB::bind_method(_MD("set_hide_root","enable"),&Tree::set_hide_root);
+ ClassDB::bind_method(_MD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
+ ClassDB::bind_method(_MD("get_selected:TreeItem"),&Tree::get_selected);
+ ClassDB::bind_method(_MD("get_selected_column"),&Tree::get_selected_column);
+ ClassDB::bind_method(_MD("get_pressed_button"),&Tree::get_pressed_button);
+ ClassDB::bind_method(_MD("set_select_mode","mode"),&Tree::set_select_mode);
- ObjectTypeDB::bind_method(_MD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
+ ClassDB::bind_method(_MD("set_columns","amount"),&Tree::set_columns);
+ ClassDB::bind_method(_MD("get_columns"),&Tree::get_columns);
- ObjectTypeDB::bind_method(_MD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
- ObjectTypeDB::bind_method(_MD("are_column_titles_visible"),&Tree::are_column_titles_visible);
+ ClassDB::bind_method(_MD("get_edited:TreeItem"),&Tree::get_edited);
+ ClassDB::bind_method(_MD("get_edited_column"),&Tree::get_edited_column);
+ ClassDB::bind_method(_MD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
+ ClassDB::bind_method(_MD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
+ ClassDB::bind_method(_MD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
+ ClassDB::bind_method(_MD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
- ObjectTypeDB::bind_method(_MD("set_column_title","column","title"),&Tree::set_column_title);
- ObjectTypeDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
- ObjectTypeDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
+ ClassDB::bind_method(_MD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
- ObjectTypeDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
- ObjectTypeDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
+ ClassDB::bind_method(_MD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
+ ClassDB::bind_method(_MD("are_column_titles_visible"),&Tree::are_column_titles_visible);
- ObjectTypeDB::bind_method(_MD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
- ObjectTypeDB::bind_method(_MD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
+ ClassDB::bind_method(_MD("set_column_title","column","title"),&Tree::set_column_title);
+ ClassDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
+ ClassDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
- ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
+ ClassDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
+ ClassDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
- ObjectTypeDB::bind_method(_MD("set_delayed_text_editor","enable"),&Tree::set_delayed_text_editor);
- ObjectTypeDB::bind_method(_MD("is_delayed_text_editor_enabled"),&Tree::is_delayed_text_editor_enabled);
+ ClassDB::bind_method(_MD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
+ ClassDB::bind_method(_MD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
+ ClassDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
+ ClassDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
- ObjectTypeDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
ADD_SIGNAL( MethodInfo("item_selected"));
ADD_SIGNAL( MethodInfo("cell_selected"));
@@ -3682,8 +3690,8 @@ Tree::Tree() {
h_scroll->connect("value_changed", this,"_scroll_moved");
v_scroll->connect("value_changed", this,"_scroll_moved");
text_editor->connect("text_entered", this,"_text_editor_enter");
- text_editor->connect("modal_close", this,"_text_editor_modal_close");
- popup_menu->connect("item_pressed", this,"_popup_select");
+ text_editor->connect("modal_closed", this,"_text_editor_modal_close");
+ popup_menu->connect("id_pressed", this,"_popup_select");
value_editor->connect("value_changed", this,"_value_editor_changed");
value_editor->set_as_toplevel(true);
@@ -3706,7 +3714,7 @@ Tree::Tree() {
blocked=0;
cursor_can_exit_tree=true;
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
drag_speed=0;
drag_touching=false;
@@ -3726,8 +3734,7 @@ Tree::Tree() {
allow_rmb_select=false;
- first_selection_time = 0;
- delayed_text_editor = false;
+ set_clip_contents(true);
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 2124dce749..d715ff4772 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,7 +45,7 @@ class Tree;
class TreeItem : public Object {
- OBJ_TYPE(TreeItem,Object);
+ GDCLASS(TreeItem,Object);
public:
enum TreeCellMode {
@@ -93,7 +93,8 @@ friend class Tree;
int id;
bool disabled;
Ref<Texture> texture;
- Button() { id=0; disabled=false; }
+ Color color;
+ Button() { id=0; disabled=false; color=Color(1,1,1,1); }
};
Vector< Button > buttons;
@@ -189,6 +190,7 @@ public:
int get_button_by_id(int p_column,int p_id) const;
bool is_button_disabled(int p_column,int p_idx) const;
void set_button(int p_column,int p_idx,const Ref<Texture>& p_button);
+ void set_button_color(int p_column,int p_idx,const Color& p_color);
/* range works for mode number or mode combo */
@@ -255,7 +257,7 @@ VARIANT_ENUM_CAST( TreeItem::TreeCellMode );
class Tree : public Control {
- OBJ_TYPE( Tree, Control );
+ GDCLASS( Tree, Control );
public:
enum SelectMode {
SELECT_SINGLE,
@@ -332,7 +334,7 @@ friend class TreeItem;
int compute_item_height(TreeItem *p_item) const;
int get_item_height(TreeItem *p_item) const;
-// void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
+ //void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
void draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,const Color& p_color);
int draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& p_draw_size,TreeItem *p_item);
void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL,bool p_force_deselect=false);
@@ -343,7 +345,7 @@ friend class TreeItem;
void popup_select(int p_option);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
Size2 get_minimum_size() const;
@@ -390,6 +392,8 @@ friend class TreeItem;
int button_margin;
Point2 offset;
int draw_relationship_lines;
+ int scroll_border;
+ int scroll_speed;
enum ClickType {
CLICK_NONE,
@@ -437,9 +441,6 @@ friend class TreeItem;
float last_drag_time;
float time_since_motion;*/
- bool delayed_text_editor;
- uint64_t first_selection_time;
-
float drag_speed;
float drag_from;
float drag_accum;
@@ -448,6 +449,7 @@ friend class TreeItem;
bool drag_touching_deaccel;
bool click_handled;
bool allow_rmb_select;
+ bool scrolling;
bool force_select_on_already_selected;
@@ -534,9 +536,6 @@ public:
void set_value_evaluator(ValueEvaluator *p_evaluator);
- void set_delayed_text_editor(bool enabled);
- bool is_delayed_text_editor_enabled() const;
-
Tree();
~Tree();
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 1be847929d..4c177ea53c 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -121,7 +121,7 @@ void VideoPlayer::_notification(int p_notification) {
}
} break;
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (stream.is_null())
return;
@@ -233,7 +233,7 @@ void VideoPlayer::play() {
return;
playback->stop();
playback->play();
- set_process(true);
+ set_process_internal(true);
AudioServer::get_singleton()->stream_set_active(stream_rid,true);
AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
last_audio_time=0;
@@ -248,8 +248,8 @@ void VideoPlayer::stop() {
playback->stop();
AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- resampler.clear();
- set_process(false);
+ resampler.flush();
+ set_process_internal(false);
last_audio_time=0;
};
@@ -266,7 +266,7 @@ void VideoPlayer::set_paused(bool p_paused) {
paused=p_paused;
if (playback.is_valid()) {
playback->set_paused(p_paused);
- set_process(!p_paused);
+ set_process_internal(!p_paused);
};
last_audio_time = 0;
};
@@ -357,47 +357,47 @@ bool VideoPlayer::has_autoplay() const {
void VideoPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:VideoStream"),&VideoPlayer::get_stream);
+ ClassDB::bind_method(_MD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
+ ClassDB::bind_method(_MD("get_stream:VideoStream"),&VideoPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play"),&VideoPlayer::play);
- ObjectTypeDB::bind_method(_MD("stop"),&VideoPlayer::stop);
+ ClassDB::bind_method(_MD("play"),&VideoPlayer::play);
+ ClassDB::bind_method(_MD("stop"),&VideoPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&VideoPlayer::is_playing);
+ ClassDB::bind_method(_MD("is_playing"),&VideoPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&VideoPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&VideoPlayer::is_paused);
+ ClassDB::bind_method(_MD("set_paused","paused"),&VideoPlayer::set_paused);
+ ClassDB::bind_method(_MD("is_paused"),&VideoPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&VideoPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&VideoPlayer::get_volume);
+ ClassDB::bind_method(_MD("set_volume","volume"),&VideoPlayer::set_volume);
+ ClassDB::bind_method(_MD("get_volume"),&VideoPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&VideoPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&VideoPlayer::get_volume_db);
+ ClassDB::bind_method(_MD("set_volume_db","db"),&VideoPlayer::set_volume_db);
+ ClassDB::bind_method(_MD("get_volume_db"),&VideoPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_audio_track","track"),&VideoPlayer::set_audio_track);
- ObjectTypeDB::bind_method(_MD("get_audio_track"),&VideoPlayer::get_audio_track);
+ ClassDB::bind_method(_MD("set_audio_track","track"),&VideoPlayer::set_audio_track);
+ ClassDB::bind_method(_MD("get_audio_track"),&VideoPlayer::get_audio_track);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&VideoPlayer::get_stream_name);
+ ClassDB::bind_method(_MD("get_stream_name"),&VideoPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_stream_pos"),&VideoPlayer::get_stream_pos);
+ ClassDB::bind_method(_MD("get_stream_pos"),&VideoPlayer::get_stream_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&VideoPlayer::has_autoplay);
+ ClassDB::bind_method(_MD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
+ ClassDB::bind_method(_MD("has_autoplay"),&VideoPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("set_expand","enable"), &VideoPlayer::set_expand );
- ObjectTypeDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
+ ClassDB::bind_method(_MD("set_expand","enable"), &VideoPlayer::set_expand );
+ ClassDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
+ ClassDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
+ ClassDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
+ ClassDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
-// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
+ //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
}
@@ -426,5 +426,6 @@ VideoPlayer::~VideoPlayer() {
if (stream_rid.is_valid())
AudioServer::get_singleton()->free(stream_rid);
+ resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes
};
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 9ce1ba78f4..694cb253a4 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class VideoPlayer : public Control {
- OBJ_TYPE(VideoPlayer,Control);
+ GDCLASS(VideoPlayer,Control);
struct InternalStream : public AudioServer::AudioStream {
VideoPlayer *player;
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp
new file mode 100644
index 0000000000..9e89de66dd
--- /dev/null
+++ b/scene/gui/viewport_container.cpp
@@ -0,0 +1,103 @@
+#include "viewport_container.h"
+#include "scene/main/viewport.h"
+Size2 ViewportContainer::get_minimum_size() const {
+
+
+ if (stretch)
+ return Size2();
+ Size2 ms;
+ for(int i=0;i<get_child_count();i++) {
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+ Size2 minsize = c->get_size();
+ ms.width = MAX(ms.width , minsize.width);
+ ms.height = MAX(ms.height , minsize.height);
+ }
+
+ return ms;
+
+}
+
+
+void ViewportContainer::set_stretch(bool p_enable) {
+
+ stretch=p_enable;
+ queue_sort();
+ update();
+
+}
+
+bool ViewportContainer::is_stretch_enabled() const {
+
+ return stretch;
+}
+
+
+void ViewportContainer::_notification(int p_what) {
+
+
+ if (p_what==NOTIFICATION_RESIZED) {
+
+ if (!stretch)
+ return;
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+ c->set_size(get_size());
+ }
+ }
+
+ if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+
+ if (is_visible_in_tree())
+ c->set_update_mode(Viewport::UPDATE_ALWAYS);
+ else
+ c->set_update_mode(Viewport::UPDATE_DISABLED);
+ }
+
+ }
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ for(int i=0;i<get_child_count();i++) {
+
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+ if (stretch)
+ draw_texture_rect(c->get_texture(),Rect2(Vector2(),get_size()*Size2(1,-1)));
+ else
+ draw_texture_rect(c->get_texture(),Rect2(Vector2(),c->get_size()*Size2(1,-1)));
+ }
+ }
+
+}
+
+void ViewportContainer::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_stretch","enable"),&ViewportContainer::set_stretch);
+ ClassDB::bind_method(_MD("is_stretch_enabled"),&ViewportContainer::is_stretch_enabled);
+
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"stretch"),_SCS("set_stretch"),_SCS("is_stretch_enabled"));
+}
+
+ViewportContainer::ViewportContainer() {
+
+ stretch=false;
+}
diff --git a/scene/gui/viewport_container.h b/scene/gui/viewport_container.h
new file mode 100644
index 0000000000..632c54f2f4
--- /dev/null
+++ b/scene/gui/viewport_container.h
@@ -0,0 +1,25 @@
+#ifndef VIEWPORTCONTAINER_H
+#define VIEWPORTCONTAINER_H
+
+#include "scene/gui/container.h"
+
+class ViewportContainer : public Container {
+
+ GDCLASS( ViewportContainer, Container );
+
+ bool stretch;
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_stretch(bool p_enable);
+ bool is_stretch_enabled() const;
+
+ virtual Size2 get_minimum_size() const;
+
+ ViewportContainer();
+};
+
+#endif // VIEWPORTCONTAINER_H
diff --git a/scene/io/SCsub b/scene/io/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/io/SCsub
+++ b/scene/io/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+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
index f3a0eaa8c4..2d098d01f5 100644
--- a/scene/io/resource_format_image.cpp
+++ b/scene/io/resource_format_image.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
if (r_error)
*r_error=ERR_CANT_OPEN;
- if (p_path.extension()=="cube") {
+ if (p_path.get_extension()=="cube") {
// open as cubemap txture
CubeMap* ptr = memnew(CubeMap);
@@ -125,7 +125,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) {
- if (bool(Globals::get_singleton()->get("debug/max_texture_size_alert"))) {
+ if (bool(GlobalConfig::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!");
}
@@ -136,61 +136,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
#endif
- uint32_t flags=0;
-
- 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);
- }
-
-
- if (flags_found.has("filter")) {
- if (flags_found["filter"])
- flags|=Texture::FLAG_FILTER;
- } else if (bool(GLOBAL_DEF("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("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("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;
- }
+ uint32_t flags=load_image_flags(p_path);
if (debug_load_times)
begtime=OS::get_singleton()->get_ticks_usec();
@@ -214,9 +160,71 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
}
+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 ObjectTypeDB::is_type(p_type,"Texture") || ObjectTypeDB::is_type(p_type,"CubeMap");
+ 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 {
@@ -227,7 +235,7 @@ void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extens
String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const {
- String ext=p_path.extension().to_lower();
+ String ext=p_path.get_extension().to_lower();
if (ext=="cube")
return "CubeMap";
@@ -244,11 +252,11 @@ String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const
ResourceFormatLoaderImage::ResourceFormatLoaderImage() {
- max_texture_size = GLOBAL_DEF("debug/max_texture_size",0);
- GLOBAL_DEF("debug/max_texture_size_alert",false);
- debug_load_times=GLOBAL_DEF("debug/image_load_times",false);
- GLOBAL_DEF("image_loader/filter",true);
- GLOBAL_DEF("image_loader/gen_mipmaps",true);
- GLOBAL_DEF("image_loader/repeat",false);
+ 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);
}
diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h
index 6388aa641f..6e4ead2a0b 100644
--- a/scene/io/resource_format_image.h
+++ b/scene/io/resource_format_image.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,8 +39,8 @@ 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;
diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp
index 9cf349eb7b..0a19e6f72b 100644
--- a/scene/io/resource_format_wav.cpp
+++ b/scene/io/resource_format_wav.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -171,9 +171,9 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original
if (format_bits>8)
len*=2;
- DVector<uint8_t> data;
+ PoolVector<uint8_t> data;
data.resize(len);
- DVector<uint8_t>::Write dataw = data.write();
+ PoolVector<uint8_t>::Write dataw = data.write();
void * data_ptr = dataw.ptr();
for (int i=0;i<frames;i++) {
@@ -215,7 +215,7 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original
}
- dataw=DVector<uint8_t>::Write();
+ dataw=PoolVector<uint8_t>::Write();
sample->set_data(data);
@@ -267,7 +267,7 @@ bool ResourceFormatLoaderWAV::handles_type(const String& p_type) const {
String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="wav")
+ if (p_path.get_extension().to_lower()=="wav")
return "Sample";
return "";
}
diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h
index 4918d5c2e7..3a278b455b 100644
--- a/scene/io/resource_format_wav.h
+++ b/scene/io/resource_format_wav.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/main/SCsub b/scene/main/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/main/SCsub
+++ b/scene/main/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 8e238c7d77..84fe2a00f6 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,7 +43,7 @@ int CanvasLayer::get_layer() const{
return layer;
}
-void CanvasLayer::set_transform(const Matrix32& p_xform) {
+void CanvasLayer::set_transform(const Transform2D& p_xform) {
transform=p_xform;
locrotscale_dirty=true;
@@ -52,7 +52,7 @@ void CanvasLayer::set_transform(const Matrix32& p_xform) {
}
-Matrix32 CanvasLayer::get_transform() const {
+Transform2D CanvasLayer::get_transform() const {
return transform;
}
@@ -176,7 +176,7 @@ void CanvasLayer::_notification(int p_what) {
}
ERR_FAIL_COND(!vp);
- viewport=vp->get_viewport();
+ viewport=vp->get_viewport_rid();
VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
@@ -232,7 +232,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
else
vp=Node::get_viewport();
- viewport = vp->get_viewport();
+ viewport = vp->get_viewport_rid();
VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
@@ -246,37 +246,46 @@ Node* CanvasLayer::get_custom_viewport() const {
return custom_viewport;
}
+void CanvasLayer::reset_sort_index() {
+ sort_index=0;
+}
+
+int CanvasLayer::get_sort_index() {
+
+ return sort_index++;
+}
+
void CanvasLayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_layer","layer"),&CanvasLayer::set_layer);
- ObjectTypeDB::bind_method(_MD("get_layer"),&CanvasLayer::get_layer);
+ ClassDB::bind_method(_MD("set_layer","layer"),&CanvasLayer::set_layer);
+ ClassDB::bind_method(_MD("get_layer"),&CanvasLayer::get_layer);
- ObjectTypeDB::bind_method(_MD("set_transform","transform"),&CanvasLayer::set_transform);
- ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasLayer::get_transform);
+ ClassDB::bind_method(_MD("set_transform","transform"),&CanvasLayer::set_transform);
+ ClassDB::bind_method(_MD("get_transform"),&CanvasLayer::get_transform);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&CanvasLayer::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&CanvasLayer::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&CanvasLayer::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&CanvasLayer::get_offset);
- ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&CanvasLayer::set_rotation);
- ObjectTypeDB::bind_method(_MD("get_rotation"),&CanvasLayer::get_rotation);
+ ClassDB::bind_method(_MD("set_rotation","radians"),&CanvasLayer::set_rotation);
+ ClassDB::bind_method(_MD("get_rotation"),&CanvasLayer::get_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotationd","degrees"),&CanvasLayer::set_rotationd);
- ObjectTypeDB::bind_method(_MD("get_rotationd"),&CanvasLayer::get_rotationd);
+ ClassDB::bind_method(_MD("set_rotationd","degrees"),&CanvasLayer::set_rotationd);
+ ClassDB::bind_method(_MD("get_rotationd"),&CanvasLayer::get_rotationd);
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotationd","degrees"),&CanvasLayer::_set_rotationd);
- ObjectTypeDB::bind_method(_MD("_get_rotationd"),&CanvasLayer::_get_rotationd);
+ ClassDB::bind_method(_MD("_set_rotationd","degrees"),&CanvasLayer::_set_rotationd);
+ ClassDB::bind_method(_MD("_get_rotationd"),&CanvasLayer::_get_rotationd);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&CanvasLayer::set_scale);
- ObjectTypeDB::bind_method(_MD("get_scale"),&CanvasLayer::get_scale);
+ ClassDB::bind_method(_MD("set_scale","scale"),&CanvasLayer::set_scale);
+ ClassDB::bind_method(_MD("get_scale"),&CanvasLayer::get_scale);
- ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&CanvasLayer::set_custom_viewport);
- ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&CanvasLayer::get_custom_viewport);
+ ClassDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&CanvasLayer::set_custom_viewport);
+ ClassDB::bind_method(_MD("get_custom_viewport:Viewport"),&CanvasLayer::get_custom_viewport);
- ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"),&CanvasLayer::get_world_2d);
-// ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
+ ClassDB::bind_method(_MD("get_world_2d:World2D"),&CanvasLayer::get_world_2d);
+ //ClassDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
ADD_PROPERTY( PropertyInfo(Variant::INT,"layer",PROPERTY_HINT_RANGE,"-128,128,1"),_SCS("set_layer"),_SCS("get_layer") );
//ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),_SCS("set_transform"),_SCS("get_transform") );
@@ -296,4 +305,5 @@ CanvasLayer::CanvasLayer() {
canvas = Ref<World2D>( memnew(World2D) );
custom_viewport=NULL;
custom_viewport_id=0;
+ sort_index=0;
}
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index a1311390be..8efbbd5a05 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,14 +36,14 @@
class Viewport;
class CanvasLayer : public Node {
- OBJ_TYPE( CanvasLayer, Node );
+ GDCLASS( CanvasLayer, Node );
bool locrotscale_dirty;
Vector2 ofs;
Size2 scale;
real_t rot;
int layer;
- Matrix32 transform;
+ Transform2D transform;
Ref<World2D> canvas;
ObjectID custom_viewport_id; // to check validity
@@ -52,6 +52,8 @@ class CanvasLayer : public Node {
RID viewport;
Viewport *vp;
+ int sort_index;
+
// Deprecated, should be removed in a future version.
void _set_rotationd(real_t p_rotation);
real_t _get_rotationd() const;
@@ -69,8 +71,8 @@ public:
void set_layer(int p_xform);
int get_layer() const;
- void set_transform(const Matrix32& p_xform);
- Matrix32 get_transform() const;
+ void set_transform(const Transform2D& p_xform);
+ Transform2D get_transform() const;
void set_offset(const Vector2& p_offset);
Vector2 get_offset() const;
@@ -93,6 +95,9 @@ public:
void set_custom_viewport(Node *p_viewport);
Node* get_custom_viewport() const;
+ void reset_sort_index();
+ int get_sort_index();
+
CanvasLayer();
};
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index c713b5e4dc..63a81a139d 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,6 +28,10 @@
/*************************************************************************/
#include "http_request.h"
+void HTTPRequest::set_ip_type(IP::Type p_type) {
+ client->set_ip_type(p_type);
+}
+
void HTTPRequest::_redirect_request(const String& p_new_url) {
@@ -35,8 +39,8 @@ void HTTPRequest::_redirect_request(const String& p_new_url) {
Error HTTPRequest::_request() {
- print_line("Requesting:\n\tURL: "+url+"\n\tString: "+request_string+"\n\tPort: "+itos(port)+"\n\tSSL: "+itos(use_ssl)+"\n\tValidate SSL: "+itos(validate_ssl));
- return client->connect(url,port,use_ssl,validate_ssl);
+ //print_line("Requesting:\n\tURL: "+url+"\n\tString: "+request_string+"\n\tPort: "+itos(port)+"\n\tSSL: "+itos(use_ssl)+"\n\tValidate SSL: "+itos(validate_ssl));
+ return client->connect_to_host(url,port,use_ssl,validate_ssl);
}
Error HTTPRequest::_parse_url(const String& p_url) {
@@ -53,36 +57,36 @@ Error HTTPRequest::_parse_url(const String& p_url) {
downloaded=0;
redirections=0;
- print_line("1 url: "+url);
+ //print_line("1 url: "+url);
if (url.begins_with("http://")) {
url=url.substr(7,url.length()-7);
- print_line("no SSL");
+ //print_line("no SSL");
} else if (url.begins_with("https://")) {
url=url.substr(8,url.length()-8);
use_ssl=true;
port=443;
- print_line("yes SSL");
+ //print_line("yes SSL");
} else {
ERR_EXPLAIN("Malformed URL");
ERR_FAIL_V(ERR_INVALID_PARAMETER);
}
- print_line("2 url: "+url);
+ //print_line("2 url: "+url);
int slash_pos = url.find("/");
if (slash_pos!=-1) {
request_string=url.substr(slash_pos,url.length());
url=url.substr(0,slash_pos);
- print_line("request string: "+request_string);
+ //print_line("request string: "+request_string);
} else {
request_string="/";
- print_line("no request");
+ //print_line("no request");
}
- print_line("3 url: "+url);
+ //print_line("3 url: "+url);
int colon_pos = url.find(":");
if (colon_pos!=-1) {
@@ -91,7 +95,7 @@ Error HTTPRequest::_parse_url(const String& p_url) {
ERR_FAIL_COND_V(port<1 || port > 65535,ERR_INVALID_PARAMETER);
}
- print_line("4 url: "+url);
+ //print_line("4 url: "+url);
return OK;
}
@@ -146,11 +150,11 @@ Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_h
client->set_blocking_mode(false);
err = _request();
if (err!=OK) {
- call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_CANT_CONNECT,0,PoolStringArray(),PoolByteArray());
return ERR_CANT_CONNECT;
}
- set_process(true);
+ set_process_internal(true);
}
@@ -166,7 +170,7 @@ void HTTPRequest::_thread_func(void *p_userdata) {
Error err = hr->_request();
if (err!=OK) {
- hr->call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ hr->call_deferred("_request_done",RESULT_CANT_CONNECT,0,PoolStringArray(),PoolByteArray());
} else {
while(!hr->thread_request_quit) {
@@ -186,7 +190,7 @@ void HTTPRequest::cancel_request() {
return;
if (!use_threads) {
- set_process(false);
+ set_process_internal(false);
} else {
thread_request_quit=true;
Thread::wait_to_finish(thread);
@@ -212,7 +216,7 @@ void HTTPRequest::cancel_request() {
bool HTTPRequest::_handle_response(bool *ret_value) {
if (!client->has_response()) {
- call_deferred("_request_done",RESULT_NO_RESPONSE,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_NO_RESPONSE,0,PoolStringArray(),PoolByteArray());
*ret_value=true;
return true;
}
@@ -224,7 +228,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
response_headers.resize(0);
downloaded=0;
for (List<String>::Element *E=rheaders.front();E;E=E->next()) {
- print_line("HEADER: "+E->get());
+ //print_line("HEADER: "+E->get());
response_headers.push_back(E->get());
}
@@ -232,7 +236,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
//redirect
if (max_redirects>=0 && redirections>=max_redirects) {
- call_deferred("_request_done",RESULT_REDIRECT_LIMIT_REACHED,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_REDIRECT_LIMIT_REACHED,response_code,response_headers,PoolByteArray());
*ret_value=true;
return true;
}
@@ -245,7 +249,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
}
}
- print_line("NEW LOCATION: "+new_request);
+ //print_line("NEW LOCATION: "+new_request);
if (new_request!="") {
//process redirect
@@ -261,7 +265,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
err = _request();
- print_line("new connection: "+itos(err));
+ //print_line("new connection: "+itos(err));
if (err==OK) {
request_sent=false;
got_response=false;
@@ -284,7 +288,7 @@ bool HTTPRequest::_update_connection() {
switch( client->get_status() ) {
case HTTPClient::STATUS_DISCONNECTED: {
- call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_CANT_CONNECT,0,PoolStringArray(),PoolByteArray());
return true; //end it, since it's doing something
} break;
case HTTPClient::STATUS_RESOLVING: {
@@ -293,7 +297,7 @@ bool HTTPRequest::_update_connection() {
return false;
} break;
case HTTPClient::STATUS_CANT_RESOLVE: {
- call_deferred("_request_done",RESULT_CANT_RESOLVE,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_CANT_RESOLVE,0,PoolStringArray(),PoolByteArray());
return true;
} break;
@@ -304,7 +308,7 @@ bool HTTPRequest::_update_connection() {
} break; //connecting to ip
case HTTPClient::STATUS_CANT_CONNECT: {
- call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_CANT_CONNECT,0,PoolStringArray(),PoolByteArray());
return true;
} break;
@@ -322,7 +326,7 @@ bool HTTPRequest::_update_connection() {
return ret_value;
- call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,PoolByteArray());
return true;
}
if (got_response && body_len<0) {
@@ -332,7 +336,7 @@ bool HTTPRequest::_update_connection() {
}
- call_deferred("_request_done",RESULT_CHUNKED_BODY_SIZE_MISMATCH,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_CHUNKED_BODY_SIZE_MISMATCH,response_code,response_headers,PoolByteArray());
return true;
//request migh have been done
} else {
@@ -340,7 +344,7 @@ bool HTTPRequest::_update_connection() {
Error err = client->request(method,request_string,headers,request_data);
if (err!=OK) {
- call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,PoolStringArray(),PoolByteArray());
return true;
}
@@ -366,7 +370,7 @@ bool HTTPRequest::_update_connection() {
if (!client->is_response_chunked() && client->get_response_body_length()==0) {
- call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,PoolByteArray());
return true;
}
@@ -377,7 +381,7 @@ bool HTTPRequest::_update_connection() {
body_len=client->get_response_body_length();
if (body_size_limit>=0 && body_len>body_size_limit) {
- call_deferred("_request_done",RESULT_BODY_SIZE_LIMIT_EXCEEDED,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_BODY_SIZE_LIMIT_EXCEEDED,response_code,response_headers,PoolByteArray());
return true;
}
}
@@ -386,7 +390,7 @@ bool HTTPRequest::_update_connection() {
file=FileAccess::open(download_to_file,FileAccess::WRITE);
if (!file) {
- call_deferred("_request_done",RESULT_DOWNLOAD_FILE_CANT_OPEN,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_DOWNLOAD_FILE_CANT_OPEN,response_code,response_headers,PoolByteArray());
return true;
}
}
@@ -396,14 +400,14 @@ bool HTTPRequest::_update_connection() {
//print_line("BODY: "+itos(body.size()));
client->poll();
- ByteArray chunk = client->read_response_body_chunk();
+ PoolByteArray chunk = client->read_response_body_chunk();
downloaded+=chunk.size();
if (file) {
- ByteArray::Read r=chunk.read();
+ PoolByteArray::Read r=chunk.read();
file->store_buffer(r.ptr(),chunk.size());
if (file->get_error()!=OK) {
- call_deferred("_request_done",RESULT_DOWNLOAD_FILE_WRITE_ERROR,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_DOWNLOAD_FILE_WRITE_ERROR,response_code,response_headers,PoolByteArray());
return true;
}
} else {
@@ -411,7 +415,7 @@ bool HTTPRequest::_update_connection() {
}
if (body_size_limit>=0 && downloaded>body_size_limit) {
- call_deferred("_request_done",RESULT_BODY_SIZE_LIMIT_EXCEEDED,response_code,response_headers,ByteArray());
+ call_deferred("_request_done",RESULT_BODY_SIZE_LIMIT_EXCEEDED,response_code,response_headers,PoolByteArray());
return true;
}
@@ -431,11 +435,11 @@ bool HTTPRequest::_update_connection() {
} break; // request resulted in body: { } break which must be read
case HTTPClient::STATUS_CONNECTION_ERROR: {
- call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,PoolStringArray(),PoolByteArray());
return true;
} break;
case HTTPClient::STATUS_SSL_HANDSHAKE_ERROR: {
- call_deferred("_request_done",RESULT_SSL_HANDSHAKE_ERROR,0,StringArray(),ByteArray());
+ call_deferred("_request_done",RESULT_SSL_HANDSHAKE_ERROR,0,PoolStringArray(),PoolByteArray());
return true;
} break;
@@ -445,7 +449,7 @@ bool HTTPRequest::_update_connection() {
}
-void HTTPRequest::_request_done(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data) {
+void HTTPRequest::_request_done(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data) {
cancel_request();
@@ -455,14 +459,14 @@ void HTTPRequest::_request_done(int p_status, int p_code, const StringArray& hea
void HTTPRequest::_notification(int p_what) {
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what==NOTIFICATION_INTERNAL_PROCESS) {
if (use_threads)
return;
bool done = _update_connection();
if (done) {
- set_process(false);
+ set_process_internal(false);
//cancel_request(); called from _request done now
}
}
@@ -535,34 +539,35 @@ int HTTPRequest::get_body_size() const{
void HTTPRequest::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("request","url","custom_headers","ssl_validate_domain","method","request_data"),&HTTPRequest::request,DEFVAL(StringArray()),DEFVAL(true),DEFVAL(HTTPClient::METHOD_GET),DEFVAL(String()));
- ObjectTypeDB::bind_method(_MD("cancel_request"),&HTTPRequest::cancel_request);
+ ClassDB::bind_method(_MD("set_ip_type","ip_type"),&HTTPRequest::set_ip_type);
+ ClassDB::bind_method(_MD("request","url","custom_headers","ssl_validate_domain","method","request_data"),&HTTPRequest::request,DEFVAL(PoolStringArray()),DEFVAL(true),DEFVAL(HTTPClient::METHOD_GET),DEFVAL(String()));
+ ClassDB::bind_method(_MD("cancel_request"),&HTTPRequest::cancel_request);
- ObjectTypeDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
+ ClassDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
- ObjectTypeDB::bind_method(_MD("set_use_threads","enable"),&HTTPRequest::set_use_threads);
- ObjectTypeDB::bind_method(_MD("is_using_threads"),&HTTPRequest::is_using_threads);
+ ClassDB::bind_method(_MD("set_use_threads","enable"),&HTTPRequest::set_use_threads);
+ ClassDB::bind_method(_MD("is_using_threads"),&HTTPRequest::is_using_threads);
- ObjectTypeDB::bind_method(_MD("set_body_size_limit","bytes"),&HTTPRequest::set_body_size_limit);
- ObjectTypeDB::bind_method(_MD("get_body_size_limit"),&HTTPRequest::get_body_size_limit);
+ ClassDB::bind_method(_MD("set_body_size_limit","bytes"),&HTTPRequest::set_body_size_limit);
+ ClassDB::bind_method(_MD("get_body_size_limit"),&HTTPRequest::get_body_size_limit);
- ObjectTypeDB::bind_method(_MD("set_max_redirects","amount"),&HTTPRequest::set_max_redirects);
- ObjectTypeDB::bind_method(_MD("get_max_redirects"),&HTTPRequest::get_max_redirects);
+ ClassDB::bind_method(_MD("set_max_redirects","amount"),&HTTPRequest::set_max_redirects);
+ ClassDB::bind_method(_MD("get_max_redirects"),&HTTPRequest::get_max_redirects);
- ObjectTypeDB::bind_method(_MD("set_download_file","path"),&HTTPRequest::set_download_file);
- ObjectTypeDB::bind_method(_MD("get_download_file"),&HTTPRequest::get_download_file);
+ ClassDB::bind_method(_MD("set_download_file","path"),&HTTPRequest::set_download_file);
+ ClassDB::bind_method(_MD("get_download_file"),&HTTPRequest::get_download_file);
- ObjectTypeDB::bind_method(_MD("get_downloaded_bytes"),&HTTPRequest::get_downloaded_bytes);
- ObjectTypeDB::bind_method(_MD("get_body_size"),&HTTPRequest::get_body_size);
+ ClassDB::bind_method(_MD("get_downloaded_bytes"),&HTTPRequest::get_downloaded_bytes);
+ ClassDB::bind_method(_MD("get_body_size"),&HTTPRequest::get_body_size);
- ObjectTypeDB::bind_method(_MD("_redirect_request"),&HTTPRequest::_redirect_request);
- ObjectTypeDB::bind_method(_MD("_request_done"),&HTTPRequest::_request_done);
+ ClassDB::bind_method(_MD("_redirect_request"),&HTTPRequest::_redirect_request);
+ ClassDB::bind_method(_MD("_request_done"),&HTTPRequest::_request_done);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_threads"),_SCS("set_use_threads"),_SCS("is_using_threads"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"body_size_limit",PROPERTY_HINT_RANGE,"-1,2000000000"),_SCS("set_body_size_limit"),_SCS("get_body_size_limit"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"max_redirects",PROPERTY_HINT_RANGE,"-1,1024"),_SCS("set_max_redirects"),_SCS("get_max_redirects"));
- ADD_SIGNAL(MethodInfo("request_completed",PropertyInfo(Variant::INT,"result"),PropertyInfo(Variant::INT,"response_code"),PropertyInfo(Variant::STRING_ARRAY,"headers"),PropertyInfo(Variant::RAW_ARRAY,"body")));
+ 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 );
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 705799f044..51c5ddeb69 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
class HTTPRequest : public Node {
- OBJ_TYPE(HTTPRequest,Node);
+ GDCLASS(HTTPRequest,Node);
public:
enum Result {
@@ -71,12 +71,12 @@ private:
bool request_sent;
Ref<HTTPClient> client;
- ByteArray body;
+ PoolByteArray body;
volatile bool use_threads;
bool got_response;
int response_code;
- DVector<String> response_headers;
+ PoolVector<String> response_headers;
String download_to_file;
@@ -107,7 +107,7 @@ private:
Thread *thread;
- void _request_done(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data);
+ void _request_done(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data);
static void _thread_func(void *p_userdata);
protected:
@@ -116,6 +116,7 @@ protected:
static void _bind_methods();
public:
+ void set_ip_type(IP::Type p_type);
Error request(const String& p_url, const Vector<String>& p_custom_headers=Vector<String>(), bool p_ssl_validate_domain=true, HTTPClient::Method p_method=HTTPClient::METHOD_GET, const String& p_request_data=""); //connects to a full url and perform request
void cancel_request();
HTTPClient::Status get_http_client_status() const;
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index fb047ea5e4..5d1b0495c0 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -101,13 +101,30 @@ void InstancePlaceholder::replace_by_instance(const Ref<PackedScene> &p_custom_s
base->remove_child(this);
base->add_child(scene);
base->move_child(scene,pos);
-
}
+Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
+
+ Dictionary ret;
+ PoolStringArray order;
+
+ for(List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
+ ret[E->get().name] = E->get().value;
+ if (p_with_order)
+ order.push_back(E->get().name);
+ };
+
+ if (p_with_order)
+ ret[".order"] = order;
+
+ return ret;
+};
+
void InstancePlaceholder::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("replace_by_instance","custom_scene:PackedScene"),&InstancePlaceholder::replace_by_instance,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("get_instance_path"),&InstancePlaceholder::get_instance_path);
+ ClassDB::bind_method(_MD("get_stored_values","with_order"),&InstancePlaceholder::get_stored_values,DEFVAL(false));
+ ClassDB::bind_method(_MD("replace_by_instance","custom_scene:PackedScene"),&InstancePlaceholder::replace_by_instance,DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("get_instance_path"),&InstancePlaceholder::get_instance_path);
}
InstancePlaceholder::InstancePlaceholder() {
diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h
index ef76686196..069b1c9756 100644
--- a/scene/main/instance_placeholder.h
+++ b/scene/main/instance_placeholder.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@ class PackedScene;
class InstancePlaceholder : public Node {
- OBJ_TYPE(InstancePlaceholder,Node);
+ GDCLASS(InstancePlaceholder,Node);
String path;
struct PropSet {
@@ -57,6 +57,8 @@ public:
void set_instance_path(const String& p_name);
String get_instance_path() const;
+ Dictionary get_stored_values(bool p_with_order = false);
+
void replace_by_instance(const Ref<PackedScene>& p_custom_scene=Ref<PackedScene>());
InstancePlaceholder();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 1892240426..86b78f60f6 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,6 +89,7 @@ void Node::_notification(int p_notification) {
data.network_owner=this;
}
+
if (data.input)
add_to_group("_vp_input"+itos(get_viewport()->get_instance_ID()));
if (data.unhandled_input)
@@ -128,6 +129,26 @@ void Node::_notification(int p_notification) {
if (get_script_instance()) {
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_input)) {
+ set_process_input(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_unhandled_input)) {
+ set_process_unhandled_input(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_unhandled_key_input)) {
+ set_process_unhandled_key_input(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_process)) {
+ set_process(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_fixed_process)) {
+ set_fixed_process(true);
+ }
+
Variant::CallError err;
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready,NULL,0);
}
@@ -166,13 +187,17 @@ void Node::_notification(int p_notification) {
void Node::_propagate_ready() {
+ data.ready_notified=true;
data.blocked++;
for (int i=0;i<data.children.size();i++) {
data.children[i]->_propagate_ready();
}
data.blocked--;
- notification(NOTIFICATION_READY);
+ if (data.ready_first) {
+ notification(NOTIFICATION_READY);
+ data.ready_first=false;
+ }
}
@@ -207,7 +232,7 @@ void Node::_propagate_enter_tree() {
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree,NULL,0);
}
- emit_signal(SceneStringNames::get_singleton()->enter_tree);
+ emit_signal(SceneStringNames::get_singleton()->tree_entered);
data.blocked++;
@@ -273,7 +298,7 @@ void Node::_propagate_exit_tree() {
Variant::CallError err;
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree,NULL,0);
}
- emit_signal(SceneStringNames::get_singleton()->exit_tree);
+ emit_signal(SceneStringNames::get_singleton()->tree_exited);
notification(NOTIFICATION_EXIT_TREE,true);
if (data.tree)
@@ -293,6 +318,7 @@ void Node::_propagate_exit_tree() {
data.tree->tree_changed();
data.inside_tree=false;
+ data.ready_notified=false;
data.tree=NULL;
data.depth=-1;
@@ -315,6 +341,12 @@ void Node::move_child(Node *p_child,int p_pos) {
}
+ if (p_child->data.pos==p_pos)
+ return; //do nothing
+
+ int motion_from = MIN(p_pos,p_child->data.pos);
+ int motion_to = MAX(p_pos,p_child->data.pos);
+
data.children.remove( p_child->data.pos );
data.children.insert( p_pos, p_child );
@@ -324,13 +356,13 @@ void Node::move_child(Node *p_child,int p_pos) {
data.blocked++;
//new pos first
- for (int i=0;i<data.children.size();i++) {
+ for (int i=motion_from;i<=motion_to;i++) {
data.children[i]->data.pos=i;
}
// notification second
move_child_notify(p_child);
- for (int i=0;i<data.children.size();i++) {
+ for (int i=motion_from;i<=motion_to;i++) {
data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT );
}
@@ -394,6 +426,33 @@ void Node::set_fixed_process(bool p_process) {
_change_notify("fixed_process");
}
+bool Node::is_fixed_processing() const {
+
+ return data.fixed_process;
+}
+
+void Node::set_fixed_process_internal(bool p_process_internal) {
+
+ if (data.fixed_process_internal==p_process_internal)
+ return;
+
+ data.fixed_process_internal=p_process_internal;
+
+ if (data.fixed_process_internal)
+ add_to_group("fixed_process_internal",false);
+ else
+ remove_from_group("fixed_process_internal");
+
+ data.fixed_process_internal=p_process_internal;
+ _change_notify("fixed_process_internal");
+}
+
+bool Node::is_fixed_processing_internal() const {
+
+ return data.fixed_process_internal;
+}
+
+
void Node::set_pause_mode(PauseMode p_mode) {
if (data.pause_mode==p_mode)
@@ -1108,6 +1167,14 @@ float Node::get_fixed_process_delta_time() const {
return 0;
}
+float Node::get_process_delta_time() const {
+
+ if (data.tree)
+ return data.tree->get_idle_process_time();
+ else
+ return 0;
+}
+
void Node::set_process(bool p_idle_process) {
if (data.idle_process==p_idle_process)
@@ -1124,22 +1191,31 @@ void Node::set_process(bool p_idle_process) {
_change_notify("idle_process");
}
-float Node::get_process_delta_time() const {
- if (data.tree)
- return data.tree->get_idle_process_time();
- else
- return 0;
+bool Node::is_processing() const {
+
+ return data.idle_process;
}
-bool Node::is_fixed_processing() const {
+void Node::set_process_internal(bool p_idle_process_internal) {
- return data.fixed_process;
+ if (data.idle_process_internal==p_idle_process_internal)
+ return;
+
+ data.idle_process_internal=p_idle_process_internal;
+
+ if (data.idle_process_internal)
+ add_to_group("idle_process_internal",false);
+ else
+ remove_from_group("idle_process_internal");
+
+ data.idle_process_internal=p_idle_process_internal;
+ _change_notify("idle_process_internal");
}
-bool Node::is_processing() const {
+bool Node::is_processing_internal() const {
- return data.idle_process;
+ return data.idle_process_internal;
}
@@ -1249,51 +1325,12 @@ void Node::set_human_readable_collision_renaming(bool p_enabled) {
}
+#ifdef TOOLS_ENABLED
+String Node::validate_child_name(Node* p_child) {
-String Node::validate_child_name(const String& p_name) const {
-
- //this approach to autoset node names is human readable but very slow
- //it's turned on while running in the editor
-
- String basename = p_name;
-
- if (basename==String()) {
-
- return String();
- }
-
- int val=1;
-
- for(;;) {
-
- String attempted = val > 1 ? (basename + " " +itos(val) ) : basename;
-
- bool found=false;
-
- for (int i=0;i<data.children.size();i++) {
-
- //if (data.children[i]==p_child)
- // continue;
- if (data.children[i]->get_name() == attempted) {
- found=true;
- break;
- }
-
- }
-
- if (found) {
-
- val++;
- continue;
- }
-
- return attempted;
- break;
- }
-
- return basename;
-
+ return _generate_serial_child_name(p_child);
}
+#endif
void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
@@ -1304,41 +1341,8 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
//this approach to autoset node names is human readable but very slow
//it's turned on while running in the editor
- String basename = p_child->data.name;
-
- if (basename=="") {
-
- basename = p_child->get_type();
- }
-
- int val=1;
-
- for(;;) {
-
- String attempted = val > 1 ? (basename + " " +itos(val) ) : basename;
-
- bool found=false;
+ p_child->data.name=_generate_serial_child_name(p_child);
- for (int i=0;i<data.children.size();i++) {
-
- if (data.children[i]==p_child)
- continue;
- if (data.children[i]->get_name() == attempted) {
- found=true;
- break;
- }
-
- }
-
- if (found) {
-
- val++;
- continue;
- }
-
- p_child->data.name=attempted;
- break;
- }
} else {
//this approach to autoset node names is fast but not as readable
@@ -1373,6 +1377,78 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
}
}
+String Node::_generate_serial_child_name(Node *p_child) {
+
+ String name = p_child->data.name;
+
+ if (name=="") {
+
+ name = p_child->get_class();
+ // Adjust casing according to project setting. The current type name is expected to be in PascalCase.
+ switch (GlobalConfig::get_singleton()->get("editor/node_name_casing").operator int()) {
+ case NAME_CASING_PASCAL_CASE:
+ break;
+ case NAME_CASING_CAMEL_CASE:
+ name[0] = name.to_lower()[0];
+ break;
+ case NAME_CASING_SNAKE_CASE:
+ name = name.camelcase_to_underscore(true);
+ break;
+ }
+ }
+
+ // Extract trailing number
+ String nums;
+ for(int i=name.length()-1;i>=0;i--) {
+ CharType n=name[i];
+ if (n>='0' && n<='9') {
+ nums=String::chr(name[i])+nums;
+ } else {
+ break;
+ }
+ }
+
+ String nnsep=_get_name_num_separator();
+ int num=0;
+ bool explicit_zero=false;
+ if (nums.length()>0 && name.substr(name.length()-nnsep.length()-nums.length(),nnsep.length()) == nnsep) {
+ // Base name + Separator + Number
+ num=nums.to_int();
+ name=name.substr(0,name.length()-nnsep.length()-nums.length()); // Keep base name
+ if (num==0) {
+ explicit_zero=true;
+ }
+ }
+
+ for(;;) {
+ String attempt = (name + (num > 0 || explicit_zero ? nnsep + itos(num) : "")).strip_edges();
+ bool found=false;
+ for(int i=0;i<data.children.size();i++) {
+ if (data.children[i]==p_child)
+ continue;
+ if (data.children[i]->data.name==attempt) {
+ found=true;
+ break;
+ }
+ }
+ if (!found) {
+ return attempt;
+ } else {
+ if (num==0) {
+ if (explicit_zero) {
+ // Name ended in separator + 0; user expects to get to separator + 1
+ num=1;
+ } else {
+ // Name was undecorated so skip to 2 for a more natural result
+ num=2;
+ }
+ } else {
+ num++;
+ }
+ }
+ }
+}
+
void Node::_add_child_nocheck(Node* p_child,const StringName& p_name) {
//add a child node quickly, without name validation
@@ -2237,7 +2313,7 @@ Node *Node::_duplicate(bool p_use_instancing) const {
} else {
- Object *obj = ObjectTypeDB::instance(get_type());
+ Object *obj = ClassDB::instance(get_class());
ERR_FAIL_COND_V(!obj,NULL);
node = obj->cast_to<Node>();
if (!node)
@@ -2322,9 +2398,9 @@ void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_re
ERR_FAIL_COND(!node);
} else {
- Object *obj = ObjectTypeDB::instance(get_type());
+ Object *obj = ClassDB::instance(get_class());
if (!obj) {
- print_line("could not duplicate: "+String(get_type()));
+ print_line("could not duplicate: "+String(get_class()));
}
ERR_FAIL_COND(!obj);
node = obj->cast_to<Node>();
@@ -2418,9 +2494,9 @@ Node *Node::duplicate_and_reown(const Map<Node*,Node*>& p_reown_map) const {
Node *node=NULL;
- Object *obj = ObjectTypeDB::instance(get_type());
+ Object *obj = ClassDB::instance(get_class());
if (!obj) {
- print_line("could not duplicate: "+String(get_type()));
+ print_line("could not duplicate: "+String(get_class()));
}
ERR_FAIL_COND_V(!obj,NULL);
node = obj->cast_to<Node>();
@@ -2496,6 +2572,12 @@ void Node::replace_by(Node* p_node,bool p_keep_data) {
rd.name=E->get().name;
rd.value=get(rd.name);
}
+
+ List<GroupInfo> groups;
+ get_groups(&groups);
+
+ for(List<GroupInfo>::Element *E=groups.front();E;E=E->next())
+ p_node->add_to_group(E->get().name, E->get().persistent);
}
_replace_connections_target(p_node);
@@ -2652,7 +2734,7 @@ void Node::_set_tree(SceneTree *p_tree) {
SceneTree *tree_changed_a=NULL;
SceneTree *tree_changed_b=NULL;
-// ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null
+ //ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null
if (data.tree) {
_propagate_exit_tree();
@@ -2667,7 +2749,9 @@ void Node::_set_tree(SceneTree *p_tree) {
_propagate_enter_tree();
- _propagate_ready(); //reverse_notification(NOTIFICATION_READY);
+ if (!data.parent || data.parent->data.ready_notified) { // No parent (root) or parent ready
+ _propagate_ready(); //reverse_notification(NOTIFICATION_READY);
+ }
tree_changed_b=data.tree;
@@ -2700,7 +2784,7 @@ static void _Node_debug_sn(Object *p_obj) {
path=n->get_name();
else
path=String(p->get_name())+"/"+p->get_path_to(n);
- print_line(itos(p_obj->get_instance_ID())+"- Stray Node: "+path+" (Type: "+n->get_type()+")");
+ print_line(itos(p_obj->get_instance_ID())+"- Stray Node: "+path+" (Type: "+n->get_class()+")");
}
@@ -2809,89 +2893,106 @@ bool Node::is_displayed_folded() const {
return data.display_folded;
}
+void Node::request_ready() {
+ data.ready_first=true;
+}
+
void Node::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
-
- ObjectTypeDB::bind_method(_MD("set_name","name"),&Node::set_name);
- ObjectTypeDB::bind_method(_MD("get_name"),&Node::get_name);
- ObjectTypeDB::bind_method(_MD("add_child","node:Node","legible_unique_name"),&Node::add_child,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("remove_child","node:Node"),&Node::remove_child);
- //ObjectTypeDB::bind_method(_MD("remove_and_delete_child","node:Node"),&Node::remove_and_delete_child);
- ObjectTypeDB::bind_method(_MD("get_child_count"),&Node::get_child_count);
- ObjectTypeDB::bind_method(_MD("get_children"),&Node::_get_children);
- ObjectTypeDB::bind_method(_MD("get_child:Node","idx"),&Node::get_child);
- ObjectTypeDB::bind_method(_MD("has_node","path"),&Node::has_node);
- ObjectTypeDB::bind_method(_MD("get_node:Node","path"),&Node::get_node);
- ObjectTypeDB::bind_method(_MD("get_parent:Node"),&Node::get_parent);
- ObjectTypeDB::bind_method(_MD("find_node:Node","mask","recursive","owned"),&Node::find_node,DEFVAL(true),DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("has_node_and_resource","path"),&Node::has_node_and_resource);
- ObjectTypeDB::bind_method(_MD("get_node_and_resource","path"),&Node::_get_node_and_resource);
-
- ObjectTypeDB::bind_method(_MD("is_inside_tree"),&Node::is_inside_tree);
- ObjectTypeDB::bind_method(_MD("is_a_parent_of","node:Node"),&Node::is_a_parent_of);
- ObjectTypeDB::bind_method(_MD("is_greater_than","node:Node"),&Node::is_greater_than);
- ObjectTypeDB::bind_method(_MD("get_path"),&Node::get_path);
- ObjectTypeDB::bind_method(_MD("get_path_to","node:Node"),&Node::get_path_to);
- ObjectTypeDB::bind_method(_MD("add_to_group","group","persistent"),&Node::add_to_group,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("remove_from_group","group"),&Node::remove_from_group);
- ObjectTypeDB::bind_method(_MD("is_in_group","group"),&Node::is_in_group);
- ObjectTypeDB::bind_method(_MD("move_child","child_node:Node","to_pos"),&Node::move_child);
- ObjectTypeDB::bind_method(_MD("get_groups"),&Node::_get_groups);
- ObjectTypeDB::bind_method(_MD("raise"),&Node::raise);
- ObjectTypeDB::bind_method(_MD("set_owner","owner:Node"),&Node::set_owner);
- ObjectTypeDB::bind_method(_MD("get_owner:Node"),&Node::get_owner);
- ObjectTypeDB::bind_method(_MD("remove_and_skip"),&Node::remove_and_skip);
- ObjectTypeDB::bind_method(_MD("get_index"),&Node::get_index);
- ObjectTypeDB::bind_method(_MD("print_tree"),&Node::print_tree);
- ObjectTypeDB::bind_method(_MD("set_filename","filename"),&Node::set_filename);
- ObjectTypeDB::bind_method(_MD("get_filename"),&Node::get_filename);
- ObjectTypeDB::bind_method(_MD("propagate_notification","what"),&Node::propagate_notification);
- ObjectTypeDB::bind_method(_MD("set_fixed_process","enable"),&Node::set_fixed_process);
- ObjectTypeDB::bind_method(_MD("get_fixed_process_delta_time"),&Node::get_fixed_process_delta_time);
- ObjectTypeDB::bind_method(_MD("is_fixed_processing"),&Node::is_fixed_processing);
- ObjectTypeDB::bind_method(_MD("set_process","enable"),&Node::set_process);
- ObjectTypeDB::bind_method(_MD("get_process_delta_time"),&Node::get_process_delta_time);
- ObjectTypeDB::bind_method(_MD("is_processing"),&Node::is_processing);
- ObjectTypeDB::bind_method(_MD("set_process_input","enable"),&Node::set_process_input);
- ObjectTypeDB::bind_method(_MD("is_processing_input"),&Node::is_processing_input);
- ObjectTypeDB::bind_method(_MD("set_process_unhandled_input","enable"),&Node::set_process_unhandled_input);
- ObjectTypeDB::bind_method(_MD("is_processing_unhandled_input"),&Node::is_processing_unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_process_unhandled_key_input","enable"),&Node::set_process_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("is_processing_unhandled_key_input"),&Node::is_processing_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("set_pause_mode","mode"),&Node::set_pause_mode);
- ObjectTypeDB::bind_method(_MD("get_pause_mode"),&Node::get_pause_mode);
- ObjectTypeDB::bind_method(_MD("can_process"),&Node::can_process);
- ObjectTypeDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes);
- ObjectTypeDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent);
- ObjectTypeDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
- ObjectTypeDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
-
- ObjectTypeDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
-
- ObjectTypeDB::bind_method(_MD("duplicate:Node","use_instancing"),&Node::duplicate,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("replace_by","node:Node","keep_data"),&Node::replace_by,DEFVAL(false));
-
- ObjectTypeDB::bind_method(_MD("set_scene_instance_load_placeholder","load_placeholder"),&Node::set_scene_instance_load_placeholder);
- ObjectTypeDB::bind_method(_MD("get_scene_instance_load_placeholder"),&Node::get_scene_instance_load_placeholder);
-
-
- ObjectTypeDB::bind_method(_MD("get_viewport"),&Node::get_viewport);
-
- ObjectTypeDB::bind_method(_MD("queue_free"),&Node::queue_delete);
-
- ObjectTypeDB::bind_method(_MD("set_network_mode","mode"),&Node::set_network_mode);
- ObjectTypeDB::bind_method(_MD("get_network_mode"),&Node::get_network_mode);
-
- ObjectTypeDB::bind_method(_MD("is_network_master"),&Node::is_network_master);
-
- ObjectTypeDB::bind_method(_MD("rpc_config","method","mode"),&Node::rpc_config);
- ObjectTypeDB::bind_method(_MD("rset_config","property","mode"),&Node::rset_config);
+ GLOBAL_DEF("editor/node_name_num_separator",0);
+ GlobalConfig::get_singleton()->set_custom_property_info("editor/node_name_num_separator",PropertyInfo(Variant::INT,"editor/node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
+ GLOBAL_DEF("editor/node_name_casing",NAME_CASING_PASCAL_CASE);
+ GlobalConfig::get_singleton()->set_custom_property_info("editor/node_name_casing",PropertyInfo(Variant::INT,"editor/node_name_casing",PROPERTY_HINT_ENUM,"PascalCase,camelCase,snake_case"));
+
+ ClassDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
+
+ ClassDB::bind_method(_MD("set_name","name"),&Node::set_name);
+ ClassDB::bind_method(_MD("get_name"),&Node::get_name);
+ ClassDB::bind_method(_MD("add_child","node:Node","legible_unique_name"),&Node::add_child,DEFVAL(false));
+ ClassDB::bind_method(_MD("remove_child","node:Node"),&Node::remove_child);
+ //ClassDB::bind_method(_MD("remove_and_delete_child","node:Node"),&Node::remove_and_delete_child);
+ ClassDB::bind_method(_MD("get_child_count"),&Node::get_child_count);
+ ClassDB::bind_method(_MD("get_children"),&Node::_get_children);
+ ClassDB::bind_method(_MD("get_child:Node","idx"),&Node::get_child);
+ ClassDB::bind_method(_MD("has_node","path"),&Node::has_node);
+ ClassDB::bind_method(_MD("get_node:Node","path"),&Node::get_node);
+ ClassDB::bind_method(_MD("get_parent:Node"),&Node::get_parent);
+ ClassDB::bind_method(_MD("find_node:Node","mask","recursive","owned"),&Node::find_node,DEFVAL(true),DEFVAL(true));
+ ClassDB::bind_method(_MD("has_node_and_resource","path"),&Node::has_node_and_resource);
+ ClassDB::bind_method(_MD("get_node_and_resource","path"),&Node::_get_node_and_resource);
+
+ ClassDB::bind_method(_MD("is_inside_tree"),&Node::is_inside_tree);
+ ClassDB::bind_method(_MD("is_a_parent_of","node:Node"),&Node::is_a_parent_of);
+ ClassDB::bind_method(_MD("is_greater_than","node:Node"),&Node::is_greater_than);
+ ClassDB::bind_method(_MD("get_path"),&Node::get_path);
+ ClassDB::bind_method(_MD("get_path_to","node:Node"),&Node::get_path_to);
+ ClassDB::bind_method(_MD("add_to_group","group","persistent"),&Node::add_to_group,DEFVAL(false));
+ ClassDB::bind_method(_MD("remove_from_group","group"),&Node::remove_from_group);
+ ClassDB::bind_method(_MD("is_in_group","group"),&Node::is_in_group);
+ ClassDB::bind_method(_MD("move_child","child_node:Node","to_pos"),&Node::move_child);
+ ClassDB::bind_method(_MD("get_groups"),&Node::_get_groups);
+ ClassDB::bind_method(_MD("raise"),&Node::raise);
+ ClassDB::bind_method(_MD("set_owner","owner:Node"),&Node::set_owner);
+ ClassDB::bind_method(_MD("get_owner:Node"),&Node::get_owner);
+ ClassDB::bind_method(_MD("remove_and_skip"),&Node::remove_and_skip);
+ ClassDB::bind_method(_MD("get_index"),&Node::get_index);
+ ClassDB::bind_method(_MD("print_tree"),&Node::print_tree);
+ ClassDB::bind_method(_MD("set_filename","filename"),&Node::set_filename);
+ ClassDB::bind_method(_MD("get_filename"),&Node::get_filename);
+ ClassDB::bind_method(_MD("propagate_notification","what"),&Node::propagate_notification);
+ ClassDB::bind_method(_MD("set_fixed_process","enable"),&Node::set_fixed_process);
+ ClassDB::bind_method(_MD("get_fixed_process_delta_time"),&Node::get_fixed_process_delta_time);
+ ClassDB::bind_method(_MD("is_fixed_processing"),&Node::is_fixed_processing);
+ ClassDB::bind_method(_MD("get_process_delta_time"),&Node::get_process_delta_time);
+ ClassDB::bind_method(_MD("set_process","enable"),&Node::set_process);
+ ClassDB::bind_method(_MD("is_processing"),&Node::is_processing);
+ ClassDB::bind_method(_MD("set_process_input","enable"),&Node::set_process_input);
+ ClassDB::bind_method(_MD("is_processing_input"),&Node::is_processing_input);
+ ClassDB::bind_method(_MD("set_process_unhandled_input","enable"),&Node::set_process_unhandled_input);
+ ClassDB::bind_method(_MD("is_processing_unhandled_input"),&Node::is_processing_unhandled_input);
+ ClassDB::bind_method(_MD("set_process_unhandled_key_input","enable"),&Node::set_process_unhandled_key_input);
+ ClassDB::bind_method(_MD("is_processing_unhandled_key_input"),&Node::is_processing_unhandled_key_input);
+ ClassDB::bind_method(_MD("set_pause_mode","mode"),&Node::set_pause_mode);
+ ClassDB::bind_method(_MD("get_pause_mode"),&Node::get_pause_mode);
+ ClassDB::bind_method(_MD("can_process"),&Node::can_process);
+ ClassDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes);
+ ClassDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent);
+ ClassDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
+ ClassDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
+
+ ClassDB::bind_method(_MD("set_process_internal","enable"),&Node::set_process_internal);
+ ClassDB::bind_method(_MD("is_processing_internal"),&Node::is_processing_internal);
+
+ ClassDB::bind_method(_MD("set_fixed_process_internal","enable"),&Node::set_fixed_process_internal);
+ ClassDB::bind_method(_MD("is_fixed_processing_internal"),&Node::is_fixed_processing_internal);
+
+ ClassDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
+
+ ClassDB::bind_method(_MD("duplicate:Node","use_instancing"),&Node::duplicate,DEFVAL(false));
+ ClassDB::bind_method(_MD("replace_by","node:Node","keep_data"),&Node::replace_by,DEFVAL(false));
+
+ ClassDB::bind_method(_MD("set_scene_instance_load_placeholder","load_placeholder"),&Node::set_scene_instance_load_placeholder);
+ ClassDB::bind_method(_MD("get_scene_instance_load_placeholder"),&Node::get_scene_instance_load_placeholder);
+
+
+ ClassDB::bind_method(_MD("get_viewport"),&Node::get_viewport);
+
+ ClassDB::bind_method(_MD("queue_free"),&Node::queue_delete);
+
+ ClassDB::bind_method(_MD("request_ready"),&Node::request_ready);
+
+ ClassDB::bind_method(_MD("set_network_mode","mode"),&Node::set_network_mode);
+ ClassDB::bind_method(_MD("get_network_mode"),&Node::get_network_mode);
+
+ ClassDB::bind_method(_MD("is_network_master"),&Node::is_network_master);
+
+ ClassDB::bind_method(_MD("rpc_config","method","mode"),&Node::rpc_config);
+ ClassDB::bind_method(_MD("rset_config","property","mode"),&Node::rset_config);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method(_MD("_set_import_path","import_path"),&Node::set_import_path);
- ObjectTypeDB::bind_method(_MD("_get_import_path"),&Node::get_import_path);
+ ClassDB::bind_method(_MD("_set_import_path","import_path"),&Node::set_import_path);
+ ClassDB::bind_method(_MD("_get_import_path"),&Node::get_import_path);
ADD_PROPERTYNZ( PropertyInfo(Variant::NODE_PATH,"_import_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_path"),_SCS("_get_import_path"));
#endif
@@ -2903,24 +3004,24 @@ void Node::_bind_methods() {
mi.name="rpc";
- ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc",&Node::_rpc_bind,mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc",&Node::_rpc_bind,mi);
mi.name="rpc_unreliable";
- ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable",&Node::_rpc_unreliable_bind,mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable",&Node::_rpc_unreliable_bind,mi);
mi.arguments.push_front( PropertyInfo( Variant::INT, "peer_id") );
mi.name="rpc_id";
- ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_id",&Node::_rpc_id_bind,mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_id",&Node::_rpc_id_bind,mi);
mi.name="rpc_unreliable_id";
- ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable_id",&Node::_rpc_unreliable_id_bind,mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable_id",&Node::_rpc_unreliable_id_bind,mi);
}
- ObjectTypeDB::bind_method(_MD("rset","property","value:Variant"),&Node::rset);
- ObjectTypeDB::bind_method(_MD("rset_id","peer_id","property","value:Variant"),&Node::rset_id);
- ObjectTypeDB::bind_method(_MD("rset_unreliable","property","value:Variant"),&Node::rset_unreliable);
- ObjectTypeDB::bind_method(_MD("rset_unreliable_id","peer_id","property","value:Variant"),&Node::rset_unreliable_id);
+ ClassDB::bind_method(_MD("rset","property","value:Variant"),&Node::rset);
+ ClassDB::bind_method(_MD("rset_id","peer_id","property","value:Variant"),&Node::rset_id);
+ ClassDB::bind_method(_MD("rset_unreliable","property","value:Variant"),&Node::rset_unreliable);
+ ClassDB::bind_method(_MD("rset_unreliable_id","peer_id","property","value:Variant"),&Node::rset_unreliable_id);
BIND_CONSTANT( NOTIFICATION_ENTER_TREE );
@@ -2938,6 +3039,9 @@ void Node::_bind_methods() {
BIND_CONSTANT( NOTIFICATION_DRAG_BEGIN );
BIND_CONSTANT( NOTIFICATION_DRAG_END );
BIND_CONSTANT( NOTIFICATION_PATH_CHANGED);
+ BIND_CONSTANT( NOTIFICATION_TRANSLATION_CHANGED );
+ BIND_CONSTANT( NOTIFICATION_INTERNAL_PROCESS );
+ BIND_CONSTANT( NOTIFICATION_INTERNAL_FIXED_PROCESS );
BIND_CONSTANT( NETWORK_MODE_INHERIT );
@@ -2955,14 +3059,15 @@ void Node::_bind_methods() {
BIND_CONSTANT( PAUSE_MODE_PROCESS );
ADD_SIGNAL( MethodInfo("renamed") );
- ADD_SIGNAL( MethodInfo("enter_tree") );
- ADD_SIGNAL( MethodInfo("exit_tree") );
+ ADD_SIGNAL( MethodInfo("tree_entered") );
+ ADD_SIGNAL( MethodInfo("tree_exited") );
-// ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),_SCS("set_process"),_SCS("is_processing") );
-// ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/fixed_process" ), _SCS("set_fixed_process"),_SCS("is_fixed_processing") );
+ //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),_SCS("set_process"),_SCS("is_processing") );
+ //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/fixed_process" ), _SCS("set_fixed_process"),_SCS("is_fixed_processing") );
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), _SCS("set_process_input"),_SCS("is_processing_input" ) );
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), _SCS("set_process_unhandled_input"),_SCS("is_processing_unhandled_input" ) );
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "process/pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) );
+ ADD_GROUP("Pause","pause_");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), _SCS("set_display_folded"),_SCS("is_displayed_folded" ) );
BIND_VMETHOD( MethodInfo("_process",PropertyInfo(Variant::REAL,"delta")) );
@@ -2974,8 +3079,19 @@ void Node::_bind_methods() {
BIND_VMETHOD( MethodInfo("_unhandled_input",PropertyInfo(Variant::INPUT_EVENT,"event")) );
BIND_VMETHOD( MethodInfo("_unhandled_key_input",PropertyInfo(Variant::INPUT_EVENT,"key_event")) );
- //ObjectTypeDB::bind_method(_MD("get_child",&Node::get_child,PH("index")));
- //ObjectTypeDB::bind_method(_MD("get_node",&Node::get_node,PH("path")));
+ //ClassDB::bind_method(_MD("get_child",&Node::get_child,PH("index")));
+ //ClassDB::bind_method(_MD("get_node",&Node::get_node,PH("path")));
+}
+
+
+String Node::_get_name_num_separator() {
+ switch(GlobalConfig::get_singleton()->get("node/name_num_separator").operator int()) {
+ case 0: return "";
+ case 1: return " ";
+ case 2: return "_";
+ case 3: return "-";
+ }
+ return " ";
}
@@ -2988,7 +3104,10 @@ Node::Node() {
data.tree=NULL;
data.fixed_process=false;
data.idle_process=false;
+ data.fixed_process_internal=false;
+ data.idle_process_internal=false;
data.inside_tree=false;
+ data.ready_notified=false;
data.owner=NULL;
data.OW=NULL;
@@ -3005,6 +3124,7 @@ Node::Node() {
data.viewport=NULL;
data.use_placeholder=false;
data.display_folded=false;
+ data.ready_first=true;
}
diff --git a/scene/main/node.h b/scene/main/node.h
index 3568da2ab0..14fd19a76f 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,6 +29,7 @@
#ifndef NODE_H
#define NODE_H
+#include "globals.h"
#include "object.h"
#include "path_db.h"
#include "map.h"
@@ -41,7 +42,7 @@ class Viewport;
class SceneState;
class Node : public Object {
- OBJ_TYPE( Node, Object );
+ GDCLASS( Node, Object );
OBJ_CATEGORY("Nodes");
public:
@@ -102,6 +103,8 @@ private:
StringName name;
SceneTree *tree;
bool inside_tree;
+ bool ready_notified; //this is a small hack, so if a node is added during _ready() to the tree, it corretly gets the _ready() notification
+ bool ready_first;
#ifdef TOOLS_ENABLED
NodePath import_path; //path used when imported, used by scene editors to keep tracking
#endif
@@ -127,6 +130,9 @@ private:
bool fixed_process;
bool idle_process;
+ bool fixed_process_internal;
+ bool idle_process_internal;
+
bool input;
bool unhandled_input;
bool unhandled_key_input;
@@ -141,16 +147,22 @@ private:
} data;
+ enum NameCasing {
+ NAME_CASING_PASCAL_CASE,
+ NAME_CASING_CAMEL_CASE,
+ NAME_CASING_SNAKE_CASE
+ };
+
void _print_tree(const Node *p_node);
- virtual bool _use_builtin_script() const { return true; }
Node *_get_node(const NodePath& p_path) const;
Node *_get_child_by_name(const StringName& p_name) const;
void _replace_connections_target(Node* p_new_target);
- void _validate_child_name(Node *p_name, bool p_force_human_readable=false);
+ void _validate_child_name(Node *p_child, bool p_force_human_readable=false);
+ String _generate_serial_child_name(Node *p_child);
void _propagate_reverse_notification(int p_notification);
void _propagate_deferred_notification(int p_notification, bool p_reverse);
@@ -193,6 +205,7 @@ protected:
void _propagate_replace_owner(Node *p_owner,Node* p_by_owner);
static void _bind_methods();
+ static String _get_name_num_separator();
friend class SceneState;
@@ -219,6 +232,10 @@ public:
NOTIFICATION_DRAG_BEGIN=21,
NOTIFICATION_DRAG_END=22,
NOTIFICATION_PATH_CHANGED=23,
+ NOTIFICATION_TRANSLATION_CHANGED=24,
+ NOTIFICATION_INTERNAL_PROCESS = 25,
+ NOTIFICATION_INTERNAL_FIXED_PROCESS = 26,
+
};
/* NODE/TREE */
@@ -298,6 +315,11 @@ public:
float get_process_delta_time() const;
bool is_processing() const;
+ void set_fixed_process_internal(bool p_process);
+ bool is_fixed_processing_internal() const;
+
+ void set_process_internal(bool p_process);
+ bool is_processing_internal() const;
void set_process_input(bool p_enable);
bool is_processing_input() const;
@@ -333,9 +355,13 @@ public:
PauseMode get_pause_mode() const;
bool can_process() const;
+ void request_ready();
+
static void print_stray_nodes();
- String validate_child_name(const String& p_name) const;
+#ifdef TOOLS_ENABLED
+ String validate_child_name(Node* p_child);
+#endif
void queue_delete();
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index 219eea770a..93a836a2eb 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@ void ResourcePreloader::_set_resources(const Array& p_data) {
resources.clear();
ERR_FAIL_COND(p_data.size()!=2);
- DVector<String> names=p_data[0];
+ PoolVector<String> names=p_data[0];
Array resdata=p_data[1];
ERR_FAIL_COND(names.size()!=resdata.size());
@@ -52,7 +52,7 @@ void ResourcePreloader::_set_resources(const Array& p_data) {
Array ResourcePreloader::_get_resources() const {
- DVector<String> names;
+ PoolVector<String> names;
Array arr;
arr.resize(resources.size());
names.resize(resources.size());
@@ -139,9 +139,9 @@ RES ResourcePreloader::get_resource(const StringName& p_name) const {
return resources[p_name];
}
-DVector<String> ResourcePreloader::_get_resource_list() const {
+PoolVector<String> ResourcePreloader::_get_resource_list() const {
- DVector<String> res;
+ PoolVector<String> res;
res.resize(resources.size());
int i=0;
for(Map<StringName,RES >::Element *E=resources.front();E;E=E->next(),i++) {
@@ -163,15 +163,15 @@ void ResourcePreloader::get_resource_list(List<StringName> *p_list) {
void ResourcePreloader::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_set_resources"),&ResourcePreloader::_set_resources);
- ObjectTypeDB::bind_method(_MD("_get_resources"),&ResourcePreloader::_get_resources);
+ ClassDB::bind_method(_MD("_set_resources"),&ResourcePreloader::_set_resources);
+ ClassDB::bind_method(_MD("_get_resources"),&ResourcePreloader::_get_resources);
- ObjectTypeDB::bind_method(_MD("add_resource","name","resource"),&ResourcePreloader::add_resource);
- ObjectTypeDB::bind_method(_MD("remove_resource","name"),&ResourcePreloader::remove_resource);
- ObjectTypeDB::bind_method(_MD("rename_resource","name","newname"),&ResourcePreloader::rename_resource);
- ObjectTypeDB::bind_method(_MD("has_resource","name"),&ResourcePreloader::has_resource);
- ObjectTypeDB::bind_method(_MD("get_resource","name"),&ResourcePreloader::get_resource);
- ObjectTypeDB::bind_method(_MD("get_resource_list"),&ResourcePreloader::_get_resource_list);
+ ClassDB::bind_method(_MD("add_resource","name","resource"),&ResourcePreloader::add_resource);
+ ClassDB::bind_method(_MD("remove_resource","name"),&ResourcePreloader::remove_resource);
+ ClassDB::bind_method(_MD("rename_resource","name","newname"),&ResourcePreloader::rename_resource);
+ ClassDB::bind_method(_MD("has_resource","name"),&ResourcePreloader::has_resource);
+ ClassDB::bind_method(_MD("get_resource","name"),&ResourcePreloader::get_resource);
+ ClassDB::bind_method(_MD("get_resource_list"),&ResourcePreloader::_get_resource_list);
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"resources",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_resources"), _SCS("_get_resources"));
diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h
index b06e558b59..4e585d1751 100644
--- a/scene/main/resource_preloader.h
+++ b/scene/main/resource_preloader.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,14 +34,14 @@
class ResourcePreloader : public Node {
- OBJ_TYPE(ResourcePreloader,Node);
+ GDCLASS(ResourcePreloader,Node);
Map<StringName,RES > resources;
void _set_resources(const Array& p_data);
Array _get_resources() const;
- DVector<String> _get_resource_list() const;
+ PoolVector<String> _get_resource_list() const;
protected:
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index e3472c074a..147409a862 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -48,8 +48,8 @@
void SceneTreeTimer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_time_left","time"),&SceneTreeTimer::set_time_left);
- ObjectTypeDB::bind_method(_MD("get_time_left"),&SceneTreeTimer::get_time_left);
+ ClassDB::bind_method(_MD("set_time_left","time"),&SceneTreeTimer::set_time_left);
+ ClassDB::bind_method(_MD("get_time_left"),&SceneTreeTimer::get_time_left);
ADD_SIGNAL(MethodInfo("timeout"));
}
@@ -141,7 +141,7 @@ void SceneTree::_flush_ugc() {
for(int i=0;i<E->get().size();i++)
v[i]=E->get()[i];
- call_group(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]);
+ call_group_flags(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]);
unique_group_calls.erase(E);
}
@@ -166,7 +166,7 @@ void SceneTree::_update_group_order(Group& g) {
}
-void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
+void SceneTree::call_group_flags(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E)
@@ -216,7 +216,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
continue;
if (p_call_flags&GROUP_CALL_REALTIME) {
- if (p_call_flags&GROUP_CALL_MULIILEVEL)
+ if (p_call_flags&GROUP_CALL_MULTILEVEL)
nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS);
else
nodes[i]->call(p_function,VARIANT_ARG_PASS);
@@ -233,7 +233,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
continue;
if (p_call_flags&GROUP_CALL_REALTIME) {
- if (p_call_flags&GROUP_CALL_MULIILEVEL)
+ if (p_call_flags&GROUP_CALL_MULTILEVEL)
nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS);
else
nodes[i]->call(p_function,VARIANT_ARG_PASS);
@@ -248,7 +248,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
call_skip.clear();
}
-void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification) {
+void SceneTree::notify_group_flags(uint32_t p_call_flags,const StringName& p_group,int p_notification) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E)
@@ -298,7 +298,7 @@ void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int
call_skip.clear();
}
-void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) {
+void SceneTree::set_group_flags(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E)
@@ -348,6 +348,23 @@ void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const
call_skip.clear();
}
+
+void SceneTree::call_group(const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
+
+ call_group_flags(0,p_group,VARIANT_ARG_PASS);
+}
+
+void SceneTree::notify_group(const StringName& p_group,int p_notification) {
+
+ notify_group_flags(0,p_group,p_notification);
+}
+
+void SceneTree::set_group(const StringName& p_group,const String& p_name,const Variant& p_value) {
+
+ set_group_flags(0,p_group,p_name,p_value);
+}
+
+
void SceneTree::set_input_as_handled() {
input_handled=true;
@@ -357,7 +374,7 @@ void SceneTree::input_text( const String& p_text ) {
root_lock++;
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check
root_lock--;
@@ -366,7 +383,7 @@ void SceneTree::input_text( const String& p_text ) {
void SceneTree::input_event( const InputEvent& p_event ) {
- if (is_editor_hint() && (p_event.type==InputEvent::JOYSTICK_MOTION || p_event.type==InputEvent::JOYSTICK_BUTTON))
+ if (is_editor_hint() && (p_event.type==InputEvent::JOYPAD_MOTION || p_event.type==InputEvent::JOYPAD_BUTTON))
return; //avoid joy input on editor
root_lock++;
@@ -438,21 +455,22 @@ void SceneTree::input_event( const InputEvent& p_event ) {
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev);
- /*if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) {
+ /*
+ if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) {
print_line("RAM: "+itos(Memory::get_static_mem_usage()));
print_line("DRAM: "+itos(Memory::get_dynamic_mem_usage()));
}
-*/
- //if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) {
+ if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) {
- // Memory::dump_static_mem_to_file("memdump.txt");
- //}
+ Memory::dump_static_mem_to_file("memdump.txt");
+ }
+ */
//transform for the rest
#else
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check
#endif
if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F8) {
@@ -477,7 +495,7 @@ void SceneTree::input_event( const InputEvent& p_event ) {
}
#else
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check
#endif
input_handled=true;
@@ -490,12 +508,15 @@ void SceneTree::input_event( const InputEvent& p_event ) {
}
+ _call_idle_callbacks();
+
}
void SceneTree::init() {
//_quit=false;
accept_quit=true;
+ quit_on_go_back=true;
initialized=true;
input_handled=false;
@@ -521,13 +542,15 @@ bool SceneTree::iteration(float p_time) {
emit_signal("fixed_frame");
+ _notify_group_pause("fixed_process_internal",Node::NOTIFICATION_INTERNAL_FIXED_PROCESS);
_notify_group_pause("fixed_process",Node::NOTIFICATION_FIXED_PROCESS);
_flush_ugc();
_flush_transform_notifications();
- call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds");
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds");
root_lock--;
_flush_delete_queue();
+ _call_idle_callbacks();
return _quit;
}
@@ -535,9 +558,9 @@ bool SceneTree::iteration(float p_time) {
bool SceneTree::idle(float p_time){
-// print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
-// print_line("node count: "+itos(get_node_count()));
-// print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED)));
+ //print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
+ //print_line("node count: "+itos(get_node_count()));
+ //print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED)));
root_lock++;
@@ -551,6 +574,7 @@ bool SceneTree::idle(float p_time){
_flush_transform_notifications();
+ _notify_group_pause("idle_process_internal",Node::NOTIFICATION_INTERNAL_PROCESS);
_notify_group_pause("idle_process",Node::NOTIFICATION_PROCESS);
Size2 win_size=Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height );
@@ -567,7 +591,7 @@ bool SceneTree::idle(float p_time){
_flush_ugc();
_flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications
- call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds");
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds");
root_lock--;
@@ -590,6 +614,8 @@ bool SceneTree::idle(float p_time){
E=N;
}
+ _call_idle_callbacks();
+
return _quit;
}
@@ -639,15 +665,27 @@ void SceneTree::_notification(int p_notification) {
break;
}
} break;
+ case NOTIFICATION_WM_GO_BACK_REQUEST: {
+
+ get_root()->propagate_notification(p_notification);
+
+ if (quit_on_go_back) {
+ _quit=true;
+ break;
+ }
+ } break;
case NOTIFICATION_OS_MEMORY_WARNING:
case NOTIFICATION_WM_FOCUS_IN:
case NOTIFICATION_WM_FOCUS_OUT: {
get_root()->propagate_notification(p_notification);
} break;
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ get_root()->propagate_notification(Node::NOTIFICATION_TRANSLATION_CHANGED);
+ } break;
case NOTIFICATION_WM_UNFOCUS_REQUEST: {
- notify_group(GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST);
+ notify_group_flags(GROUP_CALL_REALTIME|GROUP_CALL_MULTILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST);
} break;
@@ -662,6 +700,11 @@ void SceneTree::set_auto_accept_quit(bool p_enable) {
accept_quit=p_enable;
}
+void SceneTree::set_quit_on_go_back(bool p_enable) {
+
+ quit_on_go_back=p_enable;
+}
+
void SceneTree::set_editor_hint(bool p_enabled) {
editor_hint=p_enabled;
@@ -745,12 +788,12 @@ Ref<Material> SceneTree::get_debug_navigation_material() {
if (navigation_material.is_valid())
return navigation_material;
- Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+ Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+/* line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
- line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_color());
+ line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
+ line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
+ line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_navigation_color());*/
navigation_material=line_material;
@@ -763,12 +806,12 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material(){
if (navigation_disabled_material.is_valid())
return navigation_disabled_material;
- Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+ Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+/* line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
- line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());
+ line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
+ line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
+ line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());*/
navigation_disabled_material=line_material;
@@ -781,12 +824,12 @@ Ref<Material> SceneTree::get_debug_collision_material() {
return collision_material;
- Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+ Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ /*line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
- line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
- line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collisions_color());
+ line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
+ line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
+ line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_collisions_color());*/
collision_material=line_material;
@@ -800,11 +843,11 @@ Ref<Mesh> SceneTree::get_debug_contact_mesh() {
debug_contact_mesh = Ref<Mesh>( memnew( Mesh ) );
- Ref<FixedMaterial> mat = memnew( FixedMaterial );
- mat->set_flag(Material::FLAG_UNSHADED,true);
+ Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial );
+ /*mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
- mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());
+ mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ mat->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());*/
Vector3 diamond[6]={
Vector3(-1, 0, 0),
@@ -826,11 +869,11 @@ Ref<Mesh> SceneTree::get_debug_contact_mesh() {
1,3,5,
};
- DVector<int> indices;
+ PoolVector<int> indices;
for(int i=0;i<8*3;i++)
indices.push_back(diamond_faces[i]);
- DVector<Vector3> vertices;
+ PoolVector<Vector3> vertices;
for(int i=0;i<6;i++)
vertices.push_back(diamond[i]*0.1);
@@ -840,7 +883,7 @@ Ref<Mesh> SceneTree::get_debug_contact_mesh() {
arr[Mesh::ARRAY_INDEX]=indices;
- debug_contact_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
+ debug_contact_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,arr);
debug_contact_mesh->surface_set_material(0,mat);
return debug_contact_mesh;
@@ -966,7 +1009,7 @@ uint32_t SceneTree::get_last_event_id() const {
}
-Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
+Variant SceneTree::_call_group_flags(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
r_error.error=Variant::CallError::CALL_OK;
@@ -986,11 +1029,33 @@ Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::
v[i]=*p_args[i+3];
}
- call_group(flags,group,method,v[0],v[1],v[2],v[3],v[4]);
+ call_group_flags(flags,group,method,v[0],v[1],v[2],v[3],v[4]);
return Variant();
}
+Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
+
+
+ r_error.error=Variant::CallError::CALL_OK;
+
+ ERR_FAIL_COND_V(p_argcount<2,Variant());
+ ERR_FAIL_COND_V(p_args[0]->get_type()!=Variant::STRING,Variant());
+ ERR_FAIL_COND_V(p_args[1]->get_type()!=Variant::STRING,Variant());
+
+ StringName group = *p_args[0];
+ StringName method = *p_args[1];
+ Variant v[VARIANT_ARG_MAX];
+
+ for(int i=0;i<MIN(p_argcount-2,5);i++) {
+
+ v[i]=*p_args[i+2];
+ }
+
+ call_group_flags(0,group,method,v[0],v[1],v[2],v[3],v[4]);
+ return Variant();
+}
+
int64_t SceneTree::get_frame() const {
return current_frame;
@@ -1047,7 +1112,7 @@ static void _fill_array(Node *p_node, Array& array, int p_level) {
array.push_back(p_level);
array.push_back(p_node->get_name());
- array.push_back(p_node->get_type());
+ array.push_back(p_node->get_class());
array.push_back(p_node->get_instance_ID());
for(int i=0;i<p_node->get_child_count();i++) {
@@ -1098,7 +1163,11 @@ void SceneTree::_update_root_rect() {
if (stretch_mode==STRETCH_MODE_DISABLED) {
- root->set_rect(Rect2(Point2(),last_screen_size));
+
+ root->set_size(last_screen_size);
+ root->set_attach_to_screen_rect(Rect2(Point2(),last_screen_size));
+ root->set_size_override_stretch(false);
+ root->set_size_override(false,Size2());
return; //user will take care
}
@@ -1109,8 +1178,8 @@ void SceneTree::_update_root_rect() {
Size2 viewport_size;
Size2 screen_size;
- float viewport_aspect = desired_res.get_aspect();
- float video_mode_aspect = video_mode.get_aspect();
+ float viewport_aspect = desired_res.aspect();
+ float video_mode_aspect = video_mode.aspect();
if (stretch_aspect==STRETCH_ASPECT_IGNORE || ABS(viewport_aspect - video_mode_aspect)<CMP_EPSILON) {
//same aspect or ignore aspect
@@ -1169,26 +1238,23 @@ void SceneTree::_update_root_rect() {
VisualServer::get_singleton()->black_bars_set_margins(0,0,0,0);
}
-// print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size));
-// print_line("SS: "+video_mode);
+ //print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size));
+ //print_line("SS: "+video_mode);
switch (stretch_mode) {
case STRETCH_MODE_2D: {
-// root->set_rect(Rect2(Point2(),video_mode));
- root->set_as_render_target(false);
- root->set_rect(Rect2(margin,screen_size));
+ root->set_size(screen_size);
+ root->set_attach_to_screen_rect(Rect2(margin,screen_size));
root->set_size_override_stretch(true);
root->set_size_override(true,viewport_size);
} break;
case STRETCH_MODE_VIEWPORT: {
- root->set_rect(Rect2(Point2(),viewport_size));
+ root->set_size(viewport_size);
+ root->set_attach_to_screen_rect(Rect2(margin,screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false,Size2());
- root->set_as_render_target(true);
- root->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);
- root->set_render_target_to_screen_rect(Rect2(margin,screen_size));
} break;
@@ -1421,7 +1487,7 @@ void SceneTree::_live_edit_create_node_func(const NodePath& p_parent,const Strin
continue;
Node *n2 = n->get_node(p_parent);
- Object *o = ObjectTypeDB::instance(p_type);
+ Object *o = ClassDB::instance(p_type);
if (!o)
continue;
Node *no=o->cast_to<Node>();
@@ -2056,7 +2122,7 @@ void SceneTree::_network_process_packet(int p_from, const uint8_t* p_packet, int
node->set(name,value,&valid);
if (!valid) {
- String error = "Error setting remote property '"+String(name)+"', not found in object of type "+node->get_type();
+ String error = "Error setting remote property '"+String(name)+"', not found in object of type "+node->get_class();
ERR_PRINTS(error);
}
}
@@ -2154,77 +2220,90 @@ void SceneTree::_network_poll() {
void SceneTree::_bind_methods() {
- //ObjectTypeDB::bind_method(_MD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("notify_group","call_flags","group","notification"),&SceneTree::notify_group);
- ObjectTypeDB::bind_method(_MD("set_group","call_flags","group","property","value"),&SceneTree::set_group);
-
- ObjectTypeDB::bind_method(_MD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group);
+ //ClassDB::bind_method(_MD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("get_root:Viewport"),&SceneTree::get_root);
- ObjectTypeDB::bind_method(_MD("has_group","name"),&SceneTree::has_group);
+ ClassDB::bind_method(_MD("get_root:Viewport"),&SceneTree::get_root);
+ ClassDB::bind_method(_MD("has_group","name"),&SceneTree::has_group);
- ObjectTypeDB::bind_method(_MD("set_auto_accept_quit","enabled"),&SceneTree::set_auto_accept_quit);
+ ClassDB::bind_method(_MD("set_auto_accept_quit","enabled"),&SceneTree::set_auto_accept_quit);
- ObjectTypeDB::bind_method(_MD("set_editor_hint","enable"),&SceneTree::set_editor_hint);
- ObjectTypeDB::bind_method(_MD("is_editor_hint"),&SceneTree::is_editor_hint);
- ObjectTypeDB::bind_method(_MD("set_debug_collisions_hint","enable"),&SceneTree::set_debug_collisions_hint);
- ObjectTypeDB::bind_method(_MD("is_debugging_collisions_hint"),&SceneTree::is_debugging_collisions_hint);
- ObjectTypeDB::bind_method(_MD("set_debug_navigation_hint","enable"),&SceneTree::set_debug_navigation_hint);
- ObjectTypeDB::bind_method(_MD("is_debugging_navigation_hint"),&SceneTree::is_debugging_navigation_hint);
+ ClassDB::bind_method(_MD("set_editor_hint","enable"),&SceneTree::set_editor_hint);
+ ClassDB::bind_method(_MD("is_editor_hint"),&SceneTree::is_editor_hint);
+ ClassDB::bind_method(_MD("set_debug_collisions_hint","enable"),&SceneTree::set_debug_collisions_hint);
+ ClassDB::bind_method(_MD("is_debugging_collisions_hint"),&SceneTree::is_debugging_collisions_hint);
+ ClassDB::bind_method(_MD("set_debug_navigation_hint","enable"),&SceneTree::set_debug_navigation_hint);
+ ClassDB::bind_method(_MD("is_debugging_navigation_hint"),&SceneTree::is_debugging_navigation_hint);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method(_MD("set_edited_scene_root","scene"),&SceneTree::set_edited_scene_root);
- ObjectTypeDB::bind_method(_MD("get_edited_scene_root"),&SceneTree::get_edited_scene_root);
+ ClassDB::bind_method(_MD("set_edited_scene_root","scene"),&SceneTree::set_edited_scene_root);
+ ClassDB::bind_method(_MD("get_edited_scene_root"),&SceneTree::get_edited_scene_root);
#endif
- ObjectTypeDB::bind_method(_MD("set_pause","enable"),&SceneTree::set_pause);
- ObjectTypeDB::bind_method(_MD("is_paused"),&SceneTree::is_paused);
- ObjectTypeDB::bind_method(_MD("set_input_as_handled"),&SceneTree::set_input_as_handled);
+ ClassDB::bind_method(_MD("set_pause","enable"),&SceneTree::set_pause);
+ ClassDB::bind_method(_MD("is_paused"),&SceneTree::is_paused);
+ ClassDB::bind_method(_MD("set_input_as_handled"),&SceneTree::set_input_as_handled);
- ObjectTypeDB::bind_method(_MD("create_timer:SceneTreeTimer","time_sec"),&SceneTree::create_timer);
+ ClassDB::bind_method(_MD("create_timer:SceneTreeTimer","time_sec"),&SceneTree::create_timer);
- ObjectTypeDB::bind_method(_MD("get_node_count"),&SceneTree::get_node_count);
- ObjectTypeDB::bind_method(_MD("get_frame"),&SceneTree::get_frame);
- ObjectTypeDB::bind_method(_MD("quit"),&SceneTree::quit);
+ ClassDB::bind_method(_MD("get_node_count"),&SceneTree::get_node_count);
+ ClassDB::bind_method(_MD("get_frame"),&SceneTree::get_frame);
+ ClassDB::bind_method(_MD("quit"),&SceneTree::quit);
- ObjectTypeDB::bind_method(_MD("set_screen_stretch","mode","aspect","minsize"),&SceneTree::set_screen_stretch);
+ ClassDB::bind_method(_MD("set_screen_stretch","mode","aspect","minsize"),&SceneTree::set_screen_stretch);
- ObjectTypeDB::bind_method(_MD("queue_delete","obj"),&SceneTree::queue_delete);
+ ClassDB::bind_method(_MD("queue_delete","obj"),&SceneTree::queue_delete);
MethodInfo mi;
- mi.name="call_group";
+ mi.name="call_group_flags";
mi.arguments.push_back( PropertyInfo( Variant::INT, "flags"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "group"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group_flags",&SceneTree::_call_group_flags,mi);
+
+ ClassDB::bind_method(_MD("notify_group_flags","call_flags","group","notification"),&SceneTree::notify_group_flags);
+ ClassDB::bind_method(_MD("set_group_flags","call_flags","group","property","value"),&SceneTree::set_group_flags);
+
+ MethodInfo mi2;
+ mi2.name="call_group";
+ mi2.arguments.push_back( PropertyInfo( Variant::STRING, "group"));
+ mi2.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
+
+
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi2);
- ObjectTypeDB::bind_method(_MD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene);
- ObjectTypeDB::bind_method(_MD("get_current_scene:Node"),&SceneTree::get_current_scene);
+ ClassDB::bind_method(_MD("notify_group","call_flags","group","notification"),&SceneTree::notify_group);
+ ClassDB::bind_method(_MD("set_group","call_flags","group","property","value"),&SceneTree::set_group);
- ObjectTypeDB::bind_method(_MD("change_scene","path"),&SceneTree::change_scene);
- ObjectTypeDB::bind_method(_MD("change_scene_to","packed_scene:PackedScene"),&SceneTree::change_scene_to);
+ ClassDB::bind_method(_MD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group);
- ObjectTypeDB::bind_method(_MD("reload_current_scene"),&SceneTree::reload_current_scene);
- ObjectTypeDB::bind_method(_MD("_change_scene"),&SceneTree::_change_scene);
+ ClassDB::bind_method(_MD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene);
+ ClassDB::bind_method(_MD("get_current_scene:Node"),&SceneTree::get_current_scene);
+ ClassDB::bind_method(_MD("change_scene","path"),&SceneTree::change_scene);
+ ClassDB::bind_method(_MD("change_scene_to","packed_scene:PackedScene"),&SceneTree::change_scene_to);
- ObjectTypeDB::bind_method(_MD("set_network_peer","peer:NetworkedMultiplayerPeer"),&SceneTree::set_network_peer);
- ObjectTypeDB::bind_method(_MD("is_network_server"),&SceneTree::is_network_server);
- ObjectTypeDB::bind_method(_MD("get_network_unique_id"),&SceneTree::get_network_unique_id);
- ObjectTypeDB::bind_method(_MD("set_refuse_new_network_connections","refuse"),&SceneTree::set_refuse_new_network_connections);
- ObjectTypeDB::bind_method(_MD("is_refusing_new_network_connections"),&SceneTree::is_refusing_new_network_connections);
- ObjectTypeDB::bind_method(_MD("_network_peer_connected"),&SceneTree::_network_peer_connected);
- ObjectTypeDB::bind_method(_MD("_network_peer_disconnected"),&SceneTree::_network_peer_disconnected);
- ObjectTypeDB::bind_method(_MD("_connected_to_server"),&SceneTree::_connected_to_server);
- ObjectTypeDB::bind_method(_MD("_connection_failed"),&SceneTree::_connection_failed);
- ObjectTypeDB::bind_method(_MD("_server_disconnected"),&SceneTree::_server_disconnected);
+ ClassDB::bind_method(_MD("reload_current_scene"),&SceneTree::reload_current_scene);
+
+ ClassDB::bind_method(_MD("_change_scene"),&SceneTree::_change_scene);
+
+
+ ClassDB::bind_method(_MD("set_network_peer","peer:NetworkedMultiplayerPeer"),&SceneTree::set_network_peer);
+ ClassDB::bind_method(_MD("is_network_server"),&SceneTree::is_network_server);
+ ClassDB::bind_method(_MD("get_network_unique_id"),&SceneTree::get_network_unique_id);
+ ClassDB::bind_method(_MD("set_refuse_new_network_connections","refuse"),&SceneTree::set_refuse_new_network_connections);
+ ClassDB::bind_method(_MD("is_refusing_new_network_connections"),&SceneTree::is_refusing_new_network_connections);
+ ClassDB::bind_method(_MD("_network_peer_connected"),&SceneTree::_network_peer_connected);
+ ClassDB::bind_method(_MD("_network_peer_disconnected"),&SceneTree::_network_peer_disconnected);
+ ClassDB::bind_method(_MD("_connected_to_server"),&SceneTree::_connected_to_server);
+ ClassDB::bind_method(_MD("_connection_failed"),&SceneTree::_connection_failed);
+ ClassDB::bind_method(_MD("_server_disconnected"),&SceneTree::_server_disconnected);
ADD_SIGNAL( MethodInfo("tree_changed") );
ADD_SIGNAL( MethodInfo("node_removed",PropertyInfo( Variant::OBJECT, "node") ) );
@@ -2234,7 +2313,7 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL( MethodInfo("idle_frame"));
ADD_SIGNAL( MethodInfo("fixed_frame"));
- ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::STRING_ARRAY,"files"),PropertyInfo(Variant::INT,"screen")) );
+ ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::POOL_STRING_ARRAY,"files"),PropertyInfo(Variant::INT,"screen")) );
ADD_SIGNAL( MethodInfo("network_peer_connected",PropertyInfo(Variant::INT,"id")));
ADD_SIGNAL( MethodInfo("network_peer_disconnected",PropertyInfo(Variant::INT,"id")));
ADD_SIGNAL( MethodInfo("connected_to_server"));
@@ -2258,6 +2337,23 @@ void SceneTree::_bind_methods() {
SceneTree *SceneTree::singleton=NULL;
+
+SceneTree::IdleCallback SceneTree::idle_callbacks[SceneTree::MAX_IDLE_CALLBACKS];
+int SceneTree::idle_callback_count=0;
+
+void SceneTree::_call_idle_callbacks() {
+
+ for(int i=0;i<idle_callback_count;i++) {
+ idle_callbacks[i]();
+ }
+}
+
+void SceneTree::add_idle_callback(IdleCallback p_callback) {
+ ERR_FAIL_COND(idle_callback_count>=MAX_IDLE_CALLBACKS);
+ idle_callbacks[idle_callback_count++]=p_callback;
+}
+
+
SceneTree::SceneTree() {
singleton=this;
@@ -2266,11 +2362,12 @@ SceneTree::SceneTree() {
editor_hint=false;
debug_collisions_hint=false;
debug_navigation_hint=false;
- debug_collisions_color=GLOBAL_DEF("debug/collision_shape_color",Color(0.0,0.6,0.7,0.5));
- debug_collision_contact_color=GLOBAL_DEF("debug/collision_contact_color",Color(1.0,0.2,0.1,0.8));
- debug_navigation_color=GLOBAL_DEF("debug/navigation_geometry_color",Color(0.1,1.0,0.7,0.4));
- debug_navigation_disabled_color=GLOBAL_DEF("debug/navigation_disabled_geometry_color",Color(1.0,0.7,0.1,0.4));
- collision_debug_contacts=GLOBAL_DEF("debug/collision_max_contacts_displayed",10000);
+ debug_collisions_color=GLOBAL_DEF("debug/collision/shape_color",Color(0.0,0.6,0.7,0.5));
+ debug_collision_contact_color=GLOBAL_DEF("debug/collision/contact_color",Color(1.0,0.2,0.1,0.8));
+ debug_navigation_color=GLOBAL_DEF("debug/navigation/geometry_color",Color(0.1,1.0,0.7,0.4));
+ debug_navigation_disabled_color=GLOBAL_DEF("debug/navigation/disabled_geometry_color",Color(1.0,0.7,0.1,0.4));
+ collision_debug_contacts=GLOBAL_DEF("debug/collision/max_contacts_displayed",10000);
+
tree_version=1;
@@ -2296,17 +2393,28 @@ SceneTree::SceneTree() {
root->set_as_audio_listener_2d(true);
current_scene=NULL;
+ int ref_atlas_size = GLOBAL_DEF("rendering/reflections/atlas_size",2048);
+ int ref_atlas_subdiv = GLOBAL_DEF("rendering/reflections/atlas_subdiv",8);
+ int msaa_mode = GLOBAL_DEF("rendering/quality/msaa",0);
+ GlobalConfig::get_singleton()->set_custom_property_info("rendering/quality/msaa",PropertyInfo(Variant::INT,"rendering/quality/msaa",PROPERTY_HINT_ENUM,"Disabled,2x,4x,8x,16x"));
+ root->set_msaa(Viewport::MSAA(msaa_mode));
+ bool hdr = GLOBAL_DEF("rendering/quality/hdr",true);
+ root->set_hdr(hdr);
+
+ VS::get_singleton()->scenario_set_reflection_atlas_size(root->get_world()->get_scenario(),ref_atlas_size,ref_atlas_subdiv);
+
+
stretch_mode=STRETCH_MODE_DISABLED;
stretch_aspect=STRETCH_ASPECT_IGNORE;
last_screen_size=Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height );
- root->set_rect(Rect2(Point2(),last_screen_size));
+ root->set_size(last_screen_size);
if (ScriptDebugger::get_singleton()) {
ScriptDebugger::get_singleton()->set_request_scene_tree_message_func(_debugger_request_tree,this);
}
- root->set_physics_object_picking(GLOBAL_DEF("physics/enable_object_picking",true));
+ root->set_physics_object_picking(GLOBAL_DEF("physics/common/enable_object_picking",true));
#ifdef TOOLS_ENABLED
edited_scene_root=NULL;
diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h
index 1c0f88862c..f4271e5454 100644
--- a/scene/main/scene_main_loop.h
+++ b/scene/main/scene_main_loop.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,7 +53,7 @@ class Mesh;
class SceneTreeTimer : public Reference {
- OBJ_TYPE(SceneTreeTimer,Reference);
+ GDCLASS(SceneTreeTimer,Reference);
float time_left;
protected:
@@ -70,10 +70,12 @@ class SceneTree : public MainLoop {
_THREAD_SAFE_CLASS_
- OBJ_TYPE( SceneTree, MainLoop );
+ GDCLASS( SceneTree, MainLoop );
public:
+ typedef void (*IdleCallback)();
+
enum StretchMode {
STRETCH_MODE_DISABLED,
@@ -105,6 +107,7 @@ private:
float fixed_process_time;
float idle_process_time;
bool accept_quit;
+ bool quit_on_go_back;
uint32_t last_id;
bool editor_hint;
@@ -239,9 +242,11 @@ friend class Node;
void _notify_group_pause(const StringName& p_group,int p_notification);
void _call_input_pause(const StringName& p_group,const StringName& p_method,const InputEvent& p_input);
+ Variant _call_group_flags(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Variant _call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
+
static void _debugger_request_tree(void *self);
void _flush_delete_queue();
//optimization
@@ -303,6 +308,15 @@ friend class Viewport;
static void _live_edit_reparent_node_funcs(void* self,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos) { reinterpret_cast<SceneTree*>(self)->_live_edit_reparent_node_func(p_at,p_new_place,p_new_name,p_at_pos); }
#endif
+
+ enum {
+ MAX_IDLE_CALLBACKS=256
+ };
+
+ static IdleCallback idle_callbacks[MAX_IDLE_CALLBACKS];
+ static int idle_callback_count;
+ void _call_idle_callbacks();
+
protected:
@@ -320,17 +334,20 @@ public:
GROUP_CALL_REVERSE=1,
GROUP_CALL_REALTIME=2,
GROUP_CALL_UNIQUE=4,
- GROUP_CALL_MULIILEVEL=8,
+ GROUP_CALL_MULTILEVEL=8,
};
_FORCE_INLINE_ Viewport *get_root() const { return root; }
uint32_t get_last_event_id() const;
- void call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
- void notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification);
- void set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value);
+ void call_group_flags(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
+ void notify_group_flags(uint32_t p_call_flags,const StringName& p_group,int p_notification);
+ void set_group_flags(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value);
+ void call_group(const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
+ void notify_group(const StringName& p_group,int p_notification);
+ void set_group(const StringName& p_group,const String& p_name,const Variant& p_value);
virtual void input_text( const String& p_text );
virtual void input_event( const InputEvent& p_event );
@@ -342,6 +359,7 @@ public:
virtual void finish();
void set_auto_accept_quit(bool p_enable);
+ void set_quit_on_go_back(bool p_enable);
void quit();
@@ -430,6 +448,7 @@ public:
void set_refuse_new_network_connections(bool p_refuse);
bool is_refusing_new_network_connections() const;
+ static void add_idle_callback(IdleCallback p_callback);
SceneTree();
~SceneTree();
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 7d9bbd7f4f..7852e2b46b 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,8 +45,8 @@ void Timer::_notification(int p_what) {
autostart=false;
}
} break;
- case NOTIFICATION_PROCESS: {
- if (timer_process_mode == TIMER_PROCESS_FIXED || !is_processing())
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ if (timer_process_mode == TIMER_PROCESS_FIXED || !is_processing_internal())
return;
time_left -= get_process_delta_time();
@@ -61,8 +61,8 @@ void Timer::_notification(int p_what) {
}
} break;
- case NOTIFICATION_FIXED_PROCESS: {
- if (timer_process_mode == TIMER_PROCESS_IDLE || !is_fixed_processing())
+ case NOTIFICATION_INTERNAL_FIXED_PROCESS: {
+ if (timer_process_mode == TIMER_PROCESS_IDLE || !is_fixed_processing_internal())
return;
time_left -= get_fixed_process_delta_time();
@@ -147,15 +147,15 @@ void Timer::set_timer_process_mode(TimerProcessMode p_mode) {
switch (timer_process_mode) {
case TIMER_PROCESS_FIXED:
- if (is_fixed_processing()) {
- set_fixed_process(false);
- set_process(true);
+ if (is_fixed_processing_internal()) {
+ set_fixed_process_internal(false);
+ set_process_internal(true);
}
break;
case TIMER_PROCESS_IDLE:
- if (is_processing()) {
- set_process(false);
- set_fixed_process(true);
+ if (is_processing_internal()) {
+ set_process_internal(false);
+ set_fixed_process_internal(true);
}
break;
}
@@ -171,33 +171,33 @@ Timer::TimerProcessMode Timer::get_timer_process_mode() const{
void Timer::_set_process(bool p_process, bool p_force)
{
switch (timer_process_mode) {
- case TIMER_PROCESS_FIXED: set_fixed_process(p_process && active); break;
- case TIMER_PROCESS_IDLE: set_process(p_process && active); break;
+ case TIMER_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break;
+ case TIMER_PROCESS_IDLE: set_process_internal(p_process && active); break;
}
processing = p_process;
}
void Timer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_wait_time","time_sec"),&Timer::set_wait_time);
- ObjectTypeDB::bind_method(_MD("get_wait_time"),&Timer::get_wait_time);
+ ClassDB::bind_method(_MD("set_wait_time","time_sec"),&Timer::set_wait_time);
+ ClassDB::bind_method(_MD("get_wait_time"),&Timer::get_wait_time);
- ObjectTypeDB::bind_method(_MD("set_one_shot","enable"),&Timer::set_one_shot);
- ObjectTypeDB::bind_method(_MD("is_one_shot"),&Timer::is_one_shot);
+ ClassDB::bind_method(_MD("set_one_shot","enable"),&Timer::set_one_shot);
+ ClassDB::bind_method(_MD("is_one_shot"),&Timer::is_one_shot);
- ObjectTypeDB::bind_method(_MD("set_autostart","enable"),&Timer::set_autostart);
- ObjectTypeDB::bind_method(_MD("has_autostart"),&Timer::has_autostart);
+ ClassDB::bind_method(_MD("set_autostart","enable"),&Timer::set_autostart);
+ ClassDB::bind_method(_MD("has_autostart"),&Timer::has_autostart);
- ObjectTypeDB::bind_method(_MD("start"),&Timer::start);
- ObjectTypeDB::bind_method(_MD("stop"),&Timer::stop);
+ ClassDB::bind_method(_MD("start"),&Timer::start);
+ ClassDB::bind_method(_MD("stop"),&Timer::stop);
- ObjectTypeDB::bind_method(_MD("set_active", "active"), &Timer::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"), &Timer::is_active);
+ ClassDB::bind_method(_MD("set_active", "active"), &Timer::set_active);
+ ClassDB::bind_method(_MD("is_active"), &Timer::is_active);
- ObjectTypeDB::bind_method(_MD("get_time_left"),&Timer::get_time_left);
+ ClassDB::bind_method(_MD("get_time_left"),&Timer::get_time_left);
- ObjectTypeDB::bind_method(_MD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode);
- ObjectTypeDB::bind_method(_MD("get_timer_process_mode"), &Timer::get_timer_process_mode);
+ ClassDB::bind_method(_MD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode);
+ ClassDB::bind_method(_MD("get_timer_process_mode"), &Timer::get_timer_process_mode);
ADD_SIGNAL( MethodInfo("timeout") );
diff --git a/scene/main/timer.h b/scene/main/timer.h
index 688be6e4f2..6b69f3f409 100644
--- a/scene/main/timer.h
+++ b/scene/main/timer.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Timer : public Node {
- OBJ_TYPE( Timer, Node );
+ GDCLASS( Timer, Node );
float wait_time;
bool one_shot;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index b22d1fcdf4..c3ece76b05 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -51,60 +51,121 @@
#include "globals.h"
-int RenderTargetTexture::get_width() const {
+void ViewportTexture::setup_local_to_scene() {
+
+ if (vp) {
+ vp->viewport_textures.erase(this);
+ }
+
+ vp=NULL;
+
+ Node *local_scene = get_local_scene();
+ if (!local_scene) {
+ return;
+ }
+
+ Node *vpn = local_scene->get_node(path);
+ ERR_EXPLAIN("ViewportTexture: Path to node is invalid");
+ ERR_FAIL_COND(!vpn);
+
+ vp = vpn->cast_to<Viewport>();
+
+ ERR_EXPLAIN("ViewportTexture: Path to node does not point to a viewport");
+ ERR_FAIL_COND(!vp);
+
+ vp->viewport_textures.insert(this);
+}
+
+void ViewportTexture::set_viewport_path_in_scene(const NodePath& p_path) {
+
+ if (path==p_path)
+ return;
+
+ path=p_path;
+
+ if (get_local_scene()) {
+ setup_local_to_scene();
+ }
+
+}
+
+NodePath ViewportTexture::get_viewport_path_in_scene() const {
+
+ return path;
+}
+
+int ViewportTexture::get_width() const {
ERR_FAIL_COND_V(!vp,0);
- return vp->rect.size.width;
+ return vp->size.width;
}
-int RenderTargetTexture::get_height() const{
+int ViewportTexture::get_height() const{
ERR_FAIL_COND_V(!vp,0);
- return vp->rect.size.height;
+ return vp->size.height;
}
-Size2 RenderTargetTexture::get_size() const{
+Size2 ViewportTexture::get_size() const{
ERR_FAIL_COND_V(!vp,Size2());
- return vp->rect.size;
+ return vp->size;
}
-RID RenderTargetTexture::get_rid() const{
+RID ViewportTexture::get_rid() const{
ERR_FAIL_COND_V(!vp,RID());
- return vp->render_target_texture_rid;
+ return vp->texture_rid;
}
-bool RenderTargetTexture::has_alpha() const{
+bool ViewportTexture::has_alpha() const{
return false;
}
-void RenderTargetTexture::set_flags(uint32_t p_flags){
+void ViewportTexture::set_flags(uint32_t p_flags){
- ERR_FAIL_COND(!vp);
- if (p_flags&FLAG_FILTER)
- flags=FLAG_FILTER;
- else
- flags=0;
+ if (!vp)
+ return;
+
+ vp->texture_flags=p_flags;
+ VS::get_singleton()->texture_set_flags(vp->texture_rid,p_flags);
+
+}
- VS::get_singleton()->texture_set_flags(vp->render_target_texture_rid,flags);
+uint32_t ViewportTexture::get_flags() const{
+ if (!vp)
+ return 0;
+
+ return vp->texture_flags;
}
-uint32_t RenderTargetTexture::get_flags() const{
+void ViewportTexture::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_viewport_path_in_scene","path"),&ViewportTexture::set_viewport_path_in_scene);
+ ClassDB::bind_method(_MD("get_viewport_path_in_scene"),&ViewportTexture::get_viewport_path_in_scene);
+
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"viewport_path"),_SCS("set_viewport_path_in_scene"),_SCS("get_viewport_path_in_scene"));
- return flags;
}
-RenderTargetTexture::RenderTargetTexture(Viewport *p_vp){
+ViewportTexture::ViewportTexture(){
+
+ vp=NULL;
+ set_local_to_scene(true);
- vp=p_vp;
- flags=0;
+}
+
+ViewportTexture::~ViewportTexture(){
+
+ if (vp) {
+ vp->viewport_textures.erase(this);
+ }
}
/////////////////////////////////////
class TooltipPanel : public Panel {
- OBJ_TYPE(TooltipPanel,Panel)
+ GDCLASS(TooltipPanel,Panel)
public:
TooltipPanel() {};
@@ -112,7 +173,7 @@ public:
class TooltipLabel : public Label {
- OBJ_TYPE(TooltipLabel,Label)
+ GDCLASS(TooltipLabel,Label)
public:
TooltipLabel() {};
@@ -141,9 +202,9 @@ void Viewport::_update_stretch_transform() {
if (size_override_stretch && size_override) {
//print_line("sive override size "+size_override_size);
- //print_line("rect size "+rect.size);
- stretch_transform=Matrix32();
- Size2 scale = rect.size/(size_override_size+size_override_margin*2);
+ //print_line("rect size "+size);
+ stretch_transform=Transform2D();
+ Size2 scale = size/(size_override_size+size_override_margin*2);
stretch_transform.scale(scale);
stretch_transform.elements[2]=size_override_margin*scale;
@@ -151,7 +212,7 @@ void Viewport::_update_stretch_transform() {
} else {
- stretch_transform=Matrix32();
+ stretch_transform=Transform2D();
}
_update_global_transform();
@@ -164,14 +225,14 @@ void Viewport::_update_rect() {
return;
- if (!render_target && parent_control) {
+ /*if (!render_target && parent_control) {
Control *c = parent_control;
rect.pos=Point2();
rect.size=c->get_size();
- }
-
+ }*/
+/*
VisualServer::ViewportRect vr;
vr.x=rect.pos.x;
vr.y=rect.pos.y;
@@ -191,8 +252,8 @@ void Viewport::_update_rect() {
}
emit_signal("size_changed");
- render_target_texture->emit_changed();
-
+ texture->emit_changed();
+*/
}
@@ -207,23 +268,23 @@ void Viewport::_parent_draw() {
void Viewport::_parent_visibility_changed() {
-
+/*
if (parent_control) {
Control *c = parent_control;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,c->is_visible());
+ VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,c->is_visible_in_tree());
_update_listener();
_update_listener_2d();
}
-
+*/
}
void Viewport::_vp_enter_tree() {
- if (parent_control) {
+/* if (parent_control) {
Control *cparent=parent_control;
RID parent_ci = cparent->get_canvas_item();
@@ -232,20 +293,21 @@ void Viewport::_vp_enter_tree() {
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent_ci);
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
- VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
+ //VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
parent_control->connect("resized",this,"_parent_resized");
parent_control->connect("visibility_changed",this,"_parent_visibility_changed");
} else if (!parent){
- VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
+ //VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
}
-
+*/
}
void Viewport::_vp_exit_tree() {
+ /*
if (parent_control) {
parent_control->disconnect("resized",this,"_parent_resized");
@@ -268,7 +330,7 @@ void Viewport::_vp_exit_tree() {
VisualServer::get_singleton()->viewport_detach(viewport);
}
-
+*/
}
@@ -326,31 +388,12 @@ void Viewport::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
if (get_parent()) {
- Node *parent=get_parent();
- if (parent) {
- parent_control=parent->cast_to<Control>();
- }
- }
-
-
- parent=NULL;
- Node *parent_node=get_parent();
-
-
- while(parent_node) {
-
- parent = parent_node->cast_to<Viewport>();
- if (parent)
- break;
-
- parent_node=parent_node->get_parent();
+ parent = get_parent()->get_viewport();
+ VisualServer::get_singleton()->viewport_set_parent_viewport(viewport,parent->get_viewport_rid());
+ } else {
+ parent=NULL;
}
-
- if (!render_target)
- _vp_enter_tree();
-
-
current_canvas=find_world_2d()->get_canvas();
VisualServer::get_singleton()->viewport_set_scenario(viewport,find_world()->get_scenario());
VisualServer::get_singleton()->viewport_attach_canvas(viewport,current_canvas);
@@ -370,7 +413,7 @@ void Viewport::_notification(int p_what) {
//3D
PhysicsServer::get_singleton()->space_set_debug_contacts(find_world()->get_space(),get_tree()->get_collision_debug_contact_count());
contact_3d_debug_multimesh=VisualServer::get_singleton()->multimesh_create();
- VisualServer::get_singleton()->multimesh_set_instance_count(contact_3d_debug_multimesh,get_tree()->get_collision_debug_contact_count());
+ VisualServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh,get_tree()->get_collision_debug_contact_count(),VS::MULTIMESH_TRANSFORM_3D,VS::MULTIMESH_COLOR_8BIT);
VisualServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh,0);
VisualServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh,get_tree()->get_debug_contact_mesh()->get_rid());
contact_3d_debug_instance=VisualServer::get_singleton()->instance_create();
@@ -380,6 +423,7 @@ void Viewport::_notification(int p_what) {
}
+ VS::get_singleton()->viewport_set_active(viewport,true);
} break;
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
@@ -418,8 +462,10 @@ void Viewport::_notification(int p_what) {
if (world_2d.is_valid())
world_2d->_remove_viewport(this);
+ /*
if (!render_target)
_vp_exit_tree();
+ */
VisualServer::get_singleton()->viewport_set_scenario(viewport,RID());
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
@@ -437,7 +483,10 @@ void Viewport::_notification(int p_what) {
}
remove_from_group("_viewports");
- parent_control=NULL;
+
+
+ VS::get_singleton()->viewport_set_active(viewport,false);
+
} break;
case NOTIFICATION_FIXED_PROCESS: {
@@ -452,7 +501,7 @@ void Viewport::_notification(int p_what) {
if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) {
VisualServer::get_singleton()->canvas_item_clear(contact_2d_debug);
- VisualServer::get_singleton()->canvas_item_raise(contact_2d_debug);
+ VisualServer::get_singleton()->canvas_item_set_draw_index(contact_2d_debug,0xFFFFF); //very high index
Vector<Vector2> points = Physics2DServer::get_singleton()->space_get_contacts(find_world_2d()->get_space());
int point_count = Physics2DServer::get_singleton()->space_get_contact_count(find_world_2d()->get_space());
@@ -474,27 +523,11 @@ void Viewport::_notification(int p_what) {
VS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh,point_count);
- if (point_count>0) {
- AABB aabb;
-
- Transform t;
- for(int i=0;i<point_count;i++) {
-
- if (i==0)
- aabb.pos=points[i];
- else
- aabb.expand_to(points[i]);
- t.origin=points[i];
- VisualServer::get_singleton()->multimesh_instance_set_transform(contact_3d_debug_multimesh,i,t);
- }
- aabb.grow(aabb.get_longest_axis_size()*0.01);
- VisualServer::get_singleton()->multimesh_set_aabb(contact_3d_debug_multimesh,aabb);
- }
}
- if (physics_object_picking && (render_target || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) {
+ if (physics_object_picking && (to_screen_rect==Rect2() || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) {
Vector2 last_pos(1e20,1e20);
CollisionObject *last_object;
@@ -703,20 +736,23 @@ void Viewport::_notification(int p_what) {
}
}
-RID Viewport::get_viewport() const {
+RID Viewport::get_viewport_rid() const {
return viewport;
}
-void Viewport::set_rect(const Rect2& p_rect) {
+void Viewport::set_size(const Size2 &p_size) {
- if (rect==p_rect)
+ if (size==p_size.floor())
return;
- rect=p_rect;
+ size=p_size.floor();
+ VS::get_singleton()->viewport_set_size(viewport,size.width,size.height);
_update_rect();
_update_stretch_transform();
+ emit_signal("size_changed");
+
}
Rect2 Viewport::get_visible_rect() const {
@@ -724,12 +760,12 @@ Rect2 Viewport::get_visible_rect() const {
Rect2 r;
- if (rect.pos==Vector2() && rect.size==Size2()) {
+ if (size==Size2()) {
r=Rect2( Point2(), Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height ) );
} else {
- r=Rect2( rect.pos , rect.size );
+ r=Rect2( Point2() , size );
}
if (size_override) {
@@ -740,15 +776,15 @@ Rect2 Viewport::get_visible_rect() const {
return r;
}
-Rect2 Viewport::get_rect() const {
+Size2 Viewport::get_size() const {
- return rect;
+ return size;
}
void Viewport::_update_listener() {
- if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible()))) {
+ if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible_in_tree()))) {
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, find_world()->get_sound_space());
} else {
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
@@ -759,7 +795,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())))
+ if (is_inside_tree() && audio_listener && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible_in_tree())))
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, find_world_2d()->get_sound_space());
else
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, RID());
@@ -799,14 +835,14 @@ bool Viewport::is_audio_listener_2d() const {
return audio_listener_2d;
}
-void Viewport::set_canvas_transform(const Matrix32& p_transform) {
+void Viewport::set_canvas_transform(const Transform2D& p_transform) {
canvas_transform=p_transform;
VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,find_world_2d()->get_canvas(),canvas_transform);
- Matrix32 xform = (global_canvas_transform * canvas_transform).affine_inverse();
+ Transform2D xform = (global_canvas_transform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss*0.5)));
+ SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5)));
Vector2 ss2 = ss*xform.get_scale();
float panrange = MAX(ss2.x,ss2.y);
@@ -815,7 +851,7 @@ void Viewport::set_canvas_transform(const Matrix32& p_transform) {
}
-Matrix32 Viewport::get_canvas_transform() const{
+Transform2D Viewport::get_canvas_transform() const{
return canvas_transform;
}
@@ -825,13 +861,13 @@ Matrix32 Viewport::get_canvas_transform() const{
void Viewport::_update_global_transform() {
- Matrix32 sxform = stretch_transform * global_canvas_transform;
+ Transform2D sxform = stretch_transform * global_canvas_transform;
VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport,sxform);
- Matrix32 xform = (sxform * canvas_transform).affine_inverse();
+ Transform2D xform = (sxform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss*0.5)));
+ SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5)));
Vector2 ss2 = ss*xform.get_scale();
float panrange = MAX(ss2.x,ss2.y);
@@ -840,7 +876,7 @@ void Viewport::_update_global_transform() {
}
-void Viewport::set_global_canvas_transform(const Matrix32& p_transform) {
+void Viewport::set_global_canvas_transform(const Transform2D& p_transform) {
global_canvas_transform=p_transform;
@@ -849,7 +885,7 @@ void Viewport::set_global_canvas_transform(const Matrix32& p_transform) {
}
-Matrix32 Viewport::get_global_canvas_transform() const{
+Transform2D Viewport::get_global_canvas_transform() const{
return global_canvas_transform;
}
@@ -1171,7 +1207,7 @@ Camera* Viewport::get_camera() const {
}
-Matrix32 Viewport::get_final_transform() const {
+Transform2D Viewport::get_final_transform() const {
return stretch_transform * global_canvas_transform;
}
@@ -1219,10 +1255,10 @@ 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)
+/* if (render_target==p_enable)
return;
render_target=p_enable;
@@ -1238,117 +1274,126 @@ void Viewport::set_as_render_target(bool p_enable){
if (p_enable) {
- render_target_texture_rid = VS::get_singleton()->viewport_get_render_target_texture(viewport);
+ texture_rid = VS::get_singleton()->viewport_get_texture(viewport);
} else {
- render_target_texture_rid=RID();
+ texture_rid=RID();
}
- render_target_texture->set_flags(render_target_texture->flags);
- render_target_texture->emit_changed();
+ texture->set_flags(texture->flags);
+ texture->emit_changed();
update_configuration_warning();
+ */
}
bool Viewport::is_set_as_render_target() const{
return render_target;
+
}
-void Viewport::set_render_target_update_mode(RenderTargetUpdateMode p_mode){
+#endif
+void Viewport::set_update_mode(UpdateMode p_mode){
- render_target_update_mode=p_mode;
- VS::get_singleton()->viewport_set_render_target_update_mode(viewport,VS::RenderTargetUpdateMode(p_mode));
+ update_mode=p_mode;
+ VS::get_singleton()->viewport_set_update_mode(viewport,VS::ViewportUpdateMode(p_mode));
}
-Viewport::RenderTargetUpdateMode Viewport::get_render_target_update_mode() const{
+Viewport::UpdateMode Viewport::get_update_mode() const{
- return render_target_update_mode;
+ return update_mode;
}
-//RID get_render_target_texture() const;
+//RID get_texture() const;
void Viewport::queue_screen_capture(){
- VS::get_singleton()->viewport_queue_screen_capture(viewport);
+ //VS::get_singleton()->viewport_queue_screen_capture(viewport);
}
Image Viewport::get_screen_capture() const {
- return VS::get_singleton()->viewport_get_screen_capture(viewport);
+ //return VS::get_singleton()->viewport_get_screen_capture(viewport);
+ return Image();
}
-Ref<RenderTargetTexture> Viewport::get_render_target_texture() const {
+Ref<ViewportTexture> Viewport::get_texture() const {
- return render_target_texture;
+ return default_texture;
}
-void Viewport::set_render_target_vflip(bool p_enable) {
+void Viewport::set_vflip(bool p_enable) {
- render_target_vflip=p_enable;
- VisualServer::get_singleton()->viewport_set_render_target_vflip(viewport,p_enable);
+ vflip=p_enable;
+ VisualServer::get_singleton()->viewport_set_vflip(viewport,p_enable);
}
-bool Viewport::get_render_target_vflip() const{
+bool Viewport::get_vflip() const{
- return render_target_vflip;
+ return vflip;
}
-void Viewport::set_render_target_clear_on_new_frame(bool p_enable) {
+void Viewport::set_clear_on_new_frame(bool p_enable) {
- render_target_clear_on_new_frame=p_enable;
- VisualServer::get_singleton()->viewport_set_render_target_clear_on_new_frame(viewport,p_enable);
+ clear_on_new_frame=p_enable;
+ //VisualServer::get_singleton()->viewport_set_clear_on_new_frame(viewport,p_enable);
}
-bool Viewport::get_render_target_clear_on_new_frame() const{
+bool Viewport::get_clear_on_new_frame() const{
- return render_target_clear_on_new_frame;
+ return clear_on_new_frame;
}
-void Viewport::render_target_clear() {
+void Viewport::set_shadow_atlas_size(int p_size) {
+
+ if (shadow_atlas_size==p_size)
+ return;
- //render_target_clear=true;
- VisualServer::get_singleton()->viewport_render_target_clear(viewport);
+ shadow_atlas_size=p_size;
+ VS::get_singleton()->viewport_set_shadow_atlas_size(viewport,p_size);
}
-void Viewport::set_render_target_filter(bool p_enable) {
+int Viewport::get_shadow_atlas_size() const{
- if(!render_target)
- return;
+ return shadow_atlas_size;
+}
- render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
+void Viewport::set_shadow_atlas_quadrant_subdiv(int p_quadrant,ShadowAtlasQuadrantSubdiv p_subdiv){
-}
-bool Viewport::get_render_target_filter() const{
+ ERR_FAIL_INDEX(p_quadrant,4);
+ ERR_FAIL_INDEX(p_subdiv,SHADOW_ATLAS_QUADRANT_SUBDIV_MAX);
- return (render_target_texture->get_flags()&Texture::FLAG_FILTER)!=0;
-}
+ if (shadow_atlas_quadrant_subdiv[p_quadrant]==p_subdiv)
+ return;
-void Viewport::set_render_target_gen_mipmaps(bool p_enable) {
+ shadow_atlas_quadrant_subdiv[p_quadrant]=p_subdiv;
+ static const int subdiv[SHADOW_ATLAS_QUADRANT_SUBDIV_MAX]={0,1,4,16,64,256,1024};
- //render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
- render_target_gen_mipmaps=p_enable;
+ VS::get_singleton()->viewport_set_shadow_atlas_quadrant_subdivision(viewport,p_quadrant,subdiv[p_subdiv]);
}
+Viewport::ShadowAtlasQuadrantSubdiv Viewport::get_shadow_atlas_quadrant_subdiv(int p_quadrant) const{
+
+ ERR_FAIL_INDEX_V(p_quadrant,4,SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED);
+ return shadow_atlas_quadrant_subdiv[p_quadrant];
+}
-bool Viewport::get_render_target_gen_mipmaps() const{
- //return (render_target_texture->get_flags()&Texture::FLAG_FILTER)!=0;
- return render_target_gen_mipmaps;
+void Viewport::clear() {
+
+ //clear=true;
+ //VisualServer::get_singleton()->viewport_clear(viewport);
}
-Matrix32 Viewport::_get_input_pre_xform() const {
+Transform2D Viewport::_get_input_pre_xform() const {
- Matrix32 pre_xf;
- if (render_target) {
+ Transform2D pre_xf;
- if (to_screen_rect!=Rect2()) {
- pre_xf.elements[2]=-to_screen_rect.pos;
- pre_xf.scale(rect.size/to_screen_rect.size);
- }
- } else {
+ if (to_screen_rect!=Rect2()) {
- pre_xf.elements[2]=-rect.pos;
+ pre_xf.elements[2]=-to_screen_rect.pos;
+ pre_xf.scale(size/to_screen_rect.size);
}
return pre_xf;
@@ -1356,9 +1401,11 @@ Matrix32 Viewport::_get_input_pre_xform() const {
Vector2 Viewport::_get_window_offset() const {
+ /*
if (parent_control) {
return (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin();
}
+ */
return Vector2();
}
@@ -1372,7 +1419,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
- Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
+ Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y)-vp_ofs);
@@ -1387,7 +1434,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
- Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
+ Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
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)-vp_ofs);
Vector2 r = ai.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
@@ -1408,7 +1455,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
- Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
+ Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)-vp_ofs);
@@ -1420,7 +1467,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
- Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
+ Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)-vp_ofs);
Vector2 r = ai.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
Vector2 s = ai.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
@@ -1454,10 +1501,8 @@ void Viewport::_vp_input(const InputEvent& p_ev) {
}
#endif
- if (parent_control && !parent_control->is_visible())
- return;
- if (render_target && to_screen_rect==Rect2())
+ if (to_screen_rect==Rect2())
return; //if render target, can't get input events
//this one handles system input, p_ev are in system coordinates
@@ -1480,10 +1525,12 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
}
#endif
- if (parent_control && !parent_control->is_visible())
+ /*
+ if (parent_control && !parent_control->is_visible_in_tree())
return;
+ */
- if (render_target && to_screen_rect==Rect2())
+ if (to_screen_rect==Rect2())
return; //if render target, can't get input events
//this one handles system input, p_ev are in system coordinates
@@ -1606,7 +1653,7 @@ void Viewport::_gui_show_tooltip() {
void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
-// _block();
+ //_block();
InputEvent ev = p_input;
@@ -1623,17 +1670,17 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
Control *control = ci->cast_to<Control>();
if (control) {
- control->call_multilevel(SceneStringNames::get_singleton()->_input_event,ev);
+ control->call_multilevel(SceneStringNames::get_singleton()->_gui_input,ev);
if (gui.key_event_accepted)
break;
if (!control->is_inside_tree())
break;
- control->emit_signal(SceneStringNames::get_singleton()->input_event,ev);
+ control->emit_signal(SceneStringNames::get_singleton()->gui_input,ev);
if (!control->is_inside_tree() || control->is_set_as_toplevel())
break;
if (gui.key_event_accepted)
break;
- if (!cant_stop_me_now && control->data.stop_mouse && (ev.type==InputEvent::MOUSE_BUTTON || ev.type==InputEvent::MOUSE_MOTION))
+ if (!cant_stop_me_now && control->data.mouse_filter==Control::MOUSE_FILTER_STOP && (ev.type==InputEvent::MOUSE_BUTTON || ev.type==InputEvent::MOUSE_MOTION))
break;
}
@@ -1655,10 +1702,10 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
for (List<Control*>::Element *E=gui.subwindows.back();E;E=E->prev()) {
Control *sw = E->get();
- if (!sw->is_visible())
+ if (!sw->is_visible_in_tree())
continue;
- Matrix32 xform;
+ Transform2D xform;
CanvasItem *pci = sw->get_parent_item();
if (pci)
xform=pci->get_global_transform_with_canvas();
@@ -1675,10 +1722,10 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
for (List<Control*>::Element *E=gui.roots.back();E;E=E->prev()) {
Control *sw = E->get();
- if (!sw->is_visible())
+ if (!sw->is_visible_in_tree())
continue;
- Matrix32 xform;
+ Transform2D xform;
CanvasItem *pci = sw->get_parent_item();
if (pci)
xform=pci->get_global_transform_with_canvas();
@@ -1696,7 +1743,7 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
}
-Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_global,const Matrix32& p_xform,Matrix32& r_inv_xform) {
+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>())
return NULL;
@@ -1704,17 +1751,20 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
Control *c=p_node->cast_to<Control>();
if (c) {
- // print_line("at "+String(c->get_path())+" POS "+c->get_pos()+" bt "+p_xform);
+ //print_line("at "+String(c->get_path())+" POS "+c->get_pos()+" bt "+p_xform);
}
//subwindows first!!
- if (p_node->is_hidden()) {
+ if (!p_node->is_visible()) {
//return _find_next_visible_control_at_pos(p_node,p_global,r_inv_xform);
return NULL; //canvas item hidden, discard
}
- Matrix32 matrix = p_xform * p_node->get_transform();
+ Transform2D matrix = p_xform * p_node->get_transform();
+ // matrix.basis_determinant() == 0.0f implies that node does not exist on scene
+ if(matrix.basis_determinant() == 0.0f)
+ return NULL;
if (!c || !c->clips_input() || c->has_point(matrix.affine_inverse().xform(p_global))) {
@@ -1739,7 +1789,7 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
matrix.affine_invert();
//conditions for considering this as a valid control for return
- if (!c->data.ignore_mouse && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c!=gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) {
+ if (c->data.mouse_filter!=Control::MOUSE_FILTER_IGNORE && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c!=gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) {
r_inv_xform=matrix;
return c;
} else
@@ -1754,9 +1804,11 @@ void Viewport::_gui_input_event(InputEvent p_event) {
return;
}
//?
-// if (!is_visible()) {
-// return; //simple and plain
-// }
+ /*
+ if (!is_visible()) {
+ return; //simple and plain
+ }
+ */
switch(p_event.type) {
@@ -1786,7 +1838,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
Vector2 pos = top->get_global_transform_with_canvas().affine_inverse().xform(mpos);
if (!top->has_point(pos)) {
- if (top->data.modal_exclusive || top->data.modal_frame==OS::get_singleton()->get_frames_drawn()) {
+ if (top->data.modal_exclusive || top->data.modal_frame==Engine::get_singleton()->get_frames_drawn()) {
//cancel event, sorry, modal exclusive EATS UP ALL
//alternative, you can't pop out a window the same frame it was made modal (fixes many issues)
get_tree()->set_input_as_handled();
@@ -1805,10 +1857,10 @@ void Viewport::_gui_input_event(InputEvent p_event) {
//Matrix32 parent_xform;
- //if (data.parent_canvas_item)
- // parent_xform=data.parent_canvas_item->get_global_transform();
-
-
+ /*
+ if (data.parent_canvas_item)
+ parent_xform=data.parent_canvas_item->get_global_transform();
+ */
gui.mouse_focus = _gui_find_control(pos);
//print_line("has mf "+itos(gui.mouse_focus!=NULL));
@@ -1839,7 +1891,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
Array arr;
arr.push_back(gui.mouse_focus->get_path());
- arr.push_back(gui.mouse_focus->get_type());
+ arr.push_back(gui.mouse_focus->get_class());
ScriptDebugger::get_singleton()->send_message("click_ctrl",arr);
}
@@ -1859,7 +1911,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
_gui_call_input(gui.mouse_focus,p_event);
}
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
@@ -1936,7 +1988,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}*/
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
}
@@ -2016,7 +2068,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
- Matrix32 localizer = over->get_global_transform_with_canvas().affine_inverse();
+ Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
Size2 pos = localizer.xform(mpos);
Vector2 speed = localizer.basis_xform(Point2(p_event.mouse_motion.speed_x,p_event.mouse_motion.speed_y));
Vector2 rel = localizer.basis_xform(Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y));
@@ -2101,12 +2153,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
} break;
case InputEvent::ACTION:
- case InputEvent::JOYSTICK_BUTTON:
- case InputEvent::JOYSTICK_MOTION:
+ case InputEvent::JOYPAD_BUTTON:
+ case InputEvent::JOYPAD_MOTION:
case InputEvent::KEY: {
- if (gui.key_focus && !gui.key_focus->is_visible()) {
+ if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
gui.key_focus->release_focus();
}
@@ -2114,9 +2166,9 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.key_event_accepted=false;
if (gui.key_focus->can_process()) {
- gui.key_focus->call_multilevel("_input_event",p_event);
+ gui.key_focus->call_multilevel(SceneStringNames::get_singleton()->_gui_input,p_event);
if (gui.key_focus) //maybe lost it
- gui.key_focus->emit_signal(SceneStringNames::get_singleton()->input_event,p_event);
+ gui.key_focus->emit_signal(SceneStringNames::get_singleton()->gui_input,p_event);
}
@@ -2238,7 +2290,7 @@ void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID
if (!pfoc)
return;
- if (!pfoc->is_inside_tree() || !pfoc->is_visible())
+ if (!pfoc->is_inside_tree() || !pfoc->is_visible_in_tree())
return;
pfoc->grab_focus();
} else {
@@ -2375,7 +2427,7 @@ void Viewport::_gui_control_grab_focus(Control* p_control) {
if (gui.key_focus && gui.key_focus==p_control)
return;
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus");
gui.key_focus=p_control;
p_control->notification(Control::NOTIFICATION_FOCUS_ENTER);
p_control->update();
@@ -2424,7 +2476,7 @@ void Viewport::_gui_grab_click_focus(Control *p_control) {
mb.y=click.y;
mb.button_index=gui.mouse_focus_button;
mb.pressed=false;
- gui.mouse_focus->call_deferred("_input_event",ie);
+ gui.mouse_focus->call_deferred(SceneStringNames::get_singleton()->_gui_input,ie);
gui.mouse_focus=p_control;
@@ -2434,7 +2486,7 @@ void Viewport::_gui_grab_click_focus(Control *p_control) {
mb.y=click.y;
mb.button_index=gui.mouse_focus_button;
mb.pressed=true;
- gui.mouse_focus->call_deferred("_input_event",ie);
+ gui.mouse_focus->call_deferred(SceneStringNames::get_singleton()->_gui_input,ie);
}
}
@@ -2518,17 +2570,18 @@ bool Viewport::is_using_own_world() const {
return own_world.is_valid();
}
-void Viewport::set_render_target_to_screen_rect(const Rect2& p_rect) {
+void Viewport::set_attach_to_screen_rect(const Rect2& p_rect) {
+ VS::get_singleton()->viewport_attach_to_screen(viewport,p_rect);
to_screen_rect=p_rect;
- VisualServer::get_singleton()->viewport_set_render_target_to_screen_rect(viewport,to_screen_rect);
}
-Rect2 Viewport::get_render_target_to_screen_rect() const{
+Rect2 Viewport::get_attach_to_screen_rect() const{
return to_screen_rect;
}
+
void Viewport::set_physics_object_picking(bool p_enable) {
physics_object_picking=p_enable;
@@ -2542,7 +2595,7 @@ void Viewport::set_physics_object_picking(bool p_enable) {
Vector2 Viewport::get_camera_coords(const Vector2 &p_viewport_coords) const {
- Matrix32 xf = get_final_transform();
+ Transform2D xf = get_final_transform();
return xf.xform(p_viewport_coords);
@@ -2550,7 +2603,7 @@ Vector2 Viewport::get_camera_coords(const Vector2 &p_viewport_coords) const {
Vector2 Viewport::get_camera_rect_size() const {
- return last_vp_rect.size;
+ return size;
}
@@ -2574,6 +2627,16 @@ bool Viewport::is_input_disabled() const {
return disable_input;
}
+void Viewport::set_disable_3d(bool p_disable) {
+ disable_3d=p_disable;
+ VS::get_singleton()->viewport_set_disable_3d(viewport,p_disable);
+}
+
+bool Viewport::is_3d_disabled() const {
+
+ return disable_3d;
+}
+
Variant Viewport::gui_get_drag_data() const {
return gui.drag_data;
}
@@ -2584,129 +2647,200 @@ 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() && !get_parent()->cast_to<Control>() && !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.");
- }
+ }*/
return String();
}
+void Viewport::gui_reset_canvas_sort_index() {
+ gui.canvas_sort_index=0;
+}
+int Viewport::gui_get_canvas_sort_index() {
+
+ return gui.canvas_sort_index++;
+}
+
+void Viewport::set_msaa(MSAA p_msaa) {
+
+ ERR_FAIL_INDEX(p_msaa,5);
+ if (msaa==p_msaa)
+ return;
+ msaa=p_msaa;
+ VS::get_singleton()->viewport_set_msaa(viewport,VS::ViewportMSAA(p_msaa));
+}
+
+Viewport::MSAA Viewport::get_msaa() const {
+
+ return msaa;
+}
+
+void Viewport::set_hdr(bool p_hdr) {
+
+ if (hdr==p_hdr)
+ return;
+
+ hdr=p_hdr;
+ VS::get_singleton()->viewport_set_hdr(viewport,p_hdr);
+
+}
+
+bool Viewport::get_hdr() const{
+
+ return hdr;
+}
+
+
+
void Viewport::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_rect","rect"), &Viewport::set_rect);
- ObjectTypeDB::bind_method(_MD("get_rect"), &Viewport::get_rect);
- ObjectTypeDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
- ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
- ObjectTypeDB::bind_method(_MD("find_world_2d:World2D"), &Viewport::find_world_2d);
- ObjectTypeDB::bind_method(_MD("set_world","world:World"), &Viewport::set_world);
- ObjectTypeDB::bind_method(_MD("get_world:World"), &Viewport::get_world);
- ObjectTypeDB::bind_method(_MD("find_world:World"), &Viewport::find_world);
+ ClassDB::bind_method(_MD("set_size","size"), &Viewport::set_size);
+ ClassDB::bind_method(_MD("get_size"), &Viewport::get_size);
+ ClassDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
+ ClassDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
+ ClassDB::bind_method(_MD("find_world_2d:World2D"), &Viewport::find_world_2d);
+ ClassDB::bind_method(_MD("set_world","world:World"), &Viewport::set_world);
+ ClassDB::bind_method(_MD("get_world:World"), &Viewport::get_world);
+ ClassDB::bind_method(_MD("find_world:World"), &Viewport::find_world);
+
+ ClassDB::bind_method(_MD("set_canvas_transform","xform"), &Viewport::set_canvas_transform);
+ ClassDB::bind_method(_MD("get_canvas_transform"), &Viewport::get_canvas_transform);
- ObjectTypeDB::bind_method(_MD("set_canvas_transform","xform"), &Viewport::set_canvas_transform);
- ObjectTypeDB::bind_method(_MD("get_canvas_transform"), &Viewport::get_canvas_transform);
+ ClassDB::bind_method(_MD("set_global_canvas_transform","xform"), &Viewport::set_global_canvas_transform);
+ ClassDB::bind_method(_MD("get_global_canvas_transform"), &Viewport::get_global_canvas_transform);
+ ClassDB::bind_method(_MD("get_final_transform"), &Viewport::get_final_transform);
- ObjectTypeDB::bind_method(_MD("set_global_canvas_transform","xform"), &Viewport::set_global_canvas_transform);
- ObjectTypeDB::bind_method(_MD("get_global_canvas_transform"), &Viewport::get_global_canvas_transform);
- ObjectTypeDB::bind_method(_MD("get_final_transform"), &Viewport::get_final_transform);
+ ClassDB::bind_method(_MD("get_visible_rect"), &Viewport::get_visible_rect);
+ ClassDB::bind_method(_MD("set_transparent_background","enable"), &Viewport::set_transparent_background);
+ ClassDB::bind_method(_MD("has_transparent_background"), &Viewport::has_transparent_background);
- ObjectTypeDB::bind_method(_MD("get_visible_rect"), &Viewport::get_visible_rect);
- ObjectTypeDB::bind_method(_MD("set_transparent_background","enable"), &Viewport::set_transparent_background);
- ObjectTypeDB::bind_method(_MD("has_transparent_background"), &Viewport::has_transparent_background);
+ ClassDB::bind_method(_MD("_parent_visibility_changed"), &Viewport::_parent_visibility_changed);
- ObjectTypeDB::bind_method(_MD("_parent_visibility_changed"), &Viewport::_parent_visibility_changed);
+ ClassDB::bind_method(_MD("_parent_resized"), &Viewport::_parent_resized);
+ ClassDB::bind_method(_MD("_vp_input"), &Viewport::_vp_input);
+ ClassDB::bind_method(_MD("_vp_input_text","text"), &Viewport::_vp_input_text);
+ ClassDB::bind_method(_MD("_vp_unhandled_input"), &Viewport::_vp_unhandled_input);
- ObjectTypeDB::bind_method(_MD("_parent_resized"), &Viewport::_parent_resized);
- ObjectTypeDB::bind_method(_MD("_vp_input"), &Viewport::_vp_input);
- ObjectTypeDB::bind_method(_MD("_vp_input_text","text"), &Viewport::_vp_input_text);
- ObjectTypeDB::bind_method(_MD("_vp_unhandled_input"), &Viewport::_vp_unhandled_input);
+ ClassDB::bind_method(_MD("set_size_override","enable","size","margin"), &Viewport::set_size_override,DEFVAL(Size2(-1,-1)),DEFVAL(Size2(0,0)));
+ ClassDB::bind_method(_MD("get_size_override"), &Viewport::get_size_override);
+ ClassDB::bind_method(_MD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
+ ClassDB::bind_method(_MD("set_size_override_stretch","enabled"), &Viewport::set_size_override_stretch);
+ ClassDB::bind_method(_MD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
+ ClassDB::bind_method(_MD("queue_screen_capture"), &Viewport::queue_screen_capture);
+ ClassDB::bind_method(_MD("get_screen_capture"), &Viewport::get_screen_capture);
- ObjectTypeDB::bind_method(_MD("set_size_override","enable","size","margin"), &Viewport::set_size_override,DEFVAL(Size2(-1,-1)),DEFVAL(Size2(0,0)));
- ObjectTypeDB::bind_method(_MD("get_size_override"), &Viewport::get_size_override);
- ObjectTypeDB::bind_method(_MD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
- ObjectTypeDB::bind_method(_MD("set_size_override_stretch","enabled"), &Viewport::set_size_override_stretch);
- ObjectTypeDB::bind_method(_MD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
- ObjectTypeDB::bind_method(_MD("queue_screen_capture"), &Viewport::queue_screen_capture);
- ObjectTypeDB::bind_method(_MD("get_screen_capture"), &Viewport::get_screen_capture);
- ObjectTypeDB::bind_method(_MD("set_as_render_target","enable"), &Viewport::set_as_render_target);
- ObjectTypeDB::bind_method(_MD("is_set_as_render_target"), &Viewport::is_set_as_render_target);
+ ClassDB::bind_method(_MD("set_vflip","enable"), &Viewport::set_vflip);
+ ClassDB::bind_method(_MD("get_vflip"), &Viewport::get_vflip);
- ObjectTypeDB::bind_method(_MD("set_render_target_vflip","enable"), &Viewport::set_render_target_vflip);
- ObjectTypeDB::bind_method(_MD("get_render_target_vflip"), &Viewport::get_render_target_vflip);
+ ClassDB::bind_method(_MD("set_clear_on_new_frame","enable"), &Viewport::set_clear_on_new_frame);
+ ClassDB::bind_method(_MD("get_clear_on_new_frame"), &Viewport::get_clear_on_new_frame);
- ObjectTypeDB::bind_method(_MD("set_render_target_clear_on_new_frame","enable"), &Viewport::set_render_target_clear_on_new_frame);
- ObjectTypeDB::bind_method(_MD("get_render_target_clear_on_new_frame"), &Viewport::get_render_target_clear_on_new_frame);
+ ClassDB::bind_method(_MD("clear"), &Viewport::clear);
+ ClassDB::bind_method(_MD("set_update_mode","mode"), &Viewport::set_update_mode);
+ ClassDB::bind_method(_MD("get_update_mode"), &Viewport::get_update_mode);
- ObjectTypeDB::bind_method(_MD("render_target_clear"), &Viewport::render_target_clear);
+ ClassDB::bind_method(_MD("set_msaa","msaa"), &Viewport::set_msaa);
+ ClassDB::bind_method(_MD("get_msaa"), &Viewport::get_msaa);
- ObjectTypeDB::bind_method(_MD("set_render_target_filter","enable"), &Viewport::set_render_target_filter);
- ObjectTypeDB::bind_method(_MD("get_render_target_filter"), &Viewport::get_render_target_filter);
+ ClassDB::bind_method(_MD("set_hdr","enable"), &Viewport::set_hdr);
+ ClassDB::bind_method(_MD("get_hdr"), &Viewport::get_hdr);
- ObjectTypeDB::bind_method(_MD("set_render_target_gen_mipmaps","enable"), &Viewport::set_render_target_gen_mipmaps);
- ObjectTypeDB::bind_method(_MD("get_render_target_gen_mipmaps"), &Viewport::get_render_target_gen_mipmaps);
+ ClassDB::bind_method(_MD("get_texture:ViewportTexture"), &Viewport::get_texture);
- ObjectTypeDB::bind_method(_MD("set_render_target_update_mode","mode"), &Viewport::set_render_target_update_mode);
- ObjectTypeDB::bind_method(_MD("get_render_target_update_mode"), &Viewport::get_render_target_update_mode);
+ ClassDB::bind_method(_MD("set_physics_object_picking","enable"), &Viewport::set_physics_object_picking);
+ ClassDB::bind_method(_MD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
- ObjectTypeDB::bind_method(_MD("get_render_target_texture:RenderTargetTexture"), &Viewport::get_render_target_texture);
+ ClassDB::bind_method(_MD("get_viewport_rid"), &Viewport::get_viewport_rid);
+ ClassDB::bind_method(_MD("input","local_event"), &Viewport::input);
+ ClassDB::bind_method(_MD("unhandled_input","local_event"), &Viewport::unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_physics_object_picking","enable"), &Viewport::set_physics_object_picking);
- ObjectTypeDB::bind_method(_MD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
+ ClassDB::bind_method(_MD("update_worlds"), &Viewport::update_worlds);
- ObjectTypeDB::bind_method(_MD("get_viewport"), &Viewport::get_viewport);
- ObjectTypeDB::bind_method(_MD("input","local_event"), &Viewport::input);
- ObjectTypeDB::bind_method(_MD("unhandled_input","local_event"), &Viewport::unhandled_input);
+ ClassDB::bind_method(_MD("set_use_own_world","enable"), &Viewport::set_use_own_world);
+ ClassDB::bind_method(_MD("is_using_own_world"), &Viewport::is_using_own_world);
- ObjectTypeDB::bind_method(_MD("update_worlds"), &Viewport::update_worlds);
+ ClassDB::bind_method(_MD("get_camera:Camera"), &Viewport::get_camera);
- ObjectTypeDB::bind_method(_MD("set_use_own_world","enable"), &Viewport::set_use_own_world);
- ObjectTypeDB::bind_method(_MD("is_using_own_world"), &Viewport::is_using_own_world);
+ ClassDB::bind_method(_MD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener);
+ ClassDB::bind_method(_MD("is_audio_listener","enable"), &Viewport::is_audio_listener);
- ObjectTypeDB::bind_method(_MD("get_camera:Camera"), &Viewport::get_camera);
+ ClassDB::bind_method(_MD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d);
+ ClassDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d);
+ ClassDB::bind_method(_MD("set_attach_to_screen_rect","rect"), &Viewport::set_attach_to_screen_rect);
- ObjectTypeDB::bind_method(_MD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener);
- ObjectTypeDB::bind_method(_MD("is_audio_listener","enable"), &Viewport::is_audio_listener);
+ ClassDB::bind_method(_MD("get_mouse_pos"), &Viewport::get_mouse_pos);
+ ClassDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse);
- ObjectTypeDB::bind_method(_MD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d);
- ObjectTypeDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d);
- ObjectTypeDB::bind_method(_MD("set_render_target_to_screen_rect","rect"), &Viewport::set_render_target_to_screen_rect);
+ ClassDB::bind_method(_MD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
+ ClassDB::bind_method(_MD("gui_get_drag_data:Variant"), &Viewport::gui_get_drag_data);
- ObjectTypeDB::bind_method(_MD("get_mouse_pos"), &Viewport::get_mouse_pos);
- ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse);
+ ClassDB::bind_method(_MD("set_disable_input","disable"), &Viewport::set_disable_input);
+ ClassDB::bind_method(_MD("is_input_disabled"), &Viewport::is_input_disabled);
- ObjectTypeDB::bind_method(_MD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
- ObjectTypeDB::bind_method(_MD("gui_get_drag_data:Variant"), &Viewport::gui_get_drag_data);
+ ClassDB::bind_method(_MD("set_disable_3d","disable"), &Viewport::set_disable_3d);
+ ClassDB::bind_method(_MD("is_3d_disabled"), &Viewport::is_3d_disabled);
- ObjectTypeDB::bind_method(_MD("set_disable_input","disable"), &Viewport::set_disable_input);
- ObjectTypeDB::bind_method(_MD("is_input_disabled"), &Viewport::is_input_disabled);
+ ClassDB::bind_method(_MD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
+ ClassDB::bind_method(_MD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
- ObjectTypeDB::bind_method(_MD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
- ObjectTypeDB::bind_method(_MD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
+ ClassDB::bind_method(_MD("set_shadow_atlas_size","size"), &Viewport::set_shadow_atlas_size);
+ ClassDB::bind_method(_MD("get_shadow_atlas_size"), &Viewport::get_shadow_atlas_size);
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"), _SCS("set_rect"), _SCS("get_rect") );
+ ClassDB::bind_method(_MD("set_shadow_atlas_quadrant_subdiv","quadrant","subdiv"), &Viewport::set_shadow_atlas_quadrant_subdiv);
+ ClassDB::bind_method(_MD("get_shadow_atlas_quadrant_subdiv","quadrant"), &Viewport::get_shadow_atlas_quadrant_subdiv);
+
+ ADD_PROPERTY( PropertyInfo(Variant::RECT2,"size"), _SCS("set_size"), _SCS("get_size") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"own_world"), _SCS("set_use_own_world"), _SCS("is_using_own_world") );
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world",PROPERTY_HINT_RESOURCE_TYPE,"World"), _SCS("set_world"), _SCS("get_world") );
-// ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") );
+ //ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/enabled"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/v_flip"), _SCS("set_render_target_vflip"), _SCS("get_render_target_vflip") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/clear_on_new_frame"), _SCS("set_render_target_clear_on_new_frame"), _SCS("get_render_target_clear_on_new_frame") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/filter"), _SCS("set_render_target_filter"), _SCS("get_render_target_filter") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/gen_mipmaps"), _SCS("set_render_target_gen_mipmaps"), _SCS("get_render_target_gen_mipmaps") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target/update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_render_target_update_mode"), _SCS("get_render_target_update_mode") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"physics/object_picking"), _SCS("set_physics_object_picking"), _SCS("get_physics_object_picking") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gui/disable_input"), _SCS("set_disable_input"), _SCS("is_input_disabled") );
+ ADD_GROUP("Rendering","");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"msaa",PROPERTY_HINT_ENUM,"Disabled,2x,4x,8x,16x"), _SCS("set_msaa"), _SCS("get_msaa") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"hdr"), _SCS("set_hdr"), _SCS("get_hdr") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"disable_3d"), _SCS("set_disable_3d"), _SCS("is_3d_disabled") );
+ ADD_GROUP("Render Target","render_target_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target_v_flip"), _SCS("set_vflip"), _SCS("get_vflip") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target_clear_on_new_frame"), _SCS("set_clear_on_new_frame"), _SCS("get_clear_on_new_frame") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target_update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_update_mode"), _SCS("get_update_mode") );
+ ADD_GROUP("Audio Listener","audio_listener_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener_enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener_enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener") );
+ ADD_GROUP("Physics","physics_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"physics_object_picking"), _SCS("set_physics_object_picking"), _SCS("get_physics_object_picking") );
+ ADD_GROUP("GUI","gui_");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gui_disable_input"), _SCS("set_disable_input"), _SCS("is_input_disabled") );
+ ADD_GROUP("Shadow Atlas","shadow_atlas_");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_atlas_size"), _SCS("set_shadow_atlas_size"), _SCS("get_shadow_atlas_size") );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_0",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),0 );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_1",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),1 );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_2",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),2 );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_3",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),3 );
ADD_SIGNAL(MethodInfo("size_changed"));
- BIND_CONSTANT( RENDER_TARGET_UPDATE_DISABLED );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_ONCE );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_WHEN_VISIBLE );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_ALWAYS );
+ 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( MSAA_DISABLED );
+ BIND_CONSTANT( MSAA_2X );
+ BIND_CONSTANT( MSAA_4X );
+ BIND_CONSTANT( MSAA_8X );
+ BIND_CONSTANT( MSAA_16X );
}
@@ -2720,6 +2854,13 @@ Viewport::Viewport() {
world_2d = Ref<World2D>( memnew( World2D ));
viewport = VisualServer::get_singleton()->viewport_create();
+ texture_rid=VisualServer::get_singleton()->viewport_get_texture(viewport);
+ texture_flags=0;
+
+ default_texture.instance();
+ default_texture->vp=const_cast<Viewport*>(this);
+ viewport_textures.insert(default_texture.ptr());
+
internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener=false;
internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create();
@@ -2731,19 +2872,27 @@ Viewport::Viewport() {
size_override=false;
size_override_stretch=false;
size_override_size=Size2(1,1);
- render_target_gen_mipmaps=false;
- render_target=false;
- render_target_vflip=false;
- render_target_clear_on_new_frame=true;
- //render_target_clear=true;
- render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE;
- render_target_texture = Ref<RenderTargetTexture>( memnew( RenderTargetTexture(this) ) );
+ gen_mipmaps=false;
+
+ vflip=false;
+ clear_on_new_frame=true;
+ //clear=true;
+ update_mode=UPDATE_WHEN_VISIBLE;
physics_object_picking=false;
physics_object_capture=0;
physics_object_over=0;
physics_last_mousepos=Vector2(1e20,1e20);
+ shadow_atlas_size=0;
+ for(int i=0;i<4;i++) {
+ shadow_atlas_quadrant_subdiv[i]=SHADOW_ATLAS_QUADRANT_SUBDIV_MAX;
+ }
+ set_shadow_atlas_quadrant_subdiv(0,SHADOW_ATLAS_QUADRANT_SUBDIV_4);
+ set_shadow_atlas_quadrant_subdiv(1,SHADOW_ATLAS_QUADRANT_SUBDIV_4);
+ set_shadow_atlas_quadrant_subdiv(2,SHADOW_ATLAS_QUADRANT_SUBDIV_16);
+ set_shadow_atlas_quadrant_subdiv(3,SHADOW_ATLAS_QUADRANT_SUBDIV_64);
+
String id=itos(get_instance_ID());
input_group = "_vp_input"+id;
@@ -2752,20 +2901,23 @@ Viewport::Viewport() {
unhandled_key_input_group = "_vp_unhandled_key_input"+id;
disable_input=false;
+ disable_3d=false;
//window tooltip
gui.tooltip_timer = -1;
//gui.tooltip_timer->force_parent_owned();
- gui.tooltip_delay=GLOBAL_DEF("display/tooltip_delay",0.7);
+ gui.tooltip_delay=GLOBAL_DEF("gui/timers/tooltip_delay_sec",0.7);
gui.tooltip=NULL;
gui.tooltip_label=NULL;
gui.drag_preview=NULL;
gui.drag_attempted=false;
+ gui.canvas_sort_index=0;
- parent_control=NULL;
+ msaa=MSAA_DISABLED;
+ hdr=false;
}
@@ -2773,11 +2925,14 @@ Viewport::Viewport() {
Viewport::~Viewport() {
+ //erase itself from viewport textures
+ for(Set<ViewportTexture*>::Element *E=viewport_textures.front();E;E=E->next()) {
+ E->get()->vp=NULL;
+ }
VisualServer::get_singleton()->free( viewport );
SpatialSoundServer::get_singleton()->free(internal_listener);
SpatialSound2DServer::get_singleton()->free(internal_listener_2d);
- if (render_target_texture.is_valid())
- render_target_texture->vp=NULL; //so if used, will crash
+
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index f657f0507d..2831d177c9 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -48,17 +48,24 @@ class Label;
class Timer;
class Viewport;
-class RenderTargetTexture : public Texture {
+class ViewportTexture : public Texture {
- OBJ_TYPE( RenderTargetTexture, Texture );
+ GDCLASS( ViewportTexture, Texture );
- int flags;
-friend class Viewport;
- Viewport *vp;
+ NodePath path;
+friend class Viewport;
+ Viewport* vp;
+protected:
+ static void _bind_methods();
public:
+ void set_viewport_path_in_scene(const NodePath& p_path);
+ NodePath get_viewport_path_in_scene() const;
+
+ virtual void setup_local_to_scene();
+
virtual int get_width() const;
virtual int get_height() const;
@@ -70,28 +77,49 @@ public:
virtual void set_flags(uint32_t p_flags);
virtual uint32_t get_flags() const;
- RenderTargetTexture(Viewport *p_vp=NULL);
+ ViewportTexture();
+ ~ViewportTexture();
};
class Viewport : public Node {
- OBJ_TYPE( Viewport, Node );
+ GDCLASS( Viewport, Node );
public:
- enum RenderTargetUpdateMode {
- RENDER_TARGET_UPDATE_DISABLED,
- RENDER_TARGET_UPDATE_ONCE, //then goes to disabled
- RENDER_TARGET_UPDATE_WHEN_VISIBLE, // default
- RENDER_TARGET_UPDATE_ALWAYS
+ enum UpdateMode {
+ UPDATE_DISABLED,
+ UPDATE_ONCE, //then goes to disabled
+ UPDATE_WHEN_VISIBLE, // default
+ UPDATE_ALWAYS
+ };
+
+ enum ShadowAtlasQuadrantSubdiv {
+ SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_1,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_4,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_16,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_64,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_256,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_1024,
+ SHADOW_ATLAS_QUADRANT_SUBDIV_MAX,
+
+ };
+
+ enum MSAA {
+ MSAA_DISABLED,
+ MSAA_2X,
+ MSAA_4X,
+ MSAA_8X,
+ MSAA_16X,
};
private:
-friend class RenderTargetTexture;
+friend class ViewportTexture;
+
- Control *parent_control;
Viewport *parent;
Listener *listener;
@@ -101,7 +129,6 @@ friend class RenderTargetTexture;
Set<Camera*> cameras;
RID viewport;
- RID canvas_item;
RID current_canvas;
bool audio_listener;
@@ -110,19 +137,17 @@ friend class RenderTargetTexture;
bool audio_listener_2d;
RID internal_listener_2d;
- Matrix32 canvas_transform;
- Matrix32 global_canvas_transform;
- Matrix32 stretch_transform;
+ Transform2D canvas_transform;
+ Transform2D global_canvas_transform;
+ Transform2D stretch_transform;
- Rect2 rect;
+ Size2 size;
Rect2 to_screen_rect;
RID contact_2d_debug;
RID contact_3d_debug_multimesh;
RID contact_3d_debug_instance;
-
-
bool size_override;
bool size_override_stretch;
Size2 size_override_size;
@@ -131,10 +156,10 @@ friend class RenderTargetTexture;
Rect2 last_vp_rect;
bool transparent_bg;
- bool render_target_vflip;
- bool render_target_clear_on_new_frame;
- bool render_target_filter;
- bool render_target_gen_mipmaps;
+ bool vflip;
+ bool clear_on_new_frame;
+ bool filter;
+ bool gen_mipmaps;
bool physics_object_picking;
List<InputEvent> physics_picking_events;
@@ -170,10 +195,20 @@ friend class RenderTargetTexture;
void _update_stretch_transform();
void _update_global_transform();
- bool render_target;
- RenderTargetUpdateMode render_target_update_mode;
- RID render_target_texture_rid;
- Ref<RenderTargetTexture> render_target_texture;
+
+ bool disable_3d;
+ UpdateMode update_mode;
+ RID texture_rid;
+ uint32_t texture_flags;
+
+ int shadow_atlas_size;
+ ShadowAtlasQuadrantSubdiv shadow_atlas_quadrant_subdiv[4];
+
+ MSAA msaa;
+ bool hdr;
+
+ Ref<ViewportTexture> default_texture;
+ Set<ViewportTexture*> viewport_textures;
struct GUI {
@@ -197,11 +232,12 @@ friend class RenderTargetTexture;
float tooltip_delay;
List<Control*> modal_stack;
unsigned int cancelled_input_ID;
- Matrix32 focus_inv_xform;
+ Transform2D focus_inv_xform;
bool subwindow_order_dirty;
List<Control*> subwindows;
bool roots_order_dirty;
List<Control*> roots;
+ int canvas_sort_index; //for sorting items with canvas as root
GUI();
@@ -214,14 +250,14 @@ friend class RenderTargetTexture;
void _gui_sort_roots();
void _gui_sort_modal_stack();
Control* _gui_find_control(const Point2& p_global);
- Control* _gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_global,const Matrix32& p_xform,Matrix32& r_inv_xform);
+ Control* _gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_global,const Transform2D& p_xform,Transform2D& r_inv_xform);
void _gui_input_event(InputEvent p_event);
void update_worlds();
- _FORCE_INLINE_ Matrix32 _get_input_pre_xform() const;
+ _FORCE_INLINE_ Transform2D _get_input_pre_xform() const;
void _vp_enter_tree();
void _vp_exit_tree();
@@ -299,10 +335,12 @@ public:
void set_as_audio_listener_2d(bool p_enable);
bool is_audio_listener_2d() const;
- void set_rect(const Rect2& p_rect);
- Rect2 get_rect() const;
+ void set_size(const Size2& p_size);
+
+
+ Size2 get_size() const;
Rect2 get_visible_rect() const;
- RID get_viewport() const;
+ RID get_viewport_rid() const;
void set_world(const Ref<World>& p_world);
void set_world_2d(const Ref<World2D>& p_world_2d);
@@ -313,13 +351,13 @@ public:
Ref<World2D> find_world_2d() const;
- void set_canvas_transform(const Matrix32& p_transform);
- Matrix32 get_canvas_transform() const;
+ void set_canvas_transform(const Transform2D& p_transform);
+ Transform2D get_canvas_transform() const;
- void set_global_canvas_transform(const Matrix32& p_transform);
- Matrix32 get_global_canvas_transform() const;
+ void set_global_canvas_transform(const Transform2D& p_transform);
+ Transform2D get_global_canvas_transform() const;
- Matrix32 get_final_transform() const;
+ Transform2D get_final_transform() const;
void set_transparent_background(bool p_enable);
bool has_transparent_background() const;
@@ -327,30 +365,34 @@ public:
void set_size_override(bool p_enable,const Size2& p_size=Size2(-1,-1),const Vector2& p_margin=Vector2());
Size2 get_size_override() const;
+
bool is_size_override_enabled() const;
void set_size_override_stretch(bool p_enable);
bool is_size_override_stretch_enabled() const;
- void set_as_render_target(bool p_enable);
- bool is_set_as_render_target() const;
+ void set_vflip(bool p_enable);
+ bool get_vflip() const;
- void set_render_target_vflip(bool p_enable);
- bool get_render_target_vflip() const;
+ void set_clear_on_new_frame(bool p_enable);
+ bool get_clear_on_new_frame() const;
+ void clear();
- void set_render_target_clear_on_new_frame(bool p_enable);
- bool get_render_target_clear_on_new_frame() const;
- void render_target_clear();
- void set_render_target_filter(bool p_enable);
- bool get_render_target_filter() const;
+ void set_update_mode(UpdateMode p_mode);
+ UpdateMode get_update_mode() const;
+ Ref<ViewportTexture> get_texture() const;
- void set_render_target_gen_mipmaps(bool p_enable);
- bool get_render_target_gen_mipmaps() const;
+ void set_shadow_atlas_size(int p_size);
+ int get_shadow_atlas_size() const;
- void set_render_target_update_mode(RenderTargetUpdateMode p_mode);
- RenderTargetUpdateMode get_render_target_update_mode() const;
- Ref<RenderTargetTexture> get_render_target_texture() const;
+ void set_shadow_atlas_quadrant_subdiv(int p_quadrant,ShadowAtlasQuadrantSubdiv p_subdiv);
+ ShadowAtlasQuadrantSubdiv get_shadow_atlas_quadrant_subdiv(int p_quadrant) const;
+ void set_msaa(MSAA p_msaa);
+ MSAA get_msaa() const;
+
+ void set_hdr(bool p_hdr);
+ bool get_hdr() const;
Vector2 get_camera_coords(const Vector2& p_viewport_coords) const;
Vector2 get_camera_rect_size() const;
@@ -367,8 +409,11 @@ public:
void set_disable_input(bool p_disable);
bool is_input_disabled() const;
- void set_render_target_to_screen_rect(const Rect2& p_rect);
- Rect2 get_render_target_to_screen_rect() const;
+ void set_disable_3d(bool p_disable);
+ bool is_3d_disabled() const;
+
+ void set_attach_to_screen_rect(const Rect2& p_rect);
+ Rect2 get_attach_to_screen_rect() const;
Vector2 get_mouse_pos() const;
void warp_mouse(const Vector2& p_pos);
@@ -381,12 +426,20 @@ public:
Variant gui_get_drag_data() const;
Control *get_modal_stack_top() const;
+ void gui_reset_canvas_sort_index();
+ int gui_get_canvas_sort_index();
+
virtual String get_configuration_warning() const;
+
+
Viewport();
~Viewport();
};
-VARIANT_ENUM_CAST(Viewport::RenderTargetUpdateMode);
+VARIANT_ENUM_CAST( Viewport::UpdateMode );
+VARIANT_ENUM_CAST( Viewport::ShadowAtlasQuadrantSubdiv );
+VARIANT_ENUM_CAST( Viewport::MSAA );
+
#endif
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 104aeb2b5e..f68e5ca959 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -54,9 +54,9 @@
#include "scene/gui/spin_box.h"
#include "scene/gui/option_button.h"
#include "scene/gui/color_picker.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/color_rect.h"
-#include "scene/gui/patch_9_frame.h"
+#include "scene/gui/patch_9_rect.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
@@ -66,6 +66,7 @@
#include "scene/gui/center_container.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/margin_container.h"
+#include "scene/gui/viewport_container.h"
#include "scene/gui/panel.h"
#include "scene/gui/spin_box.h"
#include "scene/gui/file_dialog.h"
@@ -80,7 +81,7 @@
#include "scene/gui/grid_container.h"
#include "scene/gui/split_container.h"
#include "scene/gui/video_player.h"
-#include "scene/gui/reference_frame.h"
+#include "scene/gui/reference_rect.h"
#include "scene/gui/graph_node.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/tool_button.h"
@@ -132,7 +133,7 @@
#include "scene/resources/surface_tool.h"
#include "scene/resources/mesh_data_tool.h"
-#include "scene/resources/scene_preloader.h"
+
#include "scene/resources/dynamic_font.h"
#include "scene/resources/dynamic_font_stb.h"
@@ -165,6 +166,7 @@
#include "scene/resources/sample.h"
#include "scene/audio/sample_player.h"
#include "scene/resources/texture.h"
+#include "scene/resources/sky_box.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/room.h"
@@ -202,6 +204,8 @@
#include "scene/3d/mesh_instance.h"
#include "scene/3d/quad.h"
#include "scene/3d/light.h"
+#include "scene/3d/reflection_probe.h"
+#include "scene/3d/gi_probe.h"
#include "scene/3d/particles.h"
#include "scene/3d/portal.h"
#include "scene/resources/environment.h"
@@ -235,7 +239,6 @@ static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
#endif
static ResourceFormatLoaderTheme *resource_loader_theme=NULL;
-static ResourceFormatLoaderShader *resource_loader_shader=NULL;
static ResourceFormatSaverText *resource_saver_text=NULL;
static ResourceFormatLoaderText *resource_loader_text=NULL;
@@ -269,15 +272,13 @@ void register_scene_types() {
resource_loader_theme = memnew( ResourceFormatLoaderTheme );
ResourceLoader::add_resource_format_loader( resource_loader_theme );
- resource_loader_shader = memnew( ResourceFormatLoaderShader );
- ResourceLoader::add_resource_format_loader( resource_loader_shader );
- bool default_theme_hidpi=GLOBAL_DEF("display/use_hidpi_theme",false);
- Globals::get_singleton()->set_custom_property_info("display/use_hidpi_theme",PropertyInfo(Variant::BOOL,"display/use_hidpi_theme",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
- String theme_path = GLOBAL_DEF("display/custom_theme","");
- Globals::get_singleton()->set_custom_property_info("display/custom_theme",PropertyInfo(Variant::STRING,"display/custom_theme",PROPERTY_HINT_FILE,"*.tres,*.res",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
- String font_path = GLOBAL_DEF("display/custom_theme_font","");
- Globals::get_singleton()->set_custom_property_info("display/custom_theme_font",PropertyInfo(Variant::STRING,"display/custom_theme_font",PROPERTY_HINT_FILE,"*.tres,*.res,*.fnt",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
+ bool default_theme_hidpi=GLOBAL_DEF("gui/theme/use_hidpi",false);
+ GlobalConfig::get_singleton()->set_custom_property_info("gui/theme/use_hidpi",PropertyInfo(Variant::BOOL,"gui/theme/use_hidpi",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
+ String theme_path = GLOBAL_DEF("gui/theme/custom","");
+ GlobalConfig::get_singleton()->set_custom_property_info("gui/theme/custom",PropertyInfo(Variant::STRING,"gui/theme/custom",PROPERTY_HINT_FILE,"*.tres,*.res",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
+ String font_path = GLOBAL_DEF("gui/theme/custom_font","");
+ GlobalConfig::get_singleton()->set_custom_property_info("gui/theme/custom_font",PropertyInfo(Variant::STRING,"gui/theme/custom_font",PROPERTY_HINT_FILE,"*.tres,*.res,*.fnt",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
if (theme_path!=String()) {
@@ -297,102 +298,102 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<Object>();
+ ClassDB::register_class<Object>();
- ObjectTypeDB::register_type<Node>();
- ObjectTypeDB::register_virtual_type<InstancePlaceholder>();
+ ClassDB::register_class<Node>();
+ ClassDB::register_virtual_class<InstancePlaceholder>();
- ObjectTypeDB::register_type<Viewport>();
- ObjectTypeDB::register_virtual_type<RenderTargetTexture>();
- ObjectTypeDB::register_type<HTTPRequest>();
- ObjectTypeDB::register_type<Timer>();
- ObjectTypeDB::register_type<CanvasLayer>();
- ObjectTypeDB::register_type<CanvasModulate>();
- ObjectTypeDB::register_type<ResourcePreloader>();
+ ClassDB::register_class<Viewport>();
+ ClassDB::register_class<ViewportTexture>();
+ ClassDB::register_class<HTTPRequest>();
+ ClassDB::register_class<Timer>();
+ ClassDB::register_class<CanvasLayer>();
+ ClassDB::register_class<CanvasModulate>();
+ ClassDB::register_class<ResourcePreloader>();
/* REGISTER GUI */
- ObjectTypeDB::register_type<ButtonGroup>();
- ObjectTypeDB::register_virtual_type<BaseButton>();
+ ClassDB::register_class<ButtonGroup>();
+ ClassDB::register_virtual_class<BaseButton>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<ShortCut>();
- ObjectTypeDB::register_type<Control>();
-// ObjectTypeDB::register_type<EmptyControl>();
- ObjectTypeDB::add_compatibility_type("EmptyControl","Control");
- ObjectTypeDB::register_type<Button>();
- ObjectTypeDB::register_type<Label>();
- ObjectTypeDB::register_type<HScrollBar>();
- ObjectTypeDB::register_type<VScrollBar>();
- ObjectTypeDB::register_type<ProgressBar>();
- ObjectTypeDB::register_type<HSlider>();
- ObjectTypeDB::register_type<VSlider>();
- ObjectTypeDB::register_type<Popup>();
- ObjectTypeDB::register_type<PopupPanel>();
- ObjectTypeDB::register_type<MenuButton>();
- ObjectTypeDB::register_type<CheckBox>();
- ObjectTypeDB::register_type<CheckButton>();
- ObjectTypeDB::register_type<ToolButton>();
- ObjectTypeDB::register_type<LinkButton>();
- ObjectTypeDB::register_type<Panel>();
- ObjectTypeDB::register_type<Range>();
+ ClassDB::register_class<ShortCut>();
+ ClassDB::register_class<Control>();
+ //ClassDB::register_type<EmptyControl>();
+ ClassDB::register_class<Button>();
+ ClassDB::register_class<Label>();
+ ClassDB::register_class<HScrollBar>();
+ ClassDB::register_class<VScrollBar>();
+ ClassDB::register_class<ProgressBar>();
+ ClassDB::register_class<HSlider>();
+ ClassDB::register_class<VSlider>();
+ ClassDB::register_class<Popup>();
+ ClassDB::register_class<PopupPanel>();
+ ClassDB::register_class<MenuButton>();
+ ClassDB::register_class<CheckBox>();
+ ClassDB::register_class<CheckButton>();
+ ClassDB::register_class<ToolButton>();
+ ClassDB::register_class<LinkButton>();
+ ClassDB::register_class<Panel>();
+ ClassDB::register_class<Range>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<TextureFrame>();
- ObjectTypeDB::register_type<ColorFrame>();
- ObjectTypeDB::register_type<Patch9Frame>();
- ObjectTypeDB::register_type<TabContainer>();
- ObjectTypeDB::register_type<Tabs>();
- ObjectTypeDB::register_virtual_type<Separator>();
- ObjectTypeDB::register_type<HSeparator>();
- ObjectTypeDB::register_type<VSeparator>();
- ObjectTypeDB::register_type<TextureButton>();
- ObjectTypeDB::register_type<Container>();
- ObjectTypeDB::register_virtual_type<BoxContainer>();
- ObjectTypeDB::register_type<HBoxContainer>();
- ObjectTypeDB::register_type<VBoxContainer>();
- ObjectTypeDB::register_type<GridContainer>();
- ObjectTypeDB::register_type<CenterContainer>();
- ObjectTypeDB::register_type<ScrollContainer>();
- ObjectTypeDB::register_type<PanelContainer>();
- ObjectTypeDB::register_virtual_type<SplitContainer>();
- ObjectTypeDB::register_type<HSplitContainer>();
- ObjectTypeDB::register_type<VSplitContainer>();
- ObjectTypeDB::register_type<GraphNode>();
- ObjectTypeDB::register_type<GraphEdit>();
+ ClassDB::register_class<TextureRect>();
+ ClassDB::register_class<ColorRect>();
+ ClassDB::register_class<NinePatchRect>();
+ ClassDB::register_class<TabContainer>();
+ ClassDB::register_class<Tabs>();
+ ClassDB::register_virtual_class<Separator>();
+ ClassDB::register_class<HSeparator>();
+ ClassDB::register_class<VSeparator>();
+ ClassDB::register_class<TextureButton>();
+ ClassDB::register_class<Container>();
+ ClassDB::register_virtual_class<BoxContainer>();
+ ClassDB::register_class<HBoxContainer>();
+ ClassDB::register_class<VBoxContainer>();
+ ClassDB::register_class<GridContainer>();
+ ClassDB::register_class<CenterContainer>();
+ ClassDB::register_class<ScrollContainer>();
+ ClassDB::register_class<PanelContainer>();
+ ClassDB::register_virtual_class<SplitContainer>();
+ ClassDB::register_class<HSplitContainer>();
+ ClassDB::register_class<VSplitContainer>();
+ ClassDB::register_class<GraphNode>();
+ ClassDB::register_class<GraphEdit>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_virtual_type<ButtonArray>();
- ObjectTypeDB::register_type<HButtonArray>();
- ObjectTypeDB::register_type<VButtonArray>();
- ObjectTypeDB::register_type<TextureProgress>();
- ObjectTypeDB::register_type<ItemList>();
+ ClassDB::register_virtual_class<ButtonArray>();
+ ClassDB::register_class<HButtonArray>();
+ ClassDB::register_class<VButtonArray>();
+ ClassDB::register_class<TextureProgress>();
+ ClassDB::register_class<ItemList>();
#ifndef ADVANCED_GUI_DISABLED
- ObjectTypeDB::register_type<FileDialog>();
- ObjectTypeDB::register_type<LineEdit>();
- ObjectTypeDB::register_type<PopupMenu>();
- ObjectTypeDB::register_type<Tree>();
-
- ObjectTypeDB::register_type<TextEdit>();
-
- ObjectTypeDB::register_virtual_type<TreeItem>();
- ObjectTypeDB::register_type<OptionButton>();
- ObjectTypeDB::register_type<SpinBox>();
- ObjectTypeDB::register_type<ReferenceFrame>();
- ObjectTypeDB::register_type<ColorPicker>();
- ObjectTypeDB::register_type<ColorPickerButton>();
- ObjectTypeDB::register_type<RichTextLabel>();
- ObjectTypeDB::register_type<PopupDialog>();
- ObjectTypeDB::register_type<WindowDialog>();
- ObjectTypeDB::register_type<AcceptDialog>();
- ObjectTypeDB::register_type<ConfirmationDialog>();
- ObjectTypeDB::register_type<VideoPlayer>();
- ObjectTypeDB::register_type<MarginContainer>();
+ ClassDB::register_class<FileDialog>();
+ ClassDB::register_class<LineEdit>();
+ ClassDB::register_class<PopupMenu>();
+ ClassDB::register_class<Tree>();
+
+ ClassDB::register_class<TextEdit>();
+
+ ClassDB::register_virtual_class<TreeItem>();
+ ClassDB::register_class<OptionButton>();
+ ClassDB::register_class<SpinBox>();
+ ClassDB::register_class<ReferenceRect>();
+ ClassDB::register_class<ColorPicker>();
+ ClassDB::register_class<ColorPickerButton>();
+ ClassDB::register_class<RichTextLabel>();
+ ClassDB::register_class<PopupDialog>();
+ ClassDB::register_class<WindowDialog>();
+ ClassDB::register_class<AcceptDialog>();
+ ClassDB::register_class<ConfirmationDialog>();
+ ClassDB::register_class<VideoPlayer>();
+ ClassDB::register_class<MarginContainer>();
+ ClassDB::register_class<ViewportContainer>();
OS::get_singleton()->yield(); //may take time to init
@@ -400,243 +401,239 @@ void register_scene_types() {
/* REGISTER 3D */
- ObjectTypeDB::register_type<Spatial>();
- ObjectTypeDB::register_type<Skeleton>();
- ObjectTypeDB::register_type<AnimationPlayer>();
- ObjectTypeDB::register_type<Tween>();
+ ClassDB::register_class<Spatial>();
+ ClassDB::register_virtual_class<SpatialGizmo>();
+ ClassDB::register_class<Skeleton>();
+ ClassDB::register_class<AnimationPlayer>();
+ ClassDB::register_class<Tween>();
OS::get_singleton()->yield(); //may take time to init
#ifndef _3D_DISABLED
- ObjectTypeDB::register_type<BoneAttachment>();
- ObjectTypeDB::register_virtual_type<VisualInstance>();
- ObjectTypeDB::register_type<Camera>();
- ObjectTypeDB::register_type<Listener>();
- ObjectTypeDB::register_type<InterpolatedCamera>();
- ObjectTypeDB::register_type<TestCube>();
- ObjectTypeDB::register_type<MeshInstance>();
- ObjectTypeDB::register_type<ImmediateGeometry>();
- ObjectTypeDB::register_type<Sprite3D>();
- ObjectTypeDB::register_type<AnimatedSprite3D>();
- ObjectTypeDB::register_virtual_type<Light>();
- ObjectTypeDB::register_type<DirectionalLight>();
- ObjectTypeDB::register_type<OmniLight>();
- ObjectTypeDB::register_type<SpotLight>();
- ObjectTypeDB::register_type<AnimationTreePlayer>();
- ObjectTypeDB::register_type<Portal>();
- ObjectTypeDB::register_type<Particles>();
- ObjectTypeDB::register_type<Position3D>();
- ObjectTypeDB::register_type<Quad>();
- ObjectTypeDB::register_type<NavigationMeshInstance>();
- ObjectTypeDB::register_type<NavigationMesh>();
- ObjectTypeDB::register_type<Navigation>();
+ ClassDB::register_class<BoneAttachment>();
+ ClassDB::register_virtual_class<VisualInstance>();
+ ClassDB::register_class<Camera>();
+ ClassDB::register_class<Listener>();
+ ClassDB::register_class<InterpolatedCamera>();
+ ClassDB::register_class<TestCube>();
+ ClassDB::register_class<MeshInstance>();
+ ClassDB::register_class<ImmediateGeometry>();
+ ClassDB::register_class<Sprite3D>();
+ ClassDB::register_class<AnimatedSprite3D>();
+ ClassDB::register_virtual_class<Light>();
+ ClassDB::register_class<DirectionalLight>();
+ ClassDB::register_class<OmniLight>();
+ ClassDB::register_class<SpotLight>();
+ ClassDB::register_class<ReflectionProbe>();
+ ClassDB::register_class<GIProbe>();
+ ClassDB::register_class<GIProbeData>();
+ ClassDB::register_class<AnimationTreePlayer>();
+ ClassDB::register_class<Portal>();
+ //ClassDB::register_type<Particles>();
+ ClassDB::register_class<Position3D>();
+ ClassDB::register_class<Quad>();
+ ClassDB::register_class<NavigationMeshInstance>();
+ ClassDB::register_class<NavigationMesh>();
+ ClassDB::register_class<Navigation>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_virtual_type<CollisionObject>();
- ObjectTypeDB::register_type<StaticBody>();
- ObjectTypeDB::register_type<RigidBody>();
- ObjectTypeDB::register_type<KinematicBody>();
-
-
- ObjectTypeDB::register_type<VehicleBody>();
- ObjectTypeDB::register_type<VehicleWheel>();
- ObjectTypeDB::register_type<Area>();
- ObjectTypeDB::register_type<ProximityGroup>();
- ObjectTypeDB::register_type<CollisionShape>();
- ObjectTypeDB::register_type<CollisionPolygon>();
- ObjectTypeDB::register_type<RayCast>();
- ObjectTypeDB::register_type<MultiMeshInstance>();
- ObjectTypeDB::register_type<Room>();
- ObjectTypeDB::register_type<Curve3D>();
- ObjectTypeDB::register_type<Path>();
- ObjectTypeDB::register_type<PathFollow>();
- ObjectTypeDB::register_type<VisibilityNotifier>();
- ObjectTypeDB::register_type<VisibilityEnabler>();
- ObjectTypeDB::register_type<BakedLightInstance>();
- ObjectTypeDB::register_type<BakedLightSampler>();
- ObjectTypeDB::register_type<WorldEnvironment>();
- ObjectTypeDB::register_type<RemoteTransform>();
-
- ObjectTypeDB::register_virtual_type<Joint>();
- ObjectTypeDB::register_type<PinJoint>();
- ObjectTypeDB::register_type<HingeJoint>();
- ObjectTypeDB::register_type<SliderJoint>();
- ObjectTypeDB::register_type<ConeTwistJoint>();
- ObjectTypeDB::register_type<Generic6DOFJoint>();
+ ClassDB::register_virtual_class<CollisionObject>();
+ ClassDB::register_class<StaticBody>();
+ ClassDB::register_class<RigidBody>();
+ ClassDB::register_class<KinematicBody>();
+
+
+ ClassDB::register_class<VehicleBody>();
+ ClassDB::register_class<VehicleWheel>();
+ ClassDB::register_class<Area>();
+ ClassDB::register_class<ProximityGroup>();
+ ClassDB::register_class<CollisionShape>();
+ 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>();
+
+ ClassDB::register_virtual_class<Joint>();
+ ClassDB::register_class<PinJoint>();
+ ClassDB::register_class<HingeJoint>();
+ ClassDB::register_class<SliderJoint>();
+ ClassDB::register_class<ConeTwistJoint>();
+ ClassDB::register_class<Generic6DOFJoint>();
//scenariofx
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<SpatialSamplePlayer>();
- ObjectTypeDB::register_type<SpatialStreamPlayer>();
- ObjectTypeDB::register_type<SoundRoomParams>();
+ ClassDB::register_class<SpatialSamplePlayer>();
+ ClassDB::register_class<SpatialStreamPlayer>();
+ ClassDB::register_class<SoundRoomParams>();
#endif
- ObjectTypeDB::register_type<MeshLibrary>();
- AcceptDialog::set_swap_ok_cancel( GLOBAL_DEF("display/swap_ok_cancel",bool(OS::get_singleton()->get_swap_ok_cancel())) );
-
- ObjectTypeDB::register_type<SamplePlayer>();
- ObjectTypeDB::register_type<StreamPlayer>();
- ObjectTypeDB::register_type<EventPlayer>();
-
-
- ObjectTypeDB::register_type<CanvasItemMaterial>();
- ObjectTypeDB::register_virtual_type<CanvasItem>();
- ObjectTypeDB::register_type<Node2D>();
- ObjectTypeDB::register_type<Particles2D>();
- ObjectTypeDB::register_type<ParticleAttractor2D>();
- ObjectTypeDB::register_type<Sprite>();
- ObjectTypeDB::register_type<ViewportSprite>();
- ObjectTypeDB::register_type<SpriteFrames>();
- ObjectTypeDB::register_type<AnimatedSprite>();
- ObjectTypeDB::register_type<Position2D>();
- ObjectTypeDB::register_virtual_type<CollisionObject2D>();
- ObjectTypeDB::register_virtual_type<PhysicsBody2D>();
- ObjectTypeDB::register_type<StaticBody2D>();
- ObjectTypeDB::register_type<RigidBody2D>();
- ObjectTypeDB::register_type<KinematicBody2D>();
- ObjectTypeDB::register_type<Area2D>();
- ObjectTypeDB::register_type<CollisionShape2D>();
- ObjectTypeDB::register_type<CollisionPolygon2D>();
- ObjectTypeDB::register_type<RayCast2D>();
- ObjectTypeDB::register_type<VisibilityNotifier2D>();
- ObjectTypeDB::register_type<VisibilityEnabler2D>();
- ObjectTypeDB::register_type<Polygon2D>();
- ObjectTypeDB::register_type<Light2D>();
- ObjectTypeDB::register_type<LightOccluder2D>();
- ObjectTypeDB::register_type<OccluderPolygon2D>();
- ObjectTypeDB::register_type<YSort>();
- ObjectTypeDB::register_type<BackBufferCopy>();
- if (bool(GLOBAL_DEF("physics/remove_collision_helpers_at_runtime",false))) {
- ObjectTypeDB::set_type_enabled("CollisionShape2D",false);
- ObjectTypeDB::set_type_enabled("CollisionPolygon2D",false);
- ObjectTypeDB::set_type_enabled("CollisionShape",false);
- ObjectTypeDB::set_type_enabled("CollisionPolygon",false);
- }
+ ClassDB::register_class<MeshLibrary>();
+ AcceptDialog::set_swap_ok_cancel( GLOBAL_DEF("gui/common/swap_ok_cancel",bool(OS::get_singleton()->get_swap_ok_cancel())) );
+
+ ClassDB::register_class<SamplePlayer>();
+ ClassDB::register_class<StreamPlayer>();
+ ClassDB::register_class<EventPlayer>();
+
+
+ ClassDB::register_class<CanvasItemMaterial>();
+ ClassDB::register_virtual_class<CanvasItem>();
+ ClassDB::register_class<Node2D>();
+ ClassDB::register_class<Particles2D>();
+ ClassDB::register_class<ParticleAttractor2D>();
+ ClassDB::register_class<Sprite>();
+ //ClassDB::register_type<ViewportSprite>();
+ ClassDB::register_class<SpriteFrames>();
+ ClassDB::register_class<AnimatedSprite>();
+ ClassDB::register_class<Position2D>();
+ ClassDB::register_virtual_class<CollisionObject2D>();
+ ClassDB::register_virtual_class<PhysicsBody2D>();
+ ClassDB::register_class<StaticBody2D>();
+ ClassDB::register_class<RigidBody2D>();
+ ClassDB::register_class<KinematicBody2D>();
+ ClassDB::register_class<Area2D>();
+ ClassDB::register_class<CollisionShape2D>();
+ ClassDB::register_class<CollisionPolygon2D>();
+ ClassDB::register_class<RayCast2D>();
+ ClassDB::register_class<VisibilityNotifier2D>();
+ ClassDB::register_class<VisibilityEnabler2D>();
+ ClassDB::register_class<Polygon2D>();
+ ClassDB::register_class<Light2D>();
+ ClassDB::register_class<LightOccluder2D>();
+ ClassDB::register_class<OccluderPolygon2D>();
+ ClassDB::register_class<YSort>();
+ ClassDB::register_class<BackBufferCopy>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<Camera2D>();
- ObjectTypeDB::register_virtual_type<Joint2D>();
- ObjectTypeDB::register_type<PinJoint2D>();
- ObjectTypeDB::register_type<GrooveJoint2D>();
- ObjectTypeDB::register_type<DampedSpringJoint2D>();
- ObjectTypeDB::register_type<TileSet>();
- ObjectTypeDB::register_type<TileMap>();
- ObjectTypeDB::register_type<ParallaxBackground>();
- ObjectTypeDB::register_type<ParallaxLayer>();
- ObjectTypeDB::register_virtual_type<SoundPlayer2D>();
- ObjectTypeDB::register_type<SamplePlayer2D>();
- ObjectTypeDB::register_type<TouchScreenButton>();
- ObjectTypeDB::register_type<RemoteTransform2D>();
+ ClassDB::register_class<Camera2D>();
+ ClassDB::register_virtual_class<Joint2D>();
+ ClassDB::register_class<PinJoint2D>();
+ ClassDB::register_class<GrooveJoint2D>();
+ ClassDB::register_class<DampedSpringJoint2D>();
+ ClassDB::register_class<TileSet>();
+ ClassDB::register_class<TileMap>();
+ ClassDB::register_class<ParallaxBackground>();
+ ClassDB::register_class<ParallaxLayer>();
+ ClassDB::register_virtual_class<SoundPlayer2D>();
+ ClassDB::register_class<SamplePlayer2D>();
+ ClassDB::register_class<TouchScreenButton>();
+ ClassDB::register_class<RemoteTransform2D>();
OS::get_singleton()->yield(); //may take time to init
/* REGISTER RESOURCES */
- ObjectTypeDB::register_virtual_type<Shader>();
- ObjectTypeDB::register_virtual_type<ShaderGraph>();
- ObjectTypeDB::register_type<CanvasItemShader>();
- ObjectTypeDB::register_type<CanvasItemShaderGraph>();
+ ClassDB::register_virtual_class<Shader>();
+ //ClassDB::register_virtual_type<ShaderGraph>();
+ ClassDB::register_class<CanvasItemShader>();
+ //ClassDB::register_type<CanvasItemShaderGraph>();
#ifndef _3D_DISABLED
- ObjectTypeDB::register_type<Mesh>();
- ObjectTypeDB::register_virtual_type<Material>();
- ObjectTypeDB::register_type<FixedMaterial>();
- ObjectTypeDB::register_type<ShaderMaterial>();
- ObjectTypeDB::register_type<RoomBounds>();
- ObjectTypeDB::register_type<MaterialShaderGraph>();
- ObjectTypeDB::register_type<MaterialShader>();
- ObjectTypeDB::add_compatibility_type("Shader","MaterialShader");
- ObjectTypeDB::add_compatibility_type("ParticleSystemMaterial","FixedMaterial");
- ObjectTypeDB::add_compatibility_type("UnshadedMaterial","FixedMaterial");
- ObjectTypeDB::register_type<MultiMesh>();
- ObjectTypeDB::register_type<MeshLibrary>();
+ ClassDB::register_class<Mesh>();
+ ClassDB::register_virtual_class<Material>();
+ ClassDB::register_class<FixedSpatialMaterial>();
+ SceneTree::add_idle_callback(FixedSpatialMaterial::flush_changes);
+ FixedSpatialMaterial::init_shaders();
+ //ClassDB::register_type<ShaderMaterial>();
+ ClassDB::register_class<RoomBounds>();
+ //ClassDB::register_type<MaterialShaderGraph>();
+ ClassDB::register_class<SpatialShader>();
+ ClassDB::register_class<ParticlesShader>();
+ ClassDB::register_class<MultiMesh>();
+ ClassDB::register_class<MeshLibrary>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<RayShape>();
- ObjectTypeDB::register_type<SphereShape>();
- ObjectTypeDB::register_type<BoxShape>();
- ObjectTypeDB::register_type<CapsuleShape>();
- ObjectTypeDB::register_type<PlaneShape>();
- ObjectTypeDB::register_type<ConvexPolygonShape>();
- ObjectTypeDB::register_type<ConcavePolygonShape>();
+ ClassDB::register_class<RayShape>();
+ ClassDB::register_class<SphereShape>();
+ ClassDB::register_class<BoxShape>();
+ ClassDB::register_class<CapsuleShape>();
+ ClassDB::register_class<PlaneShape>();
+ ClassDB::register_class<ConvexPolygonShape>();
+ ClassDB::register_class<ConcavePolygonShape>();
- ObjectTypeDB::register_type<SurfaceTool>();
- ObjectTypeDB::register_type<MeshDataTool>();
- ObjectTypeDB::register_type<BakedLight>();
+ ClassDB::register_class<SurfaceTool>();
+ ClassDB::register_class<MeshDataTool>();
+ //ClassDB::register_type<BakedLight>();
OS::get_singleton()->yield(); //may take time to init
#endif
- ObjectTypeDB::register_type<World>();
- ObjectTypeDB::register_type<Environment>();
- ObjectTypeDB::register_type<World2D>();
- ObjectTypeDB::register_virtual_type<Texture>();
- ObjectTypeDB::register_type<ImageTexture>();
- ObjectTypeDB::register_type<AtlasTexture>();
- ObjectTypeDB::register_type<LargeTexture>();
- ObjectTypeDB::register_type<CubeMap>();
- ObjectTypeDB::register_type<Animation>();
- ObjectTypeDB::register_virtual_type<Font>();
- ObjectTypeDB::register_type<BitmapFont>();
-
- ObjectTypeDB::register_type<DynamicFontData>();
- ObjectTypeDB::register_type<DynamicFont>();
-
- ObjectTypeDB::register_type<StyleBoxEmpty>();
- ObjectTypeDB::register_type<StyleBoxTexture>();
- ObjectTypeDB::register_type<StyleBoxFlat>();
- ObjectTypeDB::register_type<StyleBoxImageMask>();
- ObjectTypeDB::register_type<Theme>();
-
- ObjectTypeDB::add_compatibility_type("Font","BitmapFont");
-
-
- ObjectTypeDB::register_type<PolygonPathFinder>();
- ObjectTypeDB::register_type<BitMap>();
- ObjectTypeDB::register_type<ColorRamp>();
+ ClassDB::register_class<World>();
+ ClassDB::register_class<Environment>();
+ ClassDB::register_class<World2D>();
+ ClassDB::register_virtual_class<Texture>();
+ ClassDB::register_virtual_class<SkyBox>();
+ ClassDB::register_class<ImageSkyBox>();
+ ClassDB::register_class<ImageTexture>();
+ ClassDB::register_class<AtlasTexture>();
+ ClassDB::register_class<LargeTexture>();
+ ClassDB::register_class<CubeMap>();
+ ClassDB::register_class<Animation>();
+ ClassDB::register_virtual_class<Font>();
+ ClassDB::register_class<BitmapFont>();
+
+ ClassDB::register_class<DynamicFontData>();
+ ClassDB::register_class<DynamicFont>();
+
+ ClassDB::register_class<StyleBoxEmpty>();
+ ClassDB::register_class<StyleBoxTexture>();
+ ClassDB::register_class<StyleBoxFlat>();
+ ClassDB::register_class<Theme>();
+
+ ClassDB::register_class<PolygonPathFinder>();
+ ClassDB::register_class<BitMap>();
+ ClassDB::register_class<ColorRamp>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_type<Sample>();
- ObjectTypeDB::register_type<SampleLibrary>();
- ObjectTypeDB::register_virtual_type<AudioStream>();
- ObjectTypeDB::register_virtual_type<AudioStreamPlayback>();
+ ClassDB::register_class<Sample>();
+ ClassDB::register_class<SampleLibrary>();
+ ClassDB::register_virtual_class<AudioStream>();
+ ClassDB::register_virtual_class<AudioStreamPlayback>();
//TODO: Adapt to the new AudioStream API or drop (GH-3307)
-// ObjectTypeDB::register_type<AudioStreamGibberish>();
- ObjectTypeDB::register_virtual_type<VideoStream>();
+ //ClassDB::register_type<AudioStreamGibberish>();
+ ClassDB::register_virtual_class<VideoStream>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_virtual_type<Shape2D>();
- ObjectTypeDB::register_type<LineShape2D>();
- ObjectTypeDB::register_type<SegmentShape2D>();
- ObjectTypeDB::register_type<RayShape2D>();
- ObjectTypeDB::register_type<CircleShape2D>();
- ObjectTypeDB::register_type<RectangleShape2D>();
- ObjectTypeDB::register_type<CapsuleShape2D>();
- ObjectTypeDB::register_type<ConvexPolygonShape2D>();
- ObjectTypeDB::register_type<ConcavePolygonShape2D>();
- ObjectTypeDB::register_type<Curve2D>();
- ObjectTypeDB::register_type<Path2D>();
- ObjectTypeDB::register_type<PathFollow2D>();
-
- ObjectTypeDB::register_type<Navigation2D>();
- ObjectTypeDB::register_type<NavigationPolygon>();
- ObjectTypeDB::register_type<NavigationPolygonInstance>();
+ ClassDB::register_virtual_class<Shape2D>();
+ ClassDB::register_class<LineShape2D>();
+ ClassDB::register_class<SegmentShape2D>();
+ ClassDB::register_class<RayShape2D>();
+ ClassDB::register_class<CircleShape2D>();
+ ClassDB::register_class<RectangleShape2D>();
+ ClassDB::register_class<CapsuleShape2D>();
+ ClassDB::register_class<ConvexPolygonShape2D>();
+ ClassDB::register_class<ConcavePolygonShape2D>();
+ ClassDB::register_class<Curve2D>();
+ ClassDB::register_class<Path2D>();
+ ClassDB::register_class<PathFollow2D>();
+
+ ClassDB::register_class<Navigation2D>();
+ ClassDB::register_class<NavigationPolygon>();
+ ClassDB::register_class<NavigationPolygonInstance>();
OS::get_singleton()->yield(); //may take time to init
- ObjectTypeDB::register_virtual_type<SceneState>();
- ObjectTypeDB::register_type<PackedScene>();
+ ClassDB::register_virtual_class<SceneState>();
+ ClassDB::register_class<PackedScene>();
- ObjectTypeDB::register_type<SceneTree>();
- ObjectTypeDB::register_virtual_type<SceneTreeTimer>(); //sorry, you can't create it
+ ClassDB::register_class<SceneTree>();
+ ClassDB::register_virtual_class<SceneTreeTimer>(); //sorry, you can't create it
OS::get_singleton()->yield(); //may take time to init
@@ -647,6 +644,12 @@ void register_scene_types() {
resource_loader_text = memnew( ResourceFormatLoaderText );
ResourceLoader::add_resource_format_loader(resource_loader_text,true);
+ for(int i=0;i<20;i++) {
+ GLOBAL_DEF("layer_names/2d_render/layer_"+itos(i+1),"");
+ GLOBAL_DEF("layer_names/2d_physics/layer_"+itos(i+1),"");
+ GLOBAL_DEF("layer_names/3d_render/layer_"+itos(i+1),"");
+ GLOBAL_DEF("layer_names/3d_physics/layer_"+itos(i+1),"");
+ }
}
void unregister_scene_types() {
@@ -657,6 +660,7 @@ void unregister_scene_types() {
memdelete( resource_loader_wav );
memdelete( resource_loader_dynamic_font );
+
#ifdef TOOLS_ENABLED
@@ -664,7 +668,6 @@ void unregister_scene_types() {
memdelete( resource_loader_theme );
- memdelete( resource_loader_shader );
if (resource_saver_text) {
memdelete(resource_saver_text);
@@ -672,5 +675,7 @@ void unregister_scene_types() {
if (resource_loader_text) {
memdelete(resource_loader_text);
}
+
+ FixedSpatialMaterial::finish_shaders();
SceneStringNames::free();
}
diff --git a/scene/register_scene_types.h b/scene/register_scene_types.h
index 15e1eb2980..090254c5f7 100644
--- a/scene/register_scene_types.h
+++ b/scene/register_scene_types.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/SCsub b/scene/resources/SCsub
index bb9766e1ca..60b16cd0d4 100644
--- a/scene/resources/SCsub
+++ b/scene/resources/SCsub
@@ -1,8 +1,10 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
-env.add_source_files(env.scene_sources,"*.c")
+env.add_source_files(env.scene_sources, "*.cpp")
+env.add_source_files(env.scene_sources, "*.c")
Export('env')
-SConscript("default_theme/SCsub");
+SConscript("default_theme/SCsub")
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 1d15b6f2bc..5b9baa6a67 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -72,6 +72,8 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
track_set_path(track,p_value);
else if (what=="interp")
track_set_interpolation_type(track,InterpolationType(p_value.operator int()));
+ else if (what=="loop_wrap")
+ track_set_interpolation_loop_wrap(track,p_value);
else if (what=="imported")
track_set_imported(track,p_value);
else if (what == "keys" || what=="key_values") {
@@ -79,14 +81,14 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
if (track_get_type(track)==TYPE_TRANSFORM) {
TransformTrack *tt = static_cast<TransformTrack*>(tracks[track]);
- DVector<float> values=p_value;
+ PoolVector<float> values=p_value;
int vcount=values.size();
#if 0 // old compatibility hack
if ((vcount%11) == 0) {
- DVector<float>::Read r = values.read();
+ PoolVector<float>::Read r = values.read();
tt->transforms.resize(vcount/11);
@@ -121,7 +123,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
#endif
ERR_FAIL_COND_V(vcount%12,false); // shuld be multiple of 11
- DVector<float>::Read r = values.read();
+ PoolVector<float>::Read r = values.read();
tt->transforms.resize(vcount/12);
@@ -172,7 +174,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
- DVector<float> times=d["times"];
+ PoolVector<float> times=d["times"];
Array values=d["values"];
ERR_FAIL_COND_V(times.size()!=values.size(),false);
@@ -181,7 +183,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
int valcount=times.size();
- DVector<float>::Read rt = times.read();
+ PoolVector<float>::Read rt = times.read();
vt->values.resize(valcount);
@@ -193,10 +195,10 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
if (d.has("transitions")) {
- DVector<float> transitions = d["transitions"];
+ PoolVector<float> transitions = d["transitions"];
ERR_FAIL_COND_V(transitions.size()!=valcount,false);
- DVector<float>::Read rtr = transitions.read();
+ PoolVector<float>::Read rtr = transitions.read();
for(int i=0;i<valcount;i++) {
@@ -218,7 +220,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
ERR_FAIL_COND_V(!d.has("times"),false);
ERR_FAIL_COND_V(!d.has("values"),false);
- DVector<float> times=d["times"];
+ PoolVector<float> times=d["times"];
Array values=d["values"];
ERR_FAIL_COND_V(times.size()!=values.size(),false);
@@ -227,7 +229,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
int valcount=times.size();
- DVector<float>::Read rt = times.read();
+ PoolVector<float>::Read rt = times.read();
for(int i=0;i<valcount;i++) {
@@ -236,10 +238,10 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
if (d.has("transitions")) {
- DVector<float> transitions = d["transitions"];
+ PoolVector<float> transitions = d["transitions"];
ERR_FAIL_COND_V(transitions.size()!=valcount,false);
- DVector<float>::Read rtr = transitions.read();
+ PoolVector<float>::Read rtr = transitions.read();
for(int i=0;i<valcount;i++) {
@@ -291,17 +293,19 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
r_ret=track_get_path(track);
else if (what=="interp")
r_ret = track_get_interpolation_type(track);
+ else if (what=="loop_wrap")
+ r_ret = track_get_interpolation_loop_wrap(track);
else if (what=="imported")
r_ret = track_is_imported(track);
else if (what=="keys") {
if (track_get_type(track)==TYPE_TRANSFORM) {
- DVector<real_t> keys;
+ PoolVector<real_t> keys;
int kk=track_get_key_count(track);
keys.resize(kk*12);
- DVector<real_t>::Write w = keys.write();
+ PoolVector<real_t>::Write w = keys.write();
int idx=0;
for(int i=0;i<track_get_key_count(track);i++) {
@@ -327,7 +331,7 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
w[idx++]=scale.z;
}
- w = DVector<real_t>::Write();
+ w = PoolVector<real_t>::Write();
r_ret=keys;
return true;
@@ -338,8 +342,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
Dictionary d;
- DVector<float> key_times;
- DVector<float> key_transitions;
+ PoolVector<float> key_times;
+ PoolVector<float> key_transitions;
Array key_values;
int kk=vt->values.size();
@@ -348,8 +352,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
key_transitions.resize(kk);
key_values.resize(kk);
- DVector<float>::Write wti=key_times.write();
- DVector<float>::Write wtr=key_transitions.write();
+ PoolVector<float>::Write wti=key_times.write();
+ PoolVector<float>::Write wtr=key_transitions.write();
int idx=0;
@@ -363,8 +367,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
idx++;
}
- wti=DVector<float>::Write();
- wtr=DVector<float>::Write();
+ wti=PoolVector<float>::Write();
+ wtr=PoolVector<float>::Write();
d["times"]=key_times;
d["transitions"]=key_transitions;
@@ -382,8 +386,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
Dictionary d;
- DVector<float> key_times;
- DVector<float> key_transitions;
+ PoolVector<float> key_times;
+ PoolVector<float> key_transitions;
Array key_values;
int kk=track_get_key_count(track);
@@ -392,8 +396,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
key_transitions.resize(kk);
key_values.resize(kk);
- DVector<float>::Write wti=key_times.write();
- DVector<float>::Write wtr=key_transitions.write();
+ PoolVector<float>::Write wti=key_times.write();
+ PoolVector<float>::Write wtr=key_transitions.write();
int idx=0;
for(int i=0;i<track_get_key_count(track);i++) {
@@ -404,8 +408,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
idx++;
}
- wti=DVector<float>::Write();
- wtr=DVector<float>::Write();
+ wti=PoolVector<float>::Write();
+ wtr=PoolVector<float>::Write();
d["times"]=key_times;
d["transitions"]=key_transitions;
@@ -440,6 +444,7 @@ void Animation::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::STRING, "tracks/"+itos(i)+"/type", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
p_list->push_back( PropertyInfo( Variant::NODE_PATH, "tracks/"+itos(i)+"/path", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
p_list->push_back( PropertyInfo( Variant::INT, "tracks/"+itos(i)+"/interp", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "tracks/"+itos(i)+"/loop_wrap", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
p_list->push_back( PropertyInfo( Variant::BOOL, "tracks/"+itos(i)+"/imported", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
p_list->push_back( PropertyInfo( Variant::ARRAY, "tracks/"+itos(i)+"/keys", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
}
@@ -559,6 +564,19 @@ Animation::InterpolationType Animation::track_get_interpolation_type(int p_track
return tracks[p_track]->interpolation;
}
+void Animation::track_set_interpolation_loop_wrap(int p_track,bool p_enable) {
+ ERR_FAIL_INDEX(p_track, tracks.size());
+ tracks[p_track]->loop_wrap=p_enable;
+ emit_changed();
+
+}
+
+bool Animation::track_get_interpolation_loop_wrap(int p_track) const{
+
+ ERR_FAIL_INDEX_V(p_track, tracks.size(),INTERPOLATION_NEAREST);
+ return tracks[p_track]->loop_wrap;
+
+}
// transform
/*
@@ -1185,14 +1203,14 @@ Variant Animation::_cubic_interpolate( const Variant& p_pre_a,const Variant& p_a
return a.cubic_slerp(b,pa,pb,p_c);
} break;
- case Variant::_AABB: {
+ case Variant::RECT3: {
- AABB a=p_a;
- AABB b=p_b;
- AABB pa=p_pre_a;
- AABB pb=p_post_b;
+ Rect3 a=p_a;
+ Rect3 b=p_b;
+ Rect3 pa=p_pre_a;
+ Rect3 pb=p_post_b;
- return AABB(
+ return Rect3(
a.pos.cubic_interpolate(b.pos,pa.pos,pb.pos,p_c),
a.size.cubic_interpolate(b.size,pa.size,pb.size,p_c)
);
@@ -1211,7 +1229,7 @@ float Animation::_cubic_interpolate( const float& p_pre_a,const float& p_a, cons
}
template<class T>
-T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, InterpolationType p_interp, bool *p_ok) const {
+T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap,bool *p_ok) const {
int len=_find( p_keys, length )+1; // try to find last key (there may be more past the end)
@@ -1239,7 +1257,7 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter
float c=0;
// prepare for all cases of interpolation
- if (loop) {
+ if (loop && p_loop_wrap) {
// loop
if (idx>=0) {
@@ -1363,7 +1381,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3
bool ok;
- TransformKey tk = _interpolate( tt->transforms, p_time, tt->interpolation, &ok );
+ TransformKey tk = _interpolate( tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok );
if (!ok) // ??
return ERR_UNAVAILABLE;
@@ -1391,7 +1409,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
bool ok;
- Variant res = _interpolate( vt->values, p_time, vt->update_mode==UPDATE_CONTINUOUS?vt->interpolation:INTERPOLATION_NEAREST, &ok );
+ Variant res = _interpolate( vt->values, p_time, vt->update_mode==UPDATE_CONTINUOUS?vt->interpolation:INTERPOLATION_NEAREST,vt->loop_wrap, &ok );
if (ok) {
@@ -1680,59 +1698,61 @@ float Animation::get_step() const{
void Animation::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_track","type","at_pos"),&Animation::add_track,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("remove_track","idx"),&Animation::remove_track);
- ObjectTypeDB::bind_method(_MD("get_track_count"),&Animation::get_track_count);
- ObjectTypeDB::bind_method(_MD("track_get_type","idx"),&Animation::track_get_type);
- ObjectTypeDB::bind_method(_MD("track_get_path","idx"),&Animation::track_get_path);
- ObjectTypeDB::bind_method(_MD("track_set_path","idx","path"),&Animation::track_set_path);
- ObjectTypeDB::bind_method(_MD("find_track","path"),&Animation::find_track);
+ ClassDB::bind_method(_MD("add_track","type","at_pos"),&Animation::add_track,DEFVAL(-1));
+ ClassDB::bind_method(_MD("remove_track","idx"),&Animation::remove_track);
+ ClassDB::bind_method(_MD("get_track_count"),&Animation::get_track_count);
+ ClassDB::bind_method(_MD("track_get_type","idx"),&Animation::track_get_type);
+ ClassDB::bind_method(_MD("track_get_path","idx"),&Animation::track_get_path);
+ ClassDB::bind_method(_MD("track_set_path","idx","path"),&Animation::track_set_path);
+ ClassDB::bind_method(_MD("find_track","path"),&Animation::find_track);
- ObjectTypeDB::bind_method(_MD("track_move_up","idx"),&Animation::track_move_up);
- ObjectTypeDB::bind_method(_MD("track_move_down","idx"),&Animation::track_move_down);
+ ClassDB::bind_method(_MD("track_move_up","idx"),&Animation::track_move_up);
+ ClassDB::bind_method(_MD("track_move_down","idx"),&Animation::track_move_down);
- ObjectTypeDB::bind_method(_MD("track_set_imported","idx","imported"),&Animation::track_set_imported);
- ObjectTypeDB::bind_method(_MD("track_is_imported","idx"),&Animation::track_is_imported);
+ ClassDB::bind_method(_MD("track_set_imported","idx","imported"),&Animation::track_set_imported);
+ ClassDB::bind_method(_MD("track_is_imported","idx"),&Animation::track_is_imported);
- ObjectTypeDB::bind_method(_MD("transform_track_insert_key","idx","time","loc","rot","scale"),&Animation::transform_track_insert_key);
- ObjectTypeDB::bind_method(_MD("track_insert_key","idx","time","key","transition"),&Animation::track_insert_key,DEFVAL(1));
- ObjectTypeDB::bind_method(_MD("track_remove_key","idx","key_idx"),&Animation::track_remove_key);
- ObjectTypeDB::bind_method(_MD("track_remove_key_at_pos","idx","pos"),&Animation::track_remove_key_at_pos);
- ObjectTypeDB::bind_method(_MD("track_set_key_value","idx","key","value"),&Animation::track_set_key_value);
- ObjectTypeDB::bind_method(_MD("track_set_key_transition","idx","key_idx","transition"),&Animation::track_set_key_transition);
- ObjectTypeDB::bind_method(_MD("track_get_key_transition","idx","key_idx"),&Animation::track_get_key_transition);
+ ClassDB::bind_method(_MD("transform_track_insert_key","idx","time","loc","rot","scale"),&Animation::transform_track_insert_key);
+ ClassDB::bind_method(_MD("track_insert_key","idx","time","key","transition"),&Animation::track_insert_key,DEFVAL(1));
+ ClassDB::bind_method(_MD("track_remove_key","idx","key_idx"),&Animation::track_remove_key);
+ ClassDB::bind_method(_MD("track_remove_key_at_pos","idx","pos"),&Animation::track_remove_key_at_pos);
+ ClassDB::bind_method(_MD("track_set_key_value","idx","key","value"),&Animation::track_set_key_value);
+ ClassDB::bind_method(_MD("track_set_key_transition","idx","key_idx","transition"),&Animation::track_set_key_transition);
+ ClassDB::bind_method(_MD("track_get_key_transition","idx","key_idx"),&Animation::track_get_key_transition);
- ObjectTypeDB::bind_method(_MD("track_get_key_count","idx"),&Animation::track_get_key_count);
- ObjectTypeDB::bind_method(_MD("track_get_key_value","idx","key_idx"),&Animation::track_get_key_value);
- ObjectTypeDB::bind_method(_MD("track_get_key_time","idx","key_idx"),&Animation::track_get_key_time);
- ObjectTypeDB::bind_method(_MD("track_find_key","idx","time","exact"),&Animation::track_find_key,DEFVAL(false));
+ ClassDB::bind_method(_MD("track_get_key_count","idx"),&Animation::track_get_key_count);
+ ClassDB::bind_method(_MD("track_get_key_value","idx","key_idx"),&Animation::track_get_key_value);
+ ClassDB::bind_method(_MD("track_get_key_time","idx","key_idx"),&Animation::track_get_key_time);
+ ClassDB::bind_method(_MD("track_find_key","idx","time","exact"),&Animation::track_find_key,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("track_set_interpolation_type","idx","interpolation"),&Animation::track_set_interpolation_type);
- ObjectTypeDB::bind_method(_MD("track_get_interpolation_type","idx"),&Animation::track_get_interpolation_type);
+ ClassDB::bind_method(_MD("track_set_interpolation_type","idx","interpolation"),&Animation::track_set_interpolation_type);
+ ClassDB::bind_method(_MD("track_get_interpolation_type","idx"),&Animation::track_get_interpolation_type);
+ ClassDB::bind_method(_MD("track_set_interpolation_loop_wrap","idx","interpolation"),&Animation::track_set_interpolation_loop_wrap);
+ ClassDB::bind_method(_MD("track_get_interpolation_loop_wrap","idx"),&Animation::track_get_interpolation_loop_wrap);
- ObjectTypeDB::bind_method(_MD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate);
- ObjectTypeDB::bind_method(_MD("value_track_set_update_mode","idx","mode"),&Animation::value_track_set_update_mode);
- ObjectTypeDB::bind_method(_MD("value_track_get_update_mode","idx"),&Animation::value_track_get_update_mode);
+ ClassDB::bind_method(_MD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate);
+ ClassDB::bind_method(_MD("value_track_set_update_mode","idx","mode"),&Animation::value_track_set_update_mode);
+ ClassDB::bind_method(_MD("value_track_get_update_mode","idx"),&Animation::value_track_get_update_mode);
- ObjectTypeDB::bind_method(_MD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices);
+ ClassDB::bind_method(_MD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices);
- ObjectTypeDB::bind_method(_MD("method_track_get_key_indices","idx","time_sec","delta"),&Animation::_method_track_get_key_indices);
- ObjectTypeDB::bind_method(_MD("method_track_get_name","idx","key_idx"),&Animation::method_track_get_name);
- ObjectTypeDB::bind_method(_MD("method_track_get_params","idx","key_idx"),&Animation::method_track_get_params);
+ ClassDB::bind_method(_MD("method_track_get_key_indices","idx","time_sec","delta"),&Animation::_method_track_get_key_indices);
+ ClassDB::bind_method(_MD("method_track_get_name","idx","key_idx"),&Animation::method_track_get_name);
+ ClassDB::bind_method(_MD("method_track_get_params","idx","key_idx"),&Animation::method_track_get_params);
- ObjectTypeDB::bind_method(_MD("set_length","time_sec"),&Animation::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&Animation::get_length);
+ ClassDB::bind_method(_MD("set_length","time_sec"),&Animation::set_length);
+ ClassDB::bind_method(_MD("get_length"),&Animation::get_length);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&Animation::has_loop);
+ ClassDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&Animation::has_loop);
- ObjectTypeDB::bind_method(_MD("set_step","size_sec"),&Animation::set_step);
- ObjectTypeDB::bind_method(_MD("get_step"),&Animation::get_step);
+ ClassDB::bind_method(_MD("set_step","size_sec"),&Animation::set_step);
+ ClassDB::bind_method(_MD("get_step"),&Animation::get_step);
- ObjectTypeDB::bind_method(_MD("clear"),&Animation::clear);
+ ClassDB::bind_method(_MD("clear"),&Animation::clear);
BIND_CONSTANT( TYPE_VALUE );
BIND_CONSTANT( TYPE_TRANSFORM );
@@ -1985,11 +2005,6 @@ void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,fl
prev_erased=false;
norm=Vector3();
}
-
-
-
- // print_line(itos(i)+" could be eliminated: "+rtos(tr));
- //}
}
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index 6c8d7252aa..b81ac4f1bf 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,16 +35,11 @@
*/
class Animation : public Resource {
- OBJ_TYPE( Animation, Resource );
+ GDCLASS( Animation, Resource );
RES_BASE_EXTENSION("anm");
public:
- enum LoopMode {
- LOOP_NONE,
- LOOP_ENABLED,
- LOOP_WRAP
- };
enum TrackType {
TYPE_VALUE, ///< Set a value in a property, can be interpolated.
@@ -71,9 +66,10 @@ private:
TrackType type;
InterpolationType interpolation;
+ bool loop_wrap;
NodePath path; // path to something
bool imported;
- Track() { interpolation=INTERPOLATION_LINEAR; imported=false;}
+ Track() { interpolation=INTERPOLATION_LINEAR; imported=false; loop_wrap=true;}
virtual ~Track() {}
};
@@ -164,7 +160,7 @@ private:
_FORCE_INLINE_ float _cubic_interpolate( const float& p_pre_a,const float& p_a, const float& p_b, const float& p_post_b, float p_c) const;
template<class T>
- _FORCE_INLINE_ T _interpolate( const Vector< TKey<T> >& p_keys, float p_time, InterpolationType p_interp,bool *p_ok) const;
+ _FORCE_INLINE_ T _interpolate( const Vector< TKey<T> >& p_keys, float p_time, InterpolationType p_interp,bool p_loop_wrap,bool *p_ok) const;
_FORCE_INLINE_ void _value_track_get_key_indices_in_range(const ValueTrack * vt, float from_time, float to_time,List<int> *p_indices) const;
_FORCE_INLINE_ void _method_track_get_key_indices_in_range(const MethodTrack * mt, float from_time, float to_time,List<int> *p_indices) const;
@@ -188,11 +184,11 @@ private:
return ret;
}
- DVector<int> _value_track_get_key_indices(int p_track, float p_time, float p_delta) const {
+ PoolVector<int> _value_track_get_key_indices(int p_track, float p_time, float p_delta) const {
List<int> idxs;
value_track_get_key_indices(p_track,p_time,p_delta,&idxs);
- DVector<int> idxr;
+ PoolVector<int> idxr;
for (List<int>::Element *E=idxs.front();E;E=E->next()) {
@@ -200,11 +196,11 @@ private:
}
return idxr;
}
- DVector<int> _method_track_get_key_indices(int p_track, float p_time, float p_delta) const {
+ PoolVector<int> _method_track_get_key_indices(int p_track, float p_time, float p_delta) const {
List<int> idxs;
method_track_get_key_indices(p_track,p_time,p_delta,&idxs);
- DVector<int> idxr;
+ PoolVector<int> idxr;
for (List<int>::Element *E=idxs.front();E;E=E->next()) {
@@ -260,6 +256,8 @@ public:
void track_set_interpolation_type(int p_track,InterpolationType p_interp);
InterpolationType track_get_interpolation_type(int p_track) const;
+ void track_set_interpolation_loop_wrap(int p_track,bool p_enable);
+ bool track_get_interpolation_loop_wrap(int p_track) const;
Error transform_track_interpolate(int p_track, float p_time, Vector3 * r_loc, Quat *r_rot, Vector3 *r_scale) const;
diff --git a/scene/resources/audio_stream.cpp b/scene/resources/audio_stream.cpp
index 1dd702abd2..7c269de007 100644
--- a/scene/resources/audio_stream.cpp
+++ b/scene/resources/audio_stream.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,22 +33,22 @@
void AudioStreamPlayback::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("play","from_pos_sec"),&AudioStreamPlayback::play,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("stop"),&AudioStreamPlayback::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AudioStreamPlayback::is_playing);
+ ClassDB::bind_method(_MD("play","from_pos_sec"),&AudioStreamPlayback::play,DEFVAL(0));
+ ClassDB::bind_method(_MD("stop"),&AudioStreamPlayback::stop);
+ ClassDB::bind_method(_MD("is_playing"),&AudioStreamPlayback::is_playing);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&AudioStreamPlayback::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&AudioStreamPlayback::has_loop);
+ ClassDB::bind_method(_MD("set_loop","enabled"),&AudioStreamPlayback::set_loop);
+ ClassDB::bind_method(_MD("has_loop"),&AudioStreamPlayback::has_loop);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&AudioStreamPlayback::get_loop_count);
+ ClassDB::bind_method(_MD("get_loop_count"),&AudioStreamPlayback::get_loop_count);
- ObjectTypeDB::bind_method(_MD("seek_pos","pos"),&AudioStreamPlayback::seek_pos);
- ObjectTypeDB::bind_method(_MD("get_pos"),&AudioStreamPlayback::get_pos);
+ ClassDB::bind_method(_MD("seek_pos","pos"),&AudioStreamPlayback::seek_pos);
+ ClassDB::bind_method(_MD("get_pos"),&AudioStreamPlayback::get_pos);
- ObjectTypeDB::bind_method(_MD("get_length"),&AudioStreamPlayback::get_length);
- ObjectTypeDB::bind_method(_MD("get_channels"),&AudioStreamPlayback::get_channels);
- ObjectTypeDB::bind_method(_MD("get_mix_rate"),&AudioStreamPlayback::get_mix_rate);
- ObjectTypeDB::bind_method(_MD("get_minimum_buffer_size"),&AudioStreamPlayback::get_minimum_buffer_size);
+ ClassDB::bind_method(_MD("get_length"),&AudioStreamPlayback::get_length);
+ ClassDB::bind_method(_MD("get_channels"),&AudioStreamPlayback::get_channels);
+ ClassDB::bind_method(_MD("get_mix_rate"),&AudioStreamPlayback::get_mix_rate);
+ ClassDB::bind_method(_MD("get_minimum_buffer_size"),&AudioStreamPlayback::get_minimum_buffer_size);
}
diff --git a/scene/resources/audio_stream.h b/scene/resources/audio_stream.h
index a4a2ad7599..b79707cd32 100644
--- a/scene/resources/audio_stream.h
+++ b/scene/resources/audio_stream.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class AudioStreamPlayback : public Reference {
- OBJ_TYPE( AudioStreamPlayback, Reference );
+ GDCLASS( AudioStreamPlayback, Reference );
protected:
static void _bind_methods();
public:
@@ -67,7 +67,7 @@ public:
class AudioStream : public Resource {
- OBJ_TYPE( AudioStream, Resource );
+ GDCLASS( AudioStream, Resource );
OBJ_SAVE_TYPE( AudioStream ); //children are all saved as AudioStream, so they can be exchanged
protected:
diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp
index 3e10048f57..7b49ec0849 100644
--- a/scene/resources/audio_stream_resampled.cpp
+++ b/scene/resources/audio_stream_resampled.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/audio_stream_resampled.h b/scene/resources/audio_stream_resampled.h
index 64f9d17d88..761643b027 100644
--- a/scene/resources/audio_stream_resampled.h
+++ b/scene/resources/audio_stream_resampled.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#if 0
class AudioStreamResampled : public AudioStream {
- OBJ_TYPE(AudioStreamResampled,AudioStream);
+ GDCLASS(AudioStreamResampled,AudioStream);
uint32_t rb_bits;
uint32_t rb_len;
diff --git a/scene/resources/baked_light.cpp b/scene/resources/baked_light.cpp
index e4510be874..616c12e8d7 100644
--- a/scene/resources/baked_light.cpp
+++ b/scene/resources/baked_light.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,574 +29,3 @@
#include "baked_light.h"
#include "servers/visual_server.h"
-void BakedLight::set_mode(Mode p_mode) {
-
- mode=p_mode;
- VS::get_singleton()->baked_light_set_mode(baked_light,(VS::BakedLightMode(p_mode)));
-
-}
-
-BakedLight::Mode BakedLight::get_mode() const{
-
- return mode;
-}
-
-void BakedLight::set_octree(const DVector<uint8_t>& p_octree) {
-
- VS::get_singleton()->baked_light_set_octree(baked_light,p_octree);
-}
-
-DVector<uint8_t> BakedLight::get_octree() const {
-
- return VS::get_singleton()->baked_light_get_octree(baked_light);
-}
-
-void BakedLight::set_light(const DVector<uint8_t>& p_light) {
-
- VS::get_singleton()->baked_light_set_light(baked_light,p_light);
-}
-
-DVector<uint8_t> BakedLight::get_light() const {
-
- return VS::get_singleton()->baked_light_get_light(baked_light);
-}
-
-
-void BakedLight::set_sampler_octree(const DVector<int>& p_sampler_octree) {
-
- VS::get_singleton()->baked_light_set_sampler_octree(baked_light,p_sampler_octree);
-}
-
-DVector<int> BakedLight::get_sampler_octree() const {
-
- return VS::get_singleton()->baked_light_get_sampler_octree(baked_light);
-}
-
-
-
-
-
-void BakedLight::add_lightmap(const Ref<Texture> &p_texture,Size2 p_gen_size) {
-
- LightMap lm;
- lm.texture=p_texture;
- lm.gen_size=p_gen_size;
- lightmaps.push_back(lm);
- _update_lightmaps();
- _change_notify();
-}
-
-void BakedLight::set_lightmap_gen_size(int p_idx,const Size2& p_size){
-
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps[p_idx].gen_size=p_size;
- _update_lightmaps();
-}
-Size2 BakedLight::get_lightmap_gen_size(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,lightmaps.size(),Size2());
- return lightmaps[p_idx].gen_size;
-
-}
-void BakedLight::set_lightmap_texture(int p_idx,const Ref<Texture> &p_texture){
-
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps[p_idx].texture=p_texture;
- _update_lightmaps();
-
-}
-Ref<Texture> BakedLight::get_lightmap_texture(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,lightmaps.size(),Ref<Texture>());
- return lightmaps[p_idx].texture;
-
-}
-void BakedLight::erase_lightmap(int p_idx){
-
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps.remove(p_idx);
- _update_lightmaps();
- _change_notify();
-
-}
-int BakedLight::get_lightmaps_count() const{
-
- return lightmaps.size();
-}
-void BakedLight::clear_lightmaps(){
-
- lightmaps.clear();
- _update_lightmaps();
- _change_notify();
-}
-
-
-
-void BakedLight::_update_lightmaps() {
-
- VS::get_singleton()->baked_light_clear_lightmaps(baked_light);
- for(int i=0;i<lightmaps.size();i++) {
-
- RID tid;
- if (lightmaps[i].texture.is_valid())
- tid=lightmaps[i].texture->get_rid();
- VS::get_singleton()->baked_light_add_lightmap(baked_light,tid,i);
- }
-}
-
-
-
-RID BakedLight::get_rid() const {
-
- return baked_light;
-}
-
-Array BakedLight::_get_lightmap_data() const {
-
- Array ret;
- ret.resize(lightmaps.size()*2);
-
- int idx=0;
- for(int i=0;i<lightmaps.size();i++) {
-
- ret[idx++]=Size2(lightmaps[i].gen_size);
- ret[idx++]=lightmaps[i].texture;
- }
- return ret;
-
-}
-
-void BakedLight::_set_lightmap_data(Array p_array){
-
- lightmaps.clear();
- for(int i=0;i<p_array.size();i+=2) {
-
- Size2 size = p_array[i];
- Ref<Texture> tex = p_array[i+1];
-// ERR_CONTINUE(tex.is_null());
- LightMap lm;
- lm.gen_size=size;
- lm.texture=tex;
- lightmaps.push_back(lm);
- }
- _update_lightmaps();
-}
-
-
-void BakedLight::set_cell_subdivision(int p_subdiv) {
-
- cell_subdiv=p_subdiv;
-}
-
-int BakedLight::get_cell_subdivision() const{
-
- return cell_subdiv;
-}
-
-void BakedLight::set_initial_lattice_subdiv(int p_size){
-
- lattice_subdiv=p_size;
-}
-int BakedLight::get_initial_lattice_subdiv() const{
-
- return lattice_subdiv;
-}
-
-void BakedLight::set_plot_size(float p_size){
-
- plot_size=p_size;
-}
-float BakedLight::get_plot_size() const{
-
- return plot_size;
-}
-
-void BakedLight::set_bounces(int p_size){
-
- bounces=p_size;
-}
-int BakedLight::get_bounces() const{
-
- return bounces;
-}
-
-void BakedLight::set_cell_extra_margin(float p_margin) {
- cell_extra_margin=p_margin;
-}
-
-float BakedLight::get_cell_extra_margin() const {
-
- return cell_extra_margin;
-}
-
-void BakedLight::set_edge_damp(float p_margin) {
- edge_damp=p_margin;
-}
-
-float BakedLight::get_edge_damp() const {
-
- return edge_damp;
-}
-
-
-void BakedLight::set_normal_damp(float p_margin) {
- normal_damp=p_margin;
-}
-
-float BakedLight::get_normal_damp() const {
-
- return normal_damp;
-}
-
-void BakedLight::set_tint(float p_margin) {
- tint=p_margin;
-}
-
-float BakedLight::get_tint() const {
-
- return tint;
-}
-
-void BakedLight::set_saturation(float p_margin) {
- saturation=p_margin;
-}
-
-float BakedLight::get_saturation() const {
-
- return saturation;
-}
-
-void BakedLight::set_ao_radius(float p_ao_radius) {
- ao_radius=p_ao_radius;
-}
-
-float BakedLight::get_ao_radius() const {
- return ao_radius;
-}
-
-void BakedLight::set_ao_strength(float p_ao_strength) {
-
- ao_strength=p_ao_strength;
-}
-
-float BakedLight::get_ao_strength() const {
-
- return ao_strength;
-}
-
-void BakedLight::set_realtime_color_enabled(const bool p_realtime_color_enabled) {
-
- VS::get_singleton()->baked_light_set_realtime_color_enabled(baked_light, p_realtime_color_enabled);
-}
-
-bool BakedLight::get_realtime_color_enabled() const {
-
- return VS::get_singleton()->baked_light_get_realtime_color_enabled(baked_light);
-}
-
-
-void BakedLight::set_realtime_color(const Color &p_realtime_color) {
-
- VS::get_singleton()->baked_light_set_realtime_color(baked_light, p_realtime_color);
-}
-
-Color BakedLight::get_realtime_color() const {
-
- return VS::get_singleton()->baked_light_get_realtime_color(baked_light);
-}
-
-void BakedLight::set_realtime_energy(const float p_realtime_energy) {
-
- VS::get_singleton()->baked_light_set_realtime_energy(baked_light, p_realtime_energy);
-}
-
-float BakedLight::get_realtime_energy() const {
-
- return VS::get_singleton()->baked_light_get_realtime_energy(baked_light);
-}
-
-
-
-void BakedLight::set_energy_multiplier(float p_multiplier){
-
- energy_multiply=p_multiplier;
-}
-float BakedLight::get_energy_multiplier() const{
-
- return energy_multiply;
-}
-
-void BakedLight::set_gamma_adjust(float p_adjust){
-
- gamma_adjust=p_adjust;
-}
-float BakedLight::get_gamma_adjust() const{
-
- return gamma_adjust;
-}
-
-void BakedLight::set_bake_flag(BakeFlags p_flags,bool p_enable){
-
- flags[p_flags]=p_enable;
-}
-bool BakedLight::get_bake_flag(BakeFlags p_flags) const{
-
- return flags[p_flags];
-}
-
-void BakedLight::set_format(Format p_format) {
-
- format=p_format;
- VS::get_singleton()->baked_light_set_lightmap_multiplier(baked_light,format==FORMAT_HDR8?8.0:1.0);
-}
-
-BakedLight::Format BakedLight::get_format() const{
-
- return format;
-}
-
-void BakedLight::set_transfer_lightmaps_only_to_uv2(bool p_enable) {
-
- transfer_only_uv2=p_enable;
-}
-
-bool BakedLight::get_transfer_lightmaps_only_to_uv2() const{
-
- return transfer_only_uv2;
-}
-
-
-bool BakedLight::_set(const StringName& p_name, const Variant& p_value) {
-
- String n = p_name;
- if (!n.begins_with("lightmap"))
- return false;
- int idx = n.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(idx<0,false);
- ERR_FAIL_COND_V(idx>lightmaps.size(),false);
-
- String what = n.get_slicec('/',2);
- Ref<Texture> tex;
- Size2 gens;
-
- if (what=="texture")
- tex=p_value;
- else if (what=="gen_size")
- gens=p_value;
-
- if (idx==lightmaps.size()) {
- if (tex.is_valid() || gens!=Size2())
- add_lightmap(tex,gens);
- } else {
- if (tex.is_valid())
- set_lightmap_texture(idx,tex);
- else if (gens!=Size2())
- set_lightmap_gen_size(idx,gens);
- }
-
-
- return true;
-}
-
-bool BakedLight::_get(const StringName& p_name,Variant &r_ret) const{
-
- String n = p_name;
- if (!n.begins_with("lightmap"))
- return false;
- int idx = n.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(idx<0,false);
- ERR_FAIL_COND_V(idx>lightmaps.size(),false);
-
- String what = n.get_slicec('/',2);
-
- if (what=="texture") {
- if (idx==lightmaps.size())
- r_ret=Ref<Texture>();
- else
- r_ret=lightmaps[idx].texture;
-
- } else if (what=="gen_size") {
-
- if (idx==lightmaps.size())
- r_ret=Size2();
- else
- r_ret=Size2(lightmaps[idx].gen_size);
- } else
- return false;
-
- return true;
-
-
-}
-void BakedLight::_get_property_list( List<PropertyInfo> *p_list) const{
-
- for(int i=0;i<=lightmaps.size();i++) {
-
- p_list->push_back(PropertyInfo(Variant::VECTOR2,"lightmaps/"+itos(i)+"/gen_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::OBJECT,"lightmaps/"+itos(i)+"/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture",PROPERTY_USAGE_EDITOR));
- }
-}
-
-
-void BakedLight::_bind_methods(){
-
-
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&BakedLight::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&BakedLight::get_mode);
-
- ObjectTypeDB::bind_method(_MD("set_octree","octree"),&BakedLight::set_octree);
- ObjectTypeDB::bind_method(_MD("get_octree"),&BakedLight::get_octree);
-
- ObjectTypeDB::bind_method(_MD("set_light","light"),&BakedLight::set_light);
- ObjectTypeDB::bind_method(_MD("get_light"),&BakedLight::get_light);
-
- ObjectTypeDB::bind_method(_MD("set_sampler_octree","sampler_octree"),&BakedLight::set_sampler_octree);
- ObjectTypeDB::bind_method(_MD("get_sampler_octree"),&BakedLight::get_sampler_octree);
-
-
- ObjectTypeDB::bind_method(_MD("add_lightmap","texture:Texture","gen_size"),&BakedLight::add_lightmap);
- ObjectTypeDB::bind_method(_MD("erase_lightmap","id"),&BakedLight::erase_lightmap);
- ObjectTypeDB::bind_method(_MD("clear_lightmaps"),&BakedLight::clear_lightmaps);
-
- ObjectTypeDB::bind_method(_MD("_set_lightmap_data","lightmap_data"),&BakedLight::_set_lightmap_data);
- ObjectTypeDB::bind_method(_MD("_get_lightmap_data"),&BakedLight::_get_lightmap_data);
-
- ObjectTypeDB::bind_method(_MD("set_cell_subdivision","cell_subdivision"),&BakedLight::set_cell_subdivision);
- ObjectTypeDB::bind_method(_MD("get_cell_subdivision"),&BakedLight::get_cell_subdivision);
-
- ObjectTypeDB::bind_method(_MD("set_initial_lattice_subdiv","cell_subdivision"),&BakedLight::set_initial_lattice_subdiv);
- ObjectTypeDB::bind_method(_MD("get_initial_lattice_subdiv","cell_subdivision"),&BakedLight::get_initial_lattice_subdiv);
-
- ObjectTypeDB::bind_method(_MD("set_plot_size","plot_size"),&BakedLight::set_plot_size);
- ObjectTypeDB::bind_method(_MD("get_plot_size"),&BakedLight::get_plot_size);
-
- ObjectTypeDB::bind_method(_MD("set_bounces","bounces"),&BakedLight::set_bounces);
- ObjectTypeDB::bind_method(_MD("get_bounces"),&BakedLight::get_bounces);
-
- ObjectTypeDB::bind_method(_MD("set_cell_extra_margin","cell_extra_margin"),&BakedLight::set_cell_extra_margin);
- ObjectTypeDB::bind_method(_MD("get_cell_extra_margin"),&BakedLight::get_cell_extra_margin);
-
- ObjectTypeDB::bind_method(_MD("set_edge_damp","edge_damp"),&BakedLight::set_edge_damp);
- ObjectTypeDB::bind_method(_MD("get_edge_damp"),&BakedLight::get_edge_damp);
-
- ObjectTypeDB::bind_method(_MD("set_normal_damp","normal_damp"),&BakedLight::set_normal_damp);
- ObjectTypeDB::bind_method(_MD("get_normal_damp"),&BakedLight::get_normal_damp);
-
- ObjectTypeDB::bind_method(_MD("set_tint","tint"),&BakedLight::set_tint);
- ObjectTypeDB::bind_method(_MD("get_tint"),&BakedLight::get_tint);
-
- ObjectTypeDB::bind_method(_MD("set_saturation","saturation"),&BakedLight::set_saturation);
- ObjectTypeDB::bind_method(_MD("get_saturation"),&BakedLight::get_saturation);
-
- ObjectTypeDB::bind_method(_MD("set_ao_radius","ao_radius"),&BakedLight::set_ao_radius);
- ObjectTypeDB::bind_method(_MD("get_ao_radius"),&BakedLight::get_ao_radius);
-
- ObjectTypeDB::bind_method(_MD("set_ao_strength","ao_strength"),&BakedLight::set_ao_strength);
- ObjectTypeDB::bind_method(_MD("get_ao_strength"),&BakedLight::get_ao_strength);
-
- ObjectTypeDB::bind_method(_MD("set_realtime_color_enabled", "enabled"), &BakedLight::set_realtime_color_enabled);
- ObjectTypeDB::bind_method(_MD("get_realtime_color_enabled"), &BakedLight::get_realtime_color_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_realtime_color", "tint"), &BakedLight::set_realtime_color);
- ObjectTypeDB::bind_method(_MD("get_realtime_color"), &BakedLight::get_realtime_color);
-
- ObjectTypeDB::bind_method(_MD("set_realtime_energy", "energy"), &BakedLight::set_realtime_energy);
- ObjectTypeDB::bind_method(_MD("get_realtime_energy"), &BakedLight::get_realtime_energy);
-
- ObjectTypeDB::bind_method(_MD("set_format","format"),&BakedLight::set_format);
- ObjectTypeDB::bind_method(_MD("get_format"),&BakedLight::get_format);
-
- ObjectTypeDB::bind_method(_MD("set_transfer_lightmaps_only_to_uv2","enable"),&BakedLight::set_transfer_lightmaps_only_to_uv2);
- ObjectTypeDB::bind_method(_MD("get_transfer_lightmaps_only_to_uv2"),&BakedLight::get_transfer_lightmaps_only_to_uv2);
-
-
-
-
- ObjectTypeDB::bind_method(_MD("set_energy_multiplier","energy_multiplier"),&BakedLight::set_energy_multiplier);
- ObjectTypeDB::bind_method(_MD("get_energy_multiplier"),&BakedLight::get_energy_multiplier);
-
- ObjectTypeDB::bind_method(_MD("set_gamma_adjust","gamma_adjust"),&BakedLight::set_gamma_adjust);
- ObjectTypeDB::bind_method(_MD("get_gamma_adjust"),&BakedLight::get_gamma_adjust);
-
- ObjectTypeDB::bind_method(_MD("set_bake_flag","flag","enabled"),&BakedLight::set_bake_flag);
- ObjectTypeDB::bind_method(_MD("get_bake_flag","flag"),&BakedLight::get_bake_flag);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode/mode",PROPERTY_HINT_ENUM,"Octree,Lightmaps"),_SCS("set_mode"),_SCS("get_mode"));
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/format",PROPERTY_HINT_ENUM,"RGB,HDR8,HDR16"),_SCS("set_format"),_SCS("get_format"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/cell_subdiv",PROPERTY_HINT_RANGE,"4,14,1"),_SCS("set_cell_subdivision"),_SCS("get_cell_subdivision"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/lattice_subdiv",PROPERTY_HINT_RANGE,"1,5,1"),_SCS("set_initial_lattice_subdiv"),_SCS("get_initial_lattice_subdiv"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/light_bounces",PROPERTY_HINT_RANGE,"0,3,1"),_SCS("set_bounces"),_SCS("get_bounces"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/plot_size",PROPERTY_HINT_RANGE,"1.0,16.0,0.01"),_SCS("set_plot_size"),_SCS("get_plot_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/energy_mult",PROPERTY_HINT_RANGE,"0.01,4096.0,0.01"),_SCS("set_energy_multiplier"),_SCS("get_energy_multiplier"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/gamma_adjust",PROPERTY_HINT_EXP_EASING),_SCS("set_gamma_adjust"),_SCS("get_gamma_adjust"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/saturation",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("set_saturation"),_SCS("get_saturation"));
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/diffuse"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/specular"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_SPECULAR);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/translucent"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_TRANSLUCENT);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/conserve_energy"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_CONSERVE_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/linear_color"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_LINEAR_COLOR);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"lightmap/use_only_uv2"),_SCS("set_transfer_lightmaps_only_to_uv2"),_SCS("get_transfer_lightmaps_only_to_uv2"));
-
- ADD_PROPERTY( PropertyInfo(Variant::RAW_ARRAY,"octree",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_octree"),_SCS("get_octree"));
- ADD_PROPERTY( PropertyInfo(Variant::RAW_ARRAY,"light",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_light"),_SCS("get_light"));
- ADD_PROPERTY( PropertyInfo(Variant::INT_ARRAY,"sampler_octree",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_sampler_octree"),_SCS("get_sampler_octree"));
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"lightmaps",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_lightmap_data"),_SCS("_get_lightmap_data"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/cell_margin",PROPERTY_HINT_RANGE,"0.01,0.8,0.01"),_SCS("set_cell_extra_margin"),_SCS("get_cell_extra_margin"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/edge_damp",PROPERTY_HINT_RANGE,"0.0,8.0,0.1"),_SCS("set_edge_damp"),_SCS("get_edge_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/normal_damp",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_normal_damp"),_SCS("get_normal_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/light_tint",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_tint"),_SCS("get_tint"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_radius",PROPERTY_HINT_RANGE,"0.0,16.0,0.01"),_SCS("set_ao_radius"),_SCS("get_ao_radius"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_strength",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_ao_strength"),_SCS("get_ao_strength"));
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "realtime/enabled"), _SCS("set_realtime_color_enabled"), _SCS("get_realtime_color_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "realtime/color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_realtime_color"), _SCS("get_realtime_color"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "realtime/energy", PROPERTY_HINT_RANGE, "0.01,4096.0,0.01"), _SCS("set_realtime_energy"), _SCS("get_realtime_energy"));
-
-
- BIND_CONSTANT( MODE_OCTREE );
- BIND_CONSTANT( MODE_LIGHTMAPS );
-
- BIND_CONSTANT( BAKE_DIFFUSE );
- BIND_CONSTANT( BAKE_SPECULAR );
- BIND_CONSTANT( BAKE_TRANSLUCENT );
- BIND_CONSTANT( BAKE_CONSERVE_ENERGY );
- BIND_CONSTANT( BAKE_MAX );
-
-
-}
-
-
-BakedLight::BakedLight() {
-
- cell_subdiv=8;
- lattice_subdiv=4;
- plot_size=2.5;
- bounces=1;
- energy_multiply=2.0;
- gamma_adjust=0.7;
- cell_extra_margin=0.05;
- edge_damp=0.0;
- normal_damp=0.0;
- saturation=1;
- tint=0.0;
- ao_radius=2.5;
- ao_strength=0.7;
- format=FORMAT_RGB;
- transfer_only_uv2=false;
-
-
- flags[BAKE_DIFFUSE]=true;
- flags[BAKE_SPECULAR]=false;
- flags[BAKE_TRANSLUCENT]=true;
- flags[BAKE_CONSERVE_ENERGY]=false;
- flags[BAKE_LINEAR_COLOR]=false;
-
- mode=MODE_OCTREE;
- baked_light=VS::get_singleton()->baked_light_create();
-}
-
-BakedLight::~BakedLight() {
-
- VS::get_singleton()->free(baked_light);
-}
diff --git a/scene/resources/baked_light.h b/scene/resources/baked_light.h
index 16806d29e3..0c69ce429e 100644
--- a/scene/resources/baked_light.h
+++ b/scene/resources/baked_light.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,168 +32,6 @@
#include "resource.h"
#include "scene/resources/texture.h"
-class BakedLight : public Resource {
- OBJ_TYPE( BakedLight, Resource);
-public:
- enum Mode {
-
- MODE_OCTREE,
- MODE_LIGHTMAPS
- };
-
- enum Format {
-
- FORMAT_RGB,
- FORMAT_HDR8,
- FORMAT_HDR16
- };
-
- enum BakeFlags {
- BAKE_DIFFUSE,
- BAKE_SPECULAR,
- BAKE_TRANSLUCENT,
- BAKE_CONSERVE_ENERGY,
- BAKE_LINEAR_COLOR,
- BAKE_MAX
- };
-
-private:
-
- RID baked_light;
- Mode mode;
- struct LightMap {
- Size2i gen_size;
- Ref<Texture> texture;
- };
-
-
- Vector< LightMap> lightmaps;
-
- //bake vars
- int cell_subdiv;
- int lattice_subdiv;
- float plot_size;
- float energy_multiply;
- float gamma_adjust;
- float cell_extra_margin;
- float edge_damp;
- float normal_damp;
- float tint;
- float ao_radius;
- float ao_strength;
- float saturation;
- int bounces;
- bool transfer_only_uv2;
- Format format;
- bool flags[BAKE_MAX];
-
-
-
- void _update_lightmaps();
-
- Array _get_lightmap_data() const;
- void _set_lightmap_data(Array p_array);
-
-protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
-
- static void _bind_methods();
-
-public:
-
- void set_cell_subdivision(int p_subdiv);
- int get_cell_subdivision() const;
-
- void set_initial_lattice_subdiv(int p_size);
- int get_initial_lattice_subdiv() const;
-
- void set_plot_size(float p_size);
- float get_plot_size() const;
-
- void set_bounces(int p_size);
- int get_bounces() const;
-
- void set_energy_multiplier(float p_multiplier);
- float get_energy_multiplier() const;
-
- void set_gamma_adjust(float p_adjust);
- float get_gamma_adjust() const;
-
- void set_cell_extra_margin(float p_margin);
- float get_cell_extra_margin() const;
-
- void set_edge_damp(float p_margin);
- float get_edge_damp() const;
-
- void set_normal_damp(float p_margin);
- float get_normal_damp() const;
-
- void set_tint(float p_margin);
- float get_tint() const;
-
- void set_saturation(float p_saturation);
- float get_saturation() const;
-
- void set_ao_radius(float p_ao_radius);
- float get_ao_radius() const;
-
- void set_ao_strength(float p_ao_strength);
- float get_ao_strength() const;
-
- void set_realtime_color_enabled(const bool p_enabled);
- bool get_realtime_color_enabled() const;
-
- void set_realtime_color(const Color& p_realtime_color);
- Color get_realtime_color() const;
-
- void set_realtime_energy(const float p_realtime_energy);
- float get_realtime_energy() const;
-
- void set_bake_flag(BakeFlags p_flags,bool p_enable);
- bool get_bake_flag(BakeFlags p_flags) const;
-
- void set_format(Format p_margin);
- Format get_format() const;
-
- void set_transfer_lightmaps_only_to_uv2(bool p_enable);
- bool get_transfer_lightmaps_only_to_uv2() const;
-
- void set_mode(Mode p_mode);
- Mode get_mode() const;
-
- void set_octree(const DVector<uint8_t>& p_octree);
- DVector<uint8_t> get_octree() const;
-
- void set_light(const DVector<uint8_t>& p_light);
- DVector<uint8_t> get_light() const;
-
- void set_sampler_octree(const DVector<int>& p_sampler_octree);
- DVector<int> get_sampler_octree() const;
-
-
-
- void add_lightmap(const Ref<Texture> &p_texture,Size2 p_gen_size=Size2(256,256));
- void set_lightmap_gen_size(int p_idx,const Size2& p_size);
- Size2 get_lightmap_gen_size(int p_idx) const;
- void set_lightmap_texture(int p_idx,const Ref<Texture> &p_texture);
- Ref<Texture> get_lightmap_texture(int p_idx) const;
- void erase_lightmap(int p_idx);
- int get_lightmaps_count() const;
- void clear_lightmaps();
-
- virtual RID get_rid() const;
-
- BakedLight();
- ~BakedLight();
-};
-
-
-VARIANT_ENUM_CAST(BakedLight::Format);
-VARIANT_ENUM_CAST(BakedLight::Mode);
-VARIANT_ENUM_CAST(BakedLight::BakeFlags);
#endif // BAKED_LIGHT_H
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index f5bfce3ef8..d669ab771c 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,20 +45,20 @@ void BitMap::create_from_image_alpha(const Image& p_image){
ERR_FAIL_COND(p_image.empty());
Image img=p_image;
- img.convert(Image::FORMAT_INTENSITY);
- ERR_FAIL_COND(img.get_format()!=Image::FORMAT_INTENSITY);
+ img.convert(Image::FORMAT_LA8);
+ ERR_FAIL_COND(img.get_format()!=Image::FORMAT_LA8);
create(Size2(img.get_width(),img.get_height()));
- DVector<uint8_t>::Read r = img.get_data().read();
+ PoolVector<uint8_t>::Read r = img.get_data().read();
uint8_t *w = bitmask.ptr();
for(int i=0;i<width*height;i++) {
int bbyte = i/8;
int bbit = i % 8;
- if (r[i])
+ if (r[i*2])
w[bbyte]|=(1<<bbit);
}
@@ -177,23 +177,22 @@ Dictionary BitMap::_get_data() const{
void BitMap::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create","size"),&BitMap::create);
- ObjectTypeDB::bind_method(_MD("create_from_image_alpha","image"),&BitMap::create_from_image_alpha);
+ ClassDB::bind_method(_MD("create","size"),&BitMap::create);
+ ClassDB::bind_method(_MD("create_from_image_alpha","image"),&BitMap::create_from_image_alpha);
- ObjectTypeDB::bind_method(_MD("set_bit","pos","bit"),&BitMap::set_bit);
- ObjectTypeDB::bind_method(_MD("get_bit","pos"),&BitMap::get_bit);
+ ClassDB::bind_method(_MD("set_bit","pos","bit"),&BitMap::set_bit);
+ ClassDB::bind_method(_MD("get_bit","pos"),&BitMap::get_bit);
- ObjectTypeDB::bind_method(_MD("set_bit_rect","p_rect","bit"),&BitMap::set_bit_rect);
- ObjectTypeDB::bind_method(_MD("get_true_bit_count"),&BitMap::get_true_bit_count);
+ ClassDB::bind_method(_MD("set_bit_rect","p_rect","bit"),&BitMap::set_bit_rect);
+ ClassDB::bind_method(_MD("get_true_bit_count"),&BitMap::get_true_bit_count);
- ObjectTypeDB::bind_method(_MD("get_size"),&BitMap::get_size);
+ ClassDB::bind_method(_MD("get_size"),&BitMap::get_size);
- ObjectTypeDB::bind_method(_MD("_set_data"),&BitMap::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&BitMap::_get_data);
+ ClassDB::bind_method(_MD("_set_data"),&BitMap::_set_data);
+ ClassDB::bind_method(_MD("_get_data"),&BitMap::_get_data);
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
-
}
BitMap::BitMap() {
diff --git a/scene/resources/bit_mask.h b/scene/resources/bit_mask.h
index e75a2aa332..f749a53e34 100644
--- a/scene/resources/bit_mask.h
+++ b/scene/resources/bit_mask.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class BitMap : public Resource {
- OBJ_TYPE(BitMap,Resource);
+ GDCLASS(BitMap,Resource);
OBJ_SAVE_TYPE(BitMap);
RES_BASE_EXTENSION("pbm");
diff --git a/scene/resources/bounds.cpp b/scene/resources/bounds.cpp
index 65ce5e49e8..03d819451d 100644
--- a/scene/resources/bounds.cpp
+++ b/scene/resources/bounds.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,8 +31,8 @@
void Bounds::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("set_bsp_tree","bsp_tree"),&Bounds::set_bsp_tree);
- ObjectTypeDB::bind_method( _MD("get_bsp_tree"),&Bounds::get_bsp_tree );
+ ClassDB::bind_method( _MD("set_bsp_tree","bsp_tree"),&Bounds::set_bsp_tree);
+ ClassDB::bind_method( _MD("get_bsp_tree"),&Bounds::get_bsp_tree );
ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "bsp_tree" ), _SCS("set_bsp_tree"), _SCS("get_bsp_tree"));
diff --git a/scene/resources/bounds.h b/scene/resources/bounds.h
index a1610e2b57..bd5d996a36 100644
--- a/scene/resources/bounds.h
+++ b/scene/resources/bounds.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Bounds : public Resource {
- OBJ_TYPE(Bounds,Resource);
+ GDCLASS(Bounds,Resource);
BSP_Tree bsp_tree;
protected:
diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp
index 9a6fedeb0b..87585af862 100644
--- a/scene/resources/box_shape.cpp
+++ b/scene/resources/box_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@ Vector<Vector3> BoxShape::_gen_debug_mesh_lines() {
Vector<Vector3> lines;
- AABB aabb;
+ Rect3 aabb;
aabb.pos=-get_extents();
aabb.size=aabb.pos*-2;
@@ -70,8 +70,8 @@ Vector3 BoxShape::get_extents() const {
void BoxShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_extents","extents"),&BoxShape::set_extents);
- ObjectTypeDB::bind_method(_MD("get_extents"),&BoxShape::get_extents);
+ ClassDB::bind_method(_MD("set_extents","extents"),&BoxShape::set_extents);
+ ClassDB::bind_method(_MD("get_extents"),&BoxShape::get_extents);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"), _SCS("set_extents"), _SCS("get_extents") );
diff --git a/scene/resources/box_shape.h b/scene/resources/box_shape.h
index 88fca65eea..c17dd22015 100644
--- a/scene/resources/box_shape.h
+++ b/scene/resources/box_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class BoxShape : public Shape {
- OBJ_TYPE(BoxShape,Shape);
+ GDCLASS(BoxShape,Shape);
Vector3 extents;
protected:
diff --git a/scene/resources/canvas.cpp b/scene/resources/canvas.cpp
index 0c87d0473d..bda97141cc 100644
--- a/scene/resources/canvas.cpp
+++ b/scene/resources/canvas.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/canvas.h b/scene/resources/canvas.h
index 5120301a67..960136ac14 100644
--- a/scene/resources/canvas.h
+++ b/scene/resources/canvas.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Canvas : public Resource {
- OBJ_TYPE(Canvas,Resource);
+ GDCLASS(Canvas,Resource);
RID canvas;
diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp
index 4c53645d2d..db83a20f38 100644
--- a/scene/resources/capsule_shape.cpp
+++ b/scene/resources/capsule_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -107,10 +107,10 @@ float CapsuleShape::get_height() const {
void CapsuleShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CapsuleShape::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&CapsuleShape::get_radius);
- ObjectTypeDB::bind_method(_MD("set_height","height"),&CapsuleShape::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&CapsuleShape::get_height);
+ ClassDB::bind_method(_MD("set_radius","radius"),&CapsuleShape::set_radius);
+ ClassDB::bind_method(_MD("get_radius"),&CapsuleShape::get_radius);
+ ClassDB::bind_method(_MD("set_height","height"),&CapsuleShape::set_height);
+ ClassDB::bind_method(_MD("get_height"),&CapsuleShape::get_height);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), _SCS("set_radius"),_SCS("get_radius") );
ADD_PROPERTY( PropertyInfo(Variant::REAL,"height",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), _SCS("set_height"),_SCS("get_height") );
diff --git a/scene/resources/capsule_shape.h b/scene/resources/capsule_shape.h
index 4263c3a554..e788d9cfc5 100644
--- a/scene/resources/capsule_shape.h
+++ b/scene/resources/capsule_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class CapsuleShape : public Shape {
- OBJ_TYPE(CapsuleShape,Shape);
+ GDCLASS(CapsuleShape,Shape);
float radius;
float height;
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 1887ec11d7..27dcff0ce0 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,11 +89,11 @@ Rect2 CapsuleShape2D::get_rect() const {
void CapsuleShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CapsuleShape2D::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&CapsuleShape2D::get_radius);
+ ClassDB::bind_method(_MD("set_radius","radius"),&CapsuleShape2D::set_radius);
+ ClassDB::bind_method(_MD("get_radius"),&CapsuleShape2D::get_radius);
- ObjectTypeDB::bind_method(_MD("set_height","height"),&CapsuleShape2D::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&CapsuleShape2D::get_height);
+ ClassDB::bind_method(_MD("set_height","height"),&CapsuleShape2D::set_height);
+ ClassDB::bind_method(_MD("get_height"),&CapsuleShape2D::get_height);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius"),_SCS("set_radius"),_SCS("get_radius") );
diff --git a/scene/resources/capsule_shape_2d.h b/scene/resources/capsule_shape_2d.h
index 18b5c12a52..ef06072e14 100644
--- a/scene/resources/capsule_shape_2d.h
+++ b/scene/resources/capsule_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/resources/shape_2d.h"
class CapsuleShape2D : public Shape2D {
- OBJ_TYPE( CapsuleShape2D, Shape2D );
+ GDCLASS( CapsuleShape2D, Shape2D );
real_t height;
real_t radius;
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index 7171af9670..a82f3f5e2d 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -51,8 +51,8 @@ real_t CircleShape2D::get_radius() const {
void CircleShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CircleShape2D::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&CircleShape2D::get_radius);
+ ClassDB::bind_method(_MD("set_radius","radius"),&CircleShape2D::set_radius);
+ ClassDB::bind_method(_MD("get_radius"),&CircleShape2D::get_radius);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.5"),_SCS("set_radius"),_SCS("get_radius") );
diff --git a/scene/resources/circle_shape_2d.h b/scene/resources/circle_shape_2d.h
index c36e00d106..ec11b55169 100644
--- a/scene/resources/circle_shape_2d.h
+++ b/scene/resources/circle_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/resources/shape_2d.h"
class CircleShape2D : public Shape2D {
- OBJ_TYPE( CircleShape2D, Shape2D );
+ GDCLASS( CircleShape2D, Shape2D );
real_t radius;
void _update_shape();
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index dfa9181d60..1144ea41f1 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -54,24 +54,24 @@ void ColorRamp::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point);
- ObjectTypeDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point);
+ ClassDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point);
+ ClassDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point);
- ObjectTypeDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset);
+ ClassDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset);
+ ClassDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset);
- ObjectTypeDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color);
- ObjectTypeDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color);
+ ClassDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color);
+ ClassDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color);
- ObjectTypeDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset);
+ ClassDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset);
- ObjectTypeDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count);
+ ClassDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
+ ClassDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
+ ClassDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_COLORS,"colors"),&ColorRamp::set_colors);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_COLORS),&ColorRamp::get_colors);
+ ClassDB::bind_method(_MD(COLOR_RAMP_SET_COLORS,"colors"),&ColorRamp::set_colors);
+ ClassDB::bind_method(_MD(COLOR_RAMP_GET_COLORS),&ColorRamp::get_colors);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"offsets"),_SCS(COLOR_RAMP_SET_OFFSETS),_SCS(COLOR_RAMP_GET_OFFSETS) );
ADD_PROPERTY( PropertyInfo(Variant::REAL,"colors"),_SCS(COLOR_RAMP_SET_COLORS),_SCS(COLOR_RAMP_GET_COLORS) );
diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h
index daa21b480a..b6ca56dbf5 100644
--- a/scene/resources/color_ramp.h
+++ b/scene/resources/color_ramp.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "resource.h"
class ColorRamp: public Resource {
- OBJ_TYPE( ColorRamp, Resource );
+ GDCLASS( ColorRamp, Resource );
OBJ_SAVE_TYPE( ColorRamp );
public:
diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp
index 34bea038f4..5190bba6a5 100644
--- a/scene/resources/concave_polygon_shape.cpp
+++ b/scene/resources/concave_polygon_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,11 +34,11 @@ Vector<Vector3> ConcavePolygonShape::_gen_debug_mesh_lines() {
Set<DrawEdge> edges;
- DVector<Vector3> data=get_faces();
+ PoolVector<Vector3> data=get_faces();
int datalen=data.size();
ERR_FAIL_COND_V( (datalen%3)!=0,Vector<Vector3>() );
- DVector<Vector3>::Read r=data.read();
+ PoolVector<Vector3>::Read r=data.read();
for(int i=0;i<datalen;i+=3) {
@@ -94,13 +94,13 @@ void ConcavePolygonShape::_update_shape() {
}
-void ConcavePolygonShape::set_faces(const DVector<Vector3>& p_faces) {
+void ConcavePolygonShape::set_faces(const PoolVector<Vector3>& p_faces) {
PhysicsServer::get_singleton()->shape_set_data(get_shape(),p_faces);
notify_change_to_owners();
}
-DVector<Vector3> ConcavePolygonShape::get_faces() const {
+PoolVector<Vector3> ConcavePolygonShape::get_faces() const {
return PhysicsServer::get_singleton()->shape_get_data(get_shape());
@@ -110,8 +110,8 @@ DVector<Vector3> ConcavePolygonShape::get_faces() const {
void ConcavePolygonShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_faces","faces"),&ConcavePolygonShape::set_faces);
- ObjectTypeDB::bind_method(_MD("get_faces"),&ConcavePolygonShape::get_faces);
+ ClassDB::bind_method(_MD("set_faces","faces"),&ConcavePolygonShape::set_faces);
+ ClassDB::bind_method(_MD("get_faces"),&ConcavePolygonShape::get_faces);
}
ConcavePolygonShape::ConcavePolygonShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) {
diff --git a/scene/resources/concave_polygon_shape.h b/scene/resources/concave_polygon_shape.h
index a4845e9220..36e806d37a 100644
--- a/scene/resources/concave_polygon_shape.h
+++ b/scene/resources/concave_polygon_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ConcavePolygonShape : public Shape {
- OBJ_TYPE(ConcavePolygonShape,Shape);
+ GDCLASS(ConcavePolygonShape,Shape);
struct DrawEdge {
@@ -67,8 +67,8 @@ protected:
virtual Vector<Vector3> _gen_debug_mesh_lines();
public:
- void set_faces(const DVector<Vector3>& p_faces);
- DVector<Vector3> get_faces() const;
+ void set_faces(const PoolVector<Vector3>& p_faces);
+ PoolVector<Vector3> get_faces() const;
ConcavePolygonShape();
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index 2c66155cb8..6866750006 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,13 +31,13 @@
#include "servers/physics_2d_server.h"
#include "servers/visual_server.h"
-void ConcavePolygonShape2D::set_segments(const DVector<Vector2>& p_segments) {
+void ConcavePolygonShape2D::set_segments(const PoolVector<Vector2>& p_segments) {
Physics2DServer::get_singleton()->shape_set_data(get_rid(),p_segments);
emit_changed();
}
-DVector<Vector2> ConcavePolygonShape2D::get_segments() const {
+PoolVector<Vector2> ConcavePolygonShape2D::get_segments() const {
return Physics2DServer::get_singleton()->shape_get_data(get_rid());
}
@@ -45,12 +45,12 @@ DVector<Vector2> ConcavePolygonShape2D::get_segments() const {
void ConcavePolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) {
- DVector<Vector2> s = get_segments();
+ PoolVector<Vector2> s = get_segments();
int len=s.size();
if (len==0 || (len%2)==1)
return;
- DVector<Vector2>::Read r = s.read();
+ PoolVector<Vector2>::Read r = s.read();
for(int i=0;i<len;i+=2) {
VisualServer::get_singleton()->canvas_item_add_line(p_to_rid,r[i],r[i+1],p_color,2);
}
@@ -60,14 +60,14 @@ void ConcavePolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) {
Rect2 ConcavePolygonShape2D::get_rect() const {
- DVector<Vector2> s = get_segments();
+ PoolVector<Vector2> s = get_segments();
int len=s.size();
if (len==0)
return Rect2();
Rect2 rect;
- DVector<Vector2>::Read r = s.read();
+ PoolVector<Vector2>::Read r = s.read();
for(int i=0;i<len;i++) {
if (i==0)
rect.pos=r[i];
@@ -82,10 +82,10 @@ Rect2 ConcavePolygonShape2D::get_rect() const {
void ConcavePolygonShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_segments","segments"),&ConcavePolygonShape2D::set_segments);
- ObjectTypeDB::bind_method(_MD("get_segments"),&ConcavePolygonShape2D::get_segments);
+ ClassDB::bind_method(_MD("set_segments","segments"),&ConcavePolygonShape2D::set_segments);
+ ClassDB::bind_method(_MD("get_segments"),&ConcavePolygonShape2D::get_segments);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"segments"),_SCS("set_segments"),_SCS("get_segments") );
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"segments"),_SCS("set_segments"),_SCS("get_segments") );
}
diff --git a/scene/resources/concave_polygon_shape_2d.h b/scene/resources/concave_polygon_shape_2d.h
index 89b8914741..309fb4a7b3 100644
--- a/scene/resources/concave_polygon_shape_2d.h
+++ b/scene/resources/concave_polygon_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,14 +32,14 @@
#include "scene/resources/shape_2d.h"
class ConcavePolygonShape2D : public Shape2D {
- OBJ_TYPE( ConcavePolygonShape2D, Shape2D );
+ GDCLASS( ConcavePolygonShape2D, Shape2D );
protected:
static void _bind_methods();
public:
- void set_segments(const DVector<Vector2>& p_segments);
- DVector<Vector2> get_segments() const;
+ void set_segments(const PoolVector<Vector2>& p_segments);
+ PoolVector<Vector2> get_segments() const;
virtual void draw(const RID& p_to_rid,const Color& p_color);
virtual Rect2 get_rect() const ;
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index 7fcc9e97c0..ca9897bf97 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
Vector<Vector3> ConvexPolygonShape::_gen_debug_mesh_lines() {
- DVector<Vector3> points = get_points();
+ PoolVector<Vector3> points = get_points();
if (points.size()>3) {
@@ -64,14 +64,14 @@ void ConvexPolygonShape::_update_shape() {
emit_changed();
}
-void ConvexPolygonShape::set_points(const DVector<Vector3>& p_points) {
+void ConvexPolygonShape::set_points(const PoolVector<Vector3>& p_points) {
points=p_points;
_update_shape();
notify_change_to_owners();
}
-DVector<Vector3> ConvexPolygonShape::get_points() const {
+PoolVector<Vector3> ConvexPolygonShape::get_points() const {
return points;
}
@@ -79,8 +79,8 @@ DVector<Vector3> ConvexPolygonShape::get_points() const {
void ConvexPolygonShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape::set_points);
- ObjectTypeDB::bind_method(_MD("get_points"),&ConvexPolygonShape::get_points);
+ ClassDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape::set_points);
+ ClassDB::bind_method(_MD("get_points"),&ConvexPolygonShape::get_points);
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"points"), _SCS("set_points"), _SCS("get_points") );
diff --git a/scene/resources/convex_polygon_shape.h b/scene/resources/convex_polygon_shape.h
index a4e504ee24..215de941c6 100644
--- a/scene/resources/convex_polygon_shape.h
+++ b/scene/resources/convex_polygon_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,8 +33,8 @@
class ConvexPolygonShape : public Shape {
- OBJ_TYPE(ConvexPolygonShape,Shape);
- DVector<Vector3> points;
+ GDCLASS(ConvexPolygonShape,Shape);
+ PoolVector<Vector3> points;
protected:
@@ -45,8 +45,8 @@ protected:
virtual Vector<Vector3> _gen_debug_mesh_lines();
public:
- void set_points(const DVector<Vector3>& p_points);
- DVector<Vector3> get_points() const;
+ void set_points(const PoolVector<Vector3>& p_points);
+ PoolVector<Vector3> get_points() const;
ConvexPolygonShape();
};
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 5c0dadefc2..0d3ba238f6 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -61,13 +61,13 @@ Vector<Vector2> ConvexPolygonShape2D::get_points() const {
void ConvexPolygonShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_point_cloud","point_cloud"),&ConvexPolygonShape2D::set_point_cloud);
- ObjectTypeDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape2D::set_points);
- ObjectTypeDB::bind_method(_MD("get_points"),&ConvexPolygonShape2D::get_points);
+ ClassDB::bind_method(_MD("set_point_cloud","point_cloud"),&ConvexPolygonShape2D::set_point_cloud);
+ ClassDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape2D::set_points);
+ ClassDB::bind_method(_MD("get_points"),&ConvexPolygonShape2D::get_points);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"points"),_SCS("set_points"),_SCS("get_points") );
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"points"),_SCS("set_points"),_SCS("get_points") );
}
diff --git a/scene/resources/convex_polygon_shape_2d.h b/scene/resources/convex_polygon_shape_2d.h
index e1792a1075..8a4ad0e6d8 100644
--- a/scene/resources/convex_polygon_shape_2d.h
+++ b/scene/resources/convex_polygon_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/resources/shape_2d.h"
class ConvexPolygonShape2D : public Shape2D {
- OBJ_TYPE( ConvexPolygonShape2D, Shape2D );
+ GDCLASS( ConvexPolygonShape2D, Shape2D );
Vector<Vector2> points;
void _update_shape();
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index 29460790ff..e201cb16ac 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -143,17 +143,17 @@ Vector2 Curve2D::interpolatef(real_t p_findex) const {
}
-DVector<Point2> Curve2D::bake(int p_subdivs) const {
+PoolVector<Point2> Curve2D::bake(int p_subdivs) const {
int pc = points.size();
- DVector<Point2> ret;
+ PoolVector<Point2> ret;
if (pc<2)
return ret;
ret.resize((pc-1)*p_subdivs+1);
- DVector<Point2>::Write w = ret.write();
+ PoolVector<Point2>::Write w = ret.write();
const Point *r = points.ptr();
for(int i=0;i<pc;i++) {
@@ -175,7 +175,7 @@ DVector<Point2> Curve2D::bake(int p_subdivs) const {
}
}
- w = DVector<Point2>::Write();
+ w = PoolVector<Point2>::Write();
return ret;
}
@@ -349,26 +349,26 @@ Vector2Array Curve2D::get_points_pos() const {
void Curve2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
- ObjectTypeDB::bind_method(_MD("add_point","pos","in","out"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()));
- ObjectTypeDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
- ObjectTypeDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
- ObjectTypeDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
- ObjectTypeDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
- ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
- ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
- ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
- ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
- ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
+ ClassDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
+ ClassDB::bind_method(_MD("add_point","pos","in","out"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()));
+ ClassDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
+ ClassDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
+ ClassDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
+ ClassDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
+ ClassDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
+ ClassDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
+ ClassDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
+ ClassDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
+ ClassDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
- ObjectTypeDB::bind_method(_MD("set_points_in"),&Curve2D::set_points_in);
- ObjectTypeDB::bind_method(_MD("set_points_out"),&Curve2D::set_points_out);
- ObjectTypeDB::bind_method(_MD("set_points_pos"),&Curve2D::set_points_pos);
+ ClassDB::bind_method(_MD("set_points_in"),&Curve2D::set_points_in);
+ ClassDB::bind_method(_MD("set_points_out"),&Curve2D::set_points_out);
+ ClassDB::bind_method(_MD("set_points_pos"),&Curve2D::set_points_pos);
- ObjectTypeDB::bind_method(_MD("get_points_in"),&Curve2D::get_points_in);
- ObjectTypeDB::bind_method(_MD("get_points_out"),&Curve2D::get_points_out);
- ObjectTypeDB::bind_method(_MD("get_points_pos"),&Curve2D::get_points_pos);
+ ClassDB::bind_method(_MD("get_points_in"),&Curve2D::get_points_in);
+ ClassDB::bind_method(_MD("get_points_out"),&Curve2D::get_points_out);
+ ClassDB::bind_method(_MD("get_points_pos"),&Curve2D::get_points_pos);
ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_in"), _SCS("set_points_in"),_SCS("get_points_in"));
ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_out"), _SCS("set_points_out"),_SCS("get_points_out"));
@@ -464,6 +464,14 @@ void Curve2D::remove_point(int p_index) {
emit_signal(CoreStringNames::get_singleton()->changed);
}
+void Curve2D::clear_points() {
+ if (!points.empty()) {
+ points.clear();
+ baked_cache_dirty=true;
+ emit_signal(CoreStringNames::get_singleton()->changed);
+ }
+}
+
Vector2 Curve2D::interpolate(int p_index, float p_offset) const {
int pc = points.size();
@@ -602,7 +610,7 @@ void Curve2D::_bake() const {
pointlist.push_back(lastpos);
baked_point_cache.resize(pointlist.size());
- Vector2Array::Write w = baked_point_cache.write();
+ PoolVector2Array::Write w = baked_point_cache.write();
int idx=0;
@@ -637,7 +645,7 @@ Vector2 Curve2D::interpolate_baked(float p_offset,bool p_cubic) const{
return baked_point_cache.get(0);
int bpc=baked_point_cache.size();
- Vector2Array::Read r = baked_point_cache.read();
+ PoolVector2Array::Read r = baked_point_cache.read();
if (p_offset<0)
return r[0];
@@ -666,7 +674,7 @@ Vector2 Curve2D::interpolate_baked(float p_offset,bool p_cubic) const{
}
-Vector2Array Curve2D::get_baked_points() const {
+PoolVector2Array Curve2D::get_baked_points() const {
if (baked_cache_dirty)
_bake();
@@ -692,9 +700,9 @@ Dictionary Curve2D::_get_data() const {
Dictionary dc;
- Vector2Array d;
+ PoolVector2Array d;
d.resize(points.size()*3);
- Vector2Array::Write w = d.write();
+ PoolVector2Array::Write w = d.write();
for(int i=0;i<points.size();i++) {
@@ -705,7 +713,7 @@ Dictionary Curve2D::_get_data() const {
}
- w=Vector2Array::Write();
+ w=PoolVector2Array::Write();
dc["points"]=d;
@@ -716,11 +724,11 @@ void Curve2D::_set_data(const Dictionary& p_data){
ERR_FAIL_COND(!p_data.has("points"));
- Vector2Array rp=p_data["points"];
+ PoolVector2Array rp=p_data["points"];
int pc = rp.size();
ERR_FAIL_COND(pc%3!=0);
points.resize(pc/3);
- Vector2Array::Read r = rp.read();
+ PoolVector2Array::Read r = rp.read();
for(int i=0;i<points.size();i++) {
@@ -734,9 +742,9 @@ void Curve2D::_set_data(const Dictionary& p_data){
}
-Vector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
+PoolVector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
- Vector2Array tess;
+ PoolVector2Array tess;
if (points.size()==0) {
@@ -756,7 +764,7 @@ Vector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
}
tess.resize(pc);
- Vector2Array::Write bpw=tess.write();
+ PoolVector2Array::Write bpw=tess.write();
bpw[0]=points[0].pos;
int pidx=0;
@@ -773,7 +781,7 @@ Vector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
}
- bpw=Vector2Array::Write ();
+ bpw=PoolVector2Array::Write ();
return tess;
@@ -781,28 +789,29 @@ Vector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
void Curve2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
- ObjectTypeDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
- ObjectTypeDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
- ObjectTypeDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
- ObjectTypeDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
- ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
- ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
- ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
- ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
- ObjectTypeDB::bind_method(_MD("interpolatef","fofs"),&Curve2D::interpolatef);
- //ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
- ObjectTypeDB::bind_method(_MD("set_bake_interval","distance"),&Curve2D::set_bake_interval);
- ObjectTypeDB::bind_method(_MD("get_bake_interval"),&Curve2D::get_bake_interval);
-
- ObjectTypeDB::bind_method(_MD("get_baked_length"),&Curve2D::get_baked_length);
- ObjectTypeDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve2D::interpolate_baked,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_baked_points"),&Curve2D::get_baked_points);
- ObjectTypeDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve2D::tesselate,DEFVAL(5),DEFVAL(4));
-
- ObjectTypeDB::bind_method(_MD("_get_data"),&Curve2D::_get_data);
- ObjectTypeDB::bind_method(_MD("_set_data"),&Curve2D::_set_data);
+ ClassDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
+ ClassDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()),DEFVAL(-1));
+ ClassDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
+ ClassDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
+ ClassDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
+ ClassDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
+ ClassDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
+ ClassDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
+ ClassDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
+ ClassDB::bind_method(_MD("clear_points"),&Curve2D::clear_points);
+ ClassDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
+ ClassDB::bind_method(_MD("interpolatef","fofs"),&Curve2D::interpolatef);
+ //ClassDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
+ ClassDB::bind_method(_MD("set_bake_interval","distance"),&Curve2D::set_bake_interval);
+ ClassDB::bind_method(_MD("get_bake_interval"),&Curve2D::get_bake_interval);
+
+ ClassDB::bind_method(_MD("get_baked_length"),&Curve2D::get_baked_length);
+ ClassDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve2D::interpolate_baked,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_baked_points"),&Curve2D::get_baked_points);
+ ClassDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve2D::tesselate,DEFVAL(5),DEFVAL(4));
+
+ ClassDB::bind_method(_MD("_get_data"),&Curve2D::_get_data);
+ ClassDB::bind_method(_MD("_set_data"),&Curve2D::_set_data);
ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), _SCS("set_bake_interval"),_SCS("get_bake_interval"));
@@ -930,6 +939,15 @@ void Curve3D::remove_point(int p_index) {
emit_signal(CoreStringNames::get_singleton()->changed);
}
+void Curve3D::clear_points() {
+
+ if (!points.empty()) {
+ points.clear();
+ baked_cache_dirty=true;
+ emit_signal(CoreStringNames::get_singleton()->changed);
+ }
+}
+
Vector3 Curve3D::interpolate(int p_index, float p_offset) const {
int pc = points.size();
@@ -1072,11 +1090,11 @@ void Curve3D::_bake() const {
pointlist.push_back(Plane(lastpos,lastilt));
baked_point_cache.resize(pointlist.size());
- Vector3Array::Write w = baked_point_cache.write();
+ PoolVector3Array::Write w = baked_point_cache.write();
int idx=0;
baked_tilt_cache.resize(pointlist.size());
- RealArray::Write wt = baked_tilt_cache.write();
+ PoolRealArray::Write wt = baked_tilt_cache.write();
for(List<Plane>::Element *E=pointlist.front();E;E=E->next()) {
@@ -1110,7 +1128,7 @@ Vector3 Curve3D::interpolate_baked(float p_offset,bool p_cubic) const{
return baked_point_cache.get(0);
int bpc=baked_point_cache.size();
- Vector3Array::Read r = baked_point_cache.read();
+ PoolVector3Array::Read r = baked_point_cache.read();
if (p_offset<0)
return r[0];
@@ -1154,7 +1172,7 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const{
return baked_tilt_cache.get(0);
int bpc=baked_tilt_cache.size();
- RealArray::Read r = baked_tilt_cache.read();
+ PoolRealArray::Read r = baked_tilt_cache.read();
if (p_offset<0)
return r[0];
@@ -1178,7 +1196,7 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const{
}
-Vector3Array Curve3D::get_baked_points() const {
+PoolVector3Array Curve3D::get_baked_points() const {
if (baked_cache_dirty)
_bake();
@@ -1187,7 +1205,7 @@ Vector3Array Curve3D::get_baked_points() const {
}
-RealArray Curve3D::get_baked_tilts() const {
+PoolRealArray Curve3D::get_baked_tilts() const {
if (baked_cache_dirty)
_bake();
@@ -1213,12 +1231,12 @@ Dictionary Curve3D::_get_data() const {
Dictionary dc;
- Vector3Array d;
+ PoolVector3Array d;
d.resize(points.size()*3);
- Vector3Array::Write w = d.write();
- RealArray t;
+ PoolVector3Array::Write w = d.write();
+ PoolRealArray t;
t.resize(points.size());
- RealArray::Write wt = t.write();
+ PoolRealArray::Write wt = t.write();
for(int i=0;i<points.size();i++) {
@@ -1229,8 +1247,8 @@ Dictionary Curve3D::_get_data() const {
wt[i]=points[i].tilt;
}
- w=Vector3Array::Write();
- wt=RealArray::Write();
+ w=PoolVector3Array::Write();
+ wt=PoolRealArray::Write();
dc["points"]=d;
dc["tilts"]=t;
@@ -1243,13 +1261,13 @@ void Curve3D::_set_data(const Dictionary& p_data){
ERR_FAIL_COND(!p_data.has("points"));
ERR_FAIL_COND(!p_data.has("tilts"));
- Vector3Array rp=p_data["points"];
+ PoolVector3Array rp=p_data["points"];
int pc = rp.size();
ERR_FAIL_COND(pc%3!=0);
points.resize(pc/3);
- Vector3Array::Read r = rp.read();
- RealArray rtl=p_data["tilts"];
- RealArray::Read rt=rtl.read();
+ PoolVector3Array::Read r = rp.read();
+ PoolRealArray rtl=p_data["tilts"];
+ PoolRealArray::Read rt=rtl.read();
for(int i=0;i<points.size();i++) {
@@ -1264,9 +1282,9 @@ void Curve3D::_set_data(const Dictionary& p_data){
}
-Vector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
+PoolVector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
- Vector3Array tess;
+ PoolVector3Array tess;
if (points.size()==0) {
@@ -1286,7 +1304,7 @@ Vector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
}
tess.resize(pc);
- Vector3Array::Write bpw=tess.write();
+ PoolVector3Array::Write bpw=tess.write();
bpw[0]=points[0].pos;
int pidx=0;
@@ -1303,7 +1321,7 @@ Vector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
}
- bpw=Vector3Array::Write ();
+ bpw=PoolVector3Array::Write ();
return tess;
@@ -1311,31 +1329,32 @@ Vector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
void Curve3D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_point_count"),&Curve3D::get_point_count);
- ObjectTypeDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve3D::add_point,DEFVAL(Vector3()),DEFVAL(Vector3()),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve3D::set_point_pos);
- ObjectTypeDB::bind_method(_MD("get_point_pos","idx"),&Curve3D::get_point_pos);
- ObjectTypeDB::bind_method(_MD("set_point_tilt","idx","tilt"),&Curve3D::set_point_tilt);
- ObjectTypeDB::bind_method(_MD("get_point_tilt","idx"),&Curve3D::get_point_tilt);
- ObjectTypeDB::bind_method(_MD("set_point_in","idx","pos"),&Curve3D::set_point_in);
- ObjectTypeDB::bind_method(_MD("get_point_in","idx"),&Curve3D::get_point_in);
- ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve3D::set_point_out);
- ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve3D::get_point_out);
- ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve3D::remove_point);
- ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve3D::interpolate);
- ObjectTypeDB::bind_method(_MD("interpolatef","fofs"),&Curve3D::interpolatef);
- //ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve3D::bake,DEFVAL(10));
- ObjectTypeDB::bind_method(_MD("set_bake_interval","distance"),&Curve3D::set_bake_interval);
- ObjectTypeDB::bind_method(_MD("get_bake_interval"),&Curve3D::get_bake_interval);
-
- ObjectTypeDB::bind_method(_MD("get_baked_length"),&Curve3D::get_baked_length);
- ObjectTypeDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve3D::interpolate_baked,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_baked_points"),&Curve3D::get_baked_points);
- ObjectTypeDB::bind_method(_MD("get_baked_tilts"),&Curve3D::get_baked_tilts);
- ObjectTypeDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve3D::tesselate,DEFVAL(5),DEFVAL(4));
-
- ObjectTypeDB::bind_method(_MD("_get_data"),&Curve3D::_get_data);
- ObjectTypeDB::bind_method(_MD("_set_data"),&Curve3D::_set_data);
+ ClassDB::bind_method(_MD("get_point_count"),&Curve3D::get_point_count);
+ ClassDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve3D::add_point,DEFVAL(Vector3()),DEFVAL(Vector3()),DEFVAL(-1));
+ ClassDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve3D::set_point_pos);
+ ClassDB::bind_method(_MD("get_point_pos","idx"),&Curve3D::get_point_pos);
+ ClassDB::bind_method(_MD("set_point_tilt","idx","tilt"),&Curve3D::set_point_tilt);
+ ClassDB::bind_method(_MD("get_point_tilt","idx"),&Curve3D::get_point_tilt);
+ ClassDB::bind_method(_MD("set_point_in","idx","pos"),&Curve3D::set_point_in);
+ ClassDB::bind_method(_MD("get_point_in","idx"),&Curve3D::get_point_in);
+ ClassDB::bind_method(_MD("set_point_out","idx","pos"),&Curve3D::set_point_out);
+ ClassDB::bind_method(_MD("get_point_out","idx"),&Curve3D::get_point_out);
+ ClassDB::bind_method(_MD("remove_point","idx"),&Curve3D::remove_point);
+ ClassDB::bind_method(_MD("clear_points"),&Curve3D::clear_points);
+ ClassDB::bind_method(_MD("interpolate","idx","t"),&Curve3D::interpolate);
+ ClassDB::bind_method(_MD("interpolatef","fofs"),&Curve3D::interpolatef);
+ //ClassDB::bind_method(_MD("bake","subdivs"),&Curve3D::bake,DEFVAL(10));
+ ClassDB::bind_method(_MD("set_bake_interval","distance"),&Curve3D::set_bake_interval);
+ ClassDB::bind_method(_MD("get_bake_interval"),&Curve3D::get_bake_interval);
+
+ ClassDB::bind_method(_MD("get_baked_length"),&Curve3D::get_baked_length);
+ ClassDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve3D::interpolate_baked,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_baked_points"),&Curve3D::get_baked_points);
+ ClassDB::bind_method(_MD("get_baked_tilts"),&Curve3D::get_baked_tilts);
+ ClassDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve3D::tesselate,DEFVAL(5),DEFVAL(4));
+
+ ClassDB::bind_method(_MD("_get_data"),&Curve3D::_get_data);
+ ClassDB::bind_method(_MD("_set_data"),&Curve3D::_set_data);
ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), _SCS("set_bake_interval"),_SCS("get_bake_interval"));
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 262f22b7d1..3362109354 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
#if 0
class Curve2D : public Resource {
- OBJ_TYPE(Curve2D,Resource);
+ GDCLASS(Curve2D,Resource);
struct Point {
@@ -72,7 +72,7 @@ public:
Vector2 interpolate(int p_index, float p_offset) const;
Vector2 interpolatef(real_t p_findex) const;
- DVector<Point2> bake(int p_subdivs=10) 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;
@@ -84,7 +84,7 @@ public:
class Curve2D : public Resource {
- OBJ_TYPE(Curve2D,Resource);
+ GDCLASS(Curve2D,Resource);
struct Point {
@@ -103,7 +103,7 @@ class Curve2D : public Resource {
};
mutable bool baked_cache_dirty;
- mutable Vector2Array baked_point_cache;
+ mutable PoolVector2Array baked_point_cache;
mutable float baked_max_ofs;
@@ -133,6 +133,7 @@ public:
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);
+ void clear_points();
Vector2 interpolate(int p_index, float p_offset) const;
Vector2 interpolatef(real_t p_findex) const;
@@ -144,9 +145,9 @@ public:
float get_baked_length() const;
Vector2 interpolate_baked(float p_offset,bool p_cubic=false) const;
- Vector2Array get_baked_points() const; //useful for going thru
+ PoolVector2Array get_baked_points() const; //useful for going thru
- Vector2Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
+ PoolVector2Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
Curve2D();
@@ -156,7 +157,7 @@ public:
class Curve3D : public Resource {
- OBJ_TYPE(Curve3D,Resource);
+ GDCLASS(Curve3D,Resource);
struct Point {
@@ -178,8 +179,8 @@ class Curve3D : public Resource {
};
mutable bool baked_cache_dirty;
- mutable Vector3Array baked_point_cache;
- mutable RealArray baked_tilt_cache;
+ mutable PoolVector3Array baked_point_cache;
+ mutable PoolRealArray baked_tilt_cache;
mutable float baked_max_ofs;
@@ -211,6 +212,7 @@ public:
void set_point_out(int p_index, const Vector3& p_out);
Vector3 get_point_out(int p_index) const;
void remove_point(int p_index);
+ void clear_points();
Vector3 interpolate(int p_index, float p_offset) const;
Vector3 interpolatef(real_t p_findex) const;
@@ -223,10 +225,10 @@ public:
float get_baked_length() const;
Vector3 interpolate_baked(float p_offset,bool p_cubic=false) const;
float interpolate_baked_tilt(float p_offset) const;
- Vector3Array get_baked_points() const; //useful for going thru
- RealArray get_baked_tilts() const; //useful for going thru
+ PoolVector3Array get_baked_points() const; //useful for going thru
+ PoolRealArray get_baked_tilts() const; //useful for going thru
- Vector3Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
+ PoolVector3Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
Curve3D();
diff --git a/scene/resources/default_theme/SCsub b/scene/resources/default_theme/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/resources/default_theme/SCsub
+++ b/scene/resources/default_theme/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/resources/default_theme/button_pressed.png b/scene/resources/default_theme/button_pressed.png
index 4a807544ed..19a7e237aa 100644
--- a/scene/resources/default_theme/button_pressed.png
+++ b/scene/resources/default_theme/button_pressed.png
Binary files differ
diff --git a/scene/resources/default_theme/color_picker_hue.png b/scene/resources/default_theme/color_picker_hue.png
new file mode 100644
index 0000000000..de2cd0c2bf
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_hue.png
Binary files differ
diff --git a/scene/resources/default_theme/color_picker_sample.png b/scene/resources/default_theme/color_picker_sample.png
new file mode 100644
index 0000000000..b145a3e384
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_sample.png
Binary files differ
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index dea612735c..50c6a6c725 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -58,14 +58,14 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
if (scale>1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.expand_x2_hq2x();
if (scale!=2.0) {
img.resize(orig_size.x*scale,orig_size.y*scale);
}
} else if (scale<1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.resize(orig_size.x*scale,orig_size.y*scale);
}
@@ -108,14 +108,14 @@ static Ref<Texture> make_icon(T p_src) {
if (scale>1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.expand_x2_hq2x();
if (scale!=2.0) {
img.resize(orig_size.x*scale,orig_size.y*scale);
}
} else if (scale<1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.resize(orig_size.x*scale,orig_size.y*scale);
}
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
@@ -125,7 +125,7 @@ static Ref<Texture> make_icon(T p_src) {
static Ref<Shader> make_shader(const char*vertex_code,const char*fragment_code,const char*lighting_code) {
Ref<Shader> shader = (memnew( Shader(Shader::MODE_CANVAS_ITEM) ));
- shader->set_code(vertex_code, fragment_code, lighting_code);
+ //shader->set_code(vertex_code, fragment_code, lighting_code);
return shader;
}
@@ -214,6 +214,8 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_
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) {
scale=p_scale;
@@ -490,6 +492,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
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"));
@@ -714,6 +717,8 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
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);
// ItemList
@@ -830,9 +835,8 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
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_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, ""));
- t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, ""));
+ t->set_icon("color_hue", "ColorPicker", make_icon( color_picker_hue_png));
+ t->set_icon("color_sample", "ColorPicker", make_icon( color_picker_sample_png));
// TooltipPanel
@@ -896,10 +900,9 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
// HButtonArray
-
- t->set_stylebox("normal","HButtonArray", make_stylebox( button_normal_png,4,4,4,4,0,4,22,4) );
- t->set_stylebox("selected","HButtonArray", make_stylebox( button_pressed_png,4,4,4,4,0,4,22,4) );
- t->set_stylebox("hover","HButtonArray", make_stylebox( button_hover_png,4,4,4,4) );
+ t->set_stylebox("normal","HButtonArray", sb_button_normal);
+ t->set_stylebox("selected","HButtonArray", sb_button_pressed);
+ t->set_stylebox("hover","HButtonArray", sb_button_hover);
t->set_font("font","HButtonArray", default_font);
t->set_font("font_selected","HButtonArray", default_font);
@@ -907,17 +910,17 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_color("font_color","HButtonArray", control_font_color_low );
t->set_color("font_color_selected","HButtonArray", control_font_color_hover );
- t->set_constant("icon_separator","HButtonArray", 4 *scale );
- t->set_constant("button_separator","HButtonArray", 8 *scale );
+ t->set_constant("icon_separator","HButtonArray", 2 *scale );
+ t->set_constant("button_separator","HButtonArray", 4 *scale );
t->set_stylebox("focus","HButtonArray", focus );
// VButtonArray
- t->set_stylebox("normal","VButtonArray", make_stylebox( button_normal_png,4,4,4,4,0,4,22,4) );
- t->set_stylebox("selected","VButtonArray", make_stylebox( button_pressed_png,4,4,4,4,0,4,22,4) );
- t->set_stylebox("hover","VButtonArray", make_stylebox( button_hover_png,4,4,4,4) );
+ t->set_stylebox("normal","VButtonArray", sb_button_normal);
+ t->set_stylebox("selected","VButtonArray", sb_button_pressed);
+ t->set_stylebox("hover","VButtonArray", sb_button_hover);
t->set_font("font","VButtonArray", default_font);
t->set_font("font_selected","VButtonArray", default_font);
@@ -925,18 +928,18 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_color("font_color","VButtonArray", control_font_color_low );
t->set_color("font_color_selected","VButtonArray", control_font_color_hover );
- t->set_constant("icon_separator","VButtonArray", 4 *scale);
- t->set_constant("button_separator","VButtonArray", 8 *scale);
+ t->set_constant("icon_separator","VButtonArray", 2 *scale);
+ t->set_constant("button_separator","VButtonArray", 4 *scale);
t->set_stylebox("focus","VButtonArray", focus );
- // ReferenceFrame
+ // ReferenceRect
Ref<StyleBoxTexture> ttnc = make_stylebox( full_panel_bg_png,8,8,8,8);
ttnc->set_draw_center(false);
- t->set_stylebox("border","ReferenceFrame", make_stylebox( reference_border_png,4,4,4,4) );
+ t->set_stylebox("border","ReferenceRect", make_stylebox( reference_border_png,4,4,4,4) );
t->set_stylebox("panelnc","Panel", ttnc );
t->set_stylebox("panelf","Panel", tc_sb );
@@ -960,7 +963,6 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_icon( "logo","Icons", make_icon(logo_png) );
-
// Theme
default_icon= make_icon(error_icon_png) ;
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index 3312b2d812..01141ed0a0 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py
index 2d3f989e01..68c9e92527 100644..100755
--- a/scene/resources/default_theme/make_header.py
+++ b/scene/resources/default_theme/make_header.py
@@ -1,72 +1,71 @@
-import os;
-import glob;
-import string;
+import os
+import glob
+import string
-#Generate include files
+# Generate include files
-f=open("theme_data.h","wb")
+f = open("theme_data.h", "wb")
-f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n");
+f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n")
-f.write("\n\n");
+f.write("\n\n")
-#Generate png image block
+# Generate png image block
-pixmaps = glob.glob("*.png");
+pixmaps = glob.glob("*.png")
-pixmaps.sort();
+pixmaps.sort()
-f.write("\n\n\n");
+f.write("\n\n\n")
for x in pixmaps:
- var_str=x[:-4]+"_png";
+ var_str = x[:-4] + "_png"
- f.write("static const unsigned char "+ var_str +"[]={\n");
+ f.write("static const unsigned char " + var_str + "[]={\n")
- pngf=open(x,"rb");
+ pngf = open(x, "rb")
- b=pngf.read(1);
- while(len(b)==1):
- f.write(hex(ord(b)))
- b=pngf.read(1);
- if (len(b)==1):
- f.write(",")
+ b = pngf.read(1)
+ while(len(b) == 1):
+ f.write(hex(ord(b)))
+ b = pngf.read(1)
+ if (len(b) == 1):
+ f.write(",")
- f.write("\n};\n\n\n");
- pngf.close();
+ f.write("\n};\n\n\n")
+ pngf.close()
-#Generate shaders block
+# Generate shaders block
shaders = glob.glob("*.gsl")
-shaders.sort();
+shaders.sort()
-f.write("\n\n\n");
+f.write("\n\n\n")
for x in shaders:
- var_str=x[:-4]+"_shader_code";
+ var_str = x[:-4] + "_shader_code"
- f.write("static const char *"+ var_str +"=\n");
+ f.write("static const char *" + var_str + "=\n")
- sf=open(x,"rb");
+ sf = open(x, "rb")
+ b = sf.readline()
+ while(b != ""):
+ if (b.endswith("\r\n")):
+ b = b[:-2]
+ if (b.endswith("\n")):
+ b = b[:-1]
+ f.write(" \"" + b)
+ b = sf.readline()
+ if (b != ""):
+ f.write("\"\n")
- b=sf.readline();
- while(b!=""):
- if (b.endswith("\r\n")):
- b=b[:-2]
- if (b.endswith("\n")):
- b=b[:-1]
- f.write(" \""+b)
- b=sf.readline();
- if (b!=""):
- f.write("\"\n")
+ f.write("\";\n\n\n")
+ sf.close()
- f.write("\";\n\n\n");
- sf.close();
-
-f.close();
+f.close()
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 73c801483f..46fd770a27 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -69,6 +69,16 @@ static const unsigned char close_hl_png[]={
};
+static const unsigned char color_picker_hue_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0xfd,0x5c,0x8b,0xcf,0x0,0x0,0x0,0x59,0x49,0x44,0x41,0x54,0x28,0x91,0xcd,0xd0,0x31,0xa,0x3,0x31,0x10,0x43,0xd1,0x87,0xc0,0xf6,0xfd,0x8f,0x1b,0xdb,0x30,0x69,0x76,0x21,0x65,0xd8,0x14,0x71,0xf1,0xf9,0x8c,0x84,0x9a,0x51,0x44,0x13,0xfd,0x21,0xe3,0x87,0xed,0xf7,0xa8,0xcd,0x2a,0x99,0x8e,0x46,0x2b,0x94,0xd0,0x43,0xb,0xe3,0x64,0xb3,0x2a,0xa6,0x93,0xb9,0x9f,0x9a,0x4e,0x3a,0x69,0x97,0xc7,0xe5,0x3b,0x1b,0xff,0xef,0x6d,0xa5,0xec,0x30,0xc3,0xeb,0xf2,0xc,0xeb,0xe3,0x5e,0x27,0xf4,0x8a,0x37,0x75,0x7b,0x8a,0xe5,0x90,0x9a,0xab,0x81,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
+static const unsigned char color_picker_sample_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x14,0x8,0x2,0x0,0x0,0x0,0xed,0x20,0x74,0x8,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,0x9,0x18,0xc,0x27,0x37,0x29,0x4f,0x42,0x2d,0x0,0x0,0x0,0x61,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0xd9,0xb1,0xd,0x0,0x21,0xc,0x3,0x40,0x40,0xbf,0x5f,0x66,0xcd,0x84,0xf9,0x96,0x19,0xf0,0x5d,0x87,0x5c,0x5b,0x9,0xca,0x9e,0x99,0x75,0xe9,0xee,0xfb,0x59,0x55,0x52,0xe9,0xc3,0xe9,0x59,0x10,0x4c,0x1,0x50,0x0,0x50,0x0,0x8,0xf4,0xf9,0x15,0x49,0x93,0x53,0x13,0x0,0x2b,0x10,0x28,0x0,0x28,0x0,0x64,0xd9,0x2e,0xc1,0xd2,0xe4,0xd4,0x4,0xc0,0xa,0x4,0xa,0x0,0xa,0x0,0x59,0x5c,0x82,0xa5,0xd1,0xa9,0x9,0x80,0x15,0x8,0x14,0x0,0x14,0x0,0xb2,0xfc,0x5b,0xb2,0x3c,0x5a,0x4,0xa1,0xf3,0x57,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
static const unsigned char dosfont_png[]={
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x80,0x0,0x0,0x0,0x80,0x1,0x0,0x0,0x0,0x0,0xeb,0x45,0x5c,0x66,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0x1,0xdd,0x8a,0x13,0xa4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x89,0x0,0x0,0xb,0x89,0x1,0x37,0xc9,0xcb,0xad,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x2,0x83,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0xd4,0xb1,0x6e,0xdb,0x30,0x10,0x0,0x50,0x22,0x3,0x27,0x22,0xc8,0x78,0x83,0x91,0xa9,0x1f,0xc0,0xa9,0x10,0xa,0x7e,0xc,0x11,0x14,0x87,0xc,0x1c,0x32,0x9,0x1a,0xe,0x46,0xa6,0xfc,0x43,0xff,0x86,0xb5,0x80,0x9b,0x88,0x8e,0x5d,0x64,0x18,0x9e,0xdc,0xd5,0x53,0x91,0xc1,0xa0,0x7a,0xa4,0xe4,0xd4,0x31,0xd2,0x25,0x70,0x97,0xa2,0x37,0x48,0xe6,0x33,0x45,0xdd,0x51,0x24,0x95,0x7a,0x23,0xe0,0x75,0x13,0xb,0xd8,0x93,0xbf,0x51,0x51,0xa3,0xac,0x99,0xc9,0x29,0x87,0x81,0x83,0xb2,0x0,0xc7,0xfe,0xee,0x43,0x58,0x85,0x95,0xb7,0xa6,0xb6,0xaf,0x7a,0xe9,0x93,0x63,0xc3,0xf2,0xc,0x96,0x3e,0xba,0x97,0x11,0x3,0xb5,0x46,0xc0,0x15,0x30,0x43,0x1,0xbd,0x6,0x81,0x71,0xa9,0xb2,0x82,0x9,0x92,0x3d,0xf6,0xb0,0xbd,0x5c,0xf2,0x53,0xf2,0x75,0xc,0x11,0x5f,0xc7,0xe0,0xc4,0xaa,0xb4,0x40,0x41,0xc4,0x69,0xd0,0x27,0x55,0x12,0x13,0x78,0x74,0xa7,0xb5,0xd8,0x3f,0x14,0x77,0x81,0x0,0x22,0x93,0x9b,0x4c,0x54,0x5b,0x72,0x6d,0x98,0x17,0xd1,0x33,0xb3,0x94,0xaa,0x3c,0x93,0xea,0xb4,0x76,0x31,0x6a,0x66,0x0,0xa9,0x59,0x1c,0x8c,0xe,0x33,0xc0,0x12,0x4c,0x29,0xc2,0xa5,0xc3,0xc1,0xd0,0xb2,0x64,0x6a,0x60,0xa3,0xc0,0xea,0xac,0x19,0x58,0x4b,0xa9,0x4a,0x17,0xf0,0xda,0x68,0xb6,0x5,0xec,0xb2,0xf6,0x88,0x33,0xc8,0x18,0x52,0xd5,0x5a,0x1,0xb3,0x61,0x1,0x53,0xdf,0x2,0x51,0x2d,0x33,0xdd,0x12,0x59,0xea,0x94,0x95,0x3c,0x80,0x2e,0x5e,0xf9,0xdb,0x71,0x73,0x70,0xcf,0x39,0x3b,0x76,0xb7,0xbb,0x7d,0xcf,0x74,0x50,0xd,0x62,0x40,0x44,0x6,0x83,0xfe,0xc7,0x8e,0x51,0x5,0x5c,0xe1,0xdd,0xdd,0xaa,0xc2,0xf8,0x53,0x80,0x31,0xe2,0xfd,0x7d,0x14,0x8,0x7e,0xcc,0x5,0x28,0x62,0xd7,0xc5,0xc,0xa6,0xf3,0xc3,0x46,0xa6,0x30,0xd7,0x1e,0x1b,0x2e,0xd0,0x7f,0x63,0x5f,0x1f,0xf1,0x32,0xc9,0x90,0x82,0xef,0xb9,0x82,0xc,0x5a,0x1,0xef,0x66,0x90,0xd7,0x7a,0x2c,0x80,0x13,0x94,0xc4,0xf6,0x9f,0xd8,0x75,0xbb,0x2c,0x89,0xed,0xff,0x42,0xe9,0xa7,0xfb,0xa4,0x84,0xec,0x13,0x45,0x7,0x1a,0xb9,0x97,0x18,0x65,0xab,0x4,0xf9,0x54,0x8c,0x3c,0x54,0xe8,0xed,0xa3,0x7c,0x7b,0x55,0xe0,0x8b,0x0,0xf6,0x4f,0x36,0xd6,0x3d,0xc3,0xe8,0x41,0xc0,0xa1,0xb1,0xdb,0x9,0xa8,0x29,0x0,0xe,0xec,0xc3,0x4,0xc1,0x8,0xc,0x0,0xd6,0x36,0xf3,0x23,0xba,0x80,0x3,0x6f,0x17,0x15,0xbe,0x4b,0xe5,0x8c,0x23,0xc2,0x57,0x7b,0x5d,0x61,0x53,0xc0,0x61,0xf,0xbd,0xd5,0x15,0x68,0x47,0x8e,0x0,0x7b,0x37,0xba,0xab,0xba,0x59,0xcc,0x79,0x3d,0xd7,0xaf,0x5a,0xe3,0x85,0x66,0x69,0xab,0x16,0x32,0x31,0x5b,0xd0,0xdb,0x66,0x2,0x2f,0x6f,0xe,0xb2,0x42,0xb5,0x87,0xdf,0xf0,0x59,0xae,0x6a,0x86,0xae,0x93,0x4c,0x7d,0x1b,0x9a,0x6b,0x84,0xdd,0x9a,0xd6,0xca,0xc8,0x89,0xc3,0xfb,0xd4,0x82,0xe,0x30,0xa2,0x2c,0x18,0xc2,0x98,0xb2,0x4f,0x8,0xba,0x83,0xa1,0x40,0x12,0x88,0x6f,0x43,0x38,0x82,0x1c,0x1f,0x15,0x70,0x82,0x96,0xa8,0xa5,0x3d,0xed,0x9c,0xde,0xb9,0x1,0xe9,0xb8,0x5f,0x4c,0x39,0xd2,0xa6,0xac,0xa6,0x48,0xe7,0xd0,0x95,0x53,0xb0,0xc4,0x7b,0x97,0xd4,0xcd,0x3c,0xdd,0xf0,0xd0,0x4e,0xbf,0xe6,0x65,0x24,0x5b,0x7b,0x7d,0xe,0xe5,0xd6,0xae,0xe9,0x90,0x64,0xfd,0x70,0x9e,0x21,0xb5,0x6c,0x5,0xa4,0xa2,0x87,0xe9,0xa3,0x25,0xf4,0x5,0x5c,0x39,0x61,0xa6,0x1e,0xbe,0x11,0x18,0x80,0xed,0xb,0x18,0x9b,0x70,0x70,0xec,0x5f,0x80,0x3f,0x26,0x27,0xb3,0xc9,0x33,0xc8,0x5c,0x2c,0x5a,0x59,0x1f,0xcb,0x2c,0x89,0x9d,0xae,0xf,0x7d,0xcc,0xdb,0x9c,0xdd,0xd5,0xed,0x7c,0x7f,0xbe,0xd0,0x52,0xf9,0x1f,0xff,0x76,0xfc,0x2,0x24,0x3a,0x65,0x42,0xf6,0x41,0x91,0x95,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
};
@@ -562,39 +572,3 @@ static const unsigned char window_resizer_png[]={
-static const char *uv_editor_shader_code=
- "vec3 nd1sl2=vec3(UV,0);"
- "uniform float H=0;"
- "float nd4sl0=H;"
- "float nd7sl0=nd1sl2.x;"
- "float nd7sl1=nd1sl2.y;"
- "float nd7sl2=nd1sl2.z;"
- "float nd2sl1def=-1;"
- "float nd2sl0=nd7sl1*nd2sl1def;"
- "float nd6sl1def=1;"
- "float nd6sl0=nd2sl0+nd6sl1def;"
- "vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);"
- "vec3 nd5sl0;"
- "{"
- " vec3 c = nd3sl0;"
- " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
- " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
- " nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
- "}"
- "COLOR.rgb=nd5sl0;";
-
-
-static const char *w_editor_shader_code=
- "vec3 nd1sl2=vec3(UV,0);"
- "float nd2sl1=1-nd1sl2.y;"
- "vec3 nd3sl0=vec3(nd2sl1,1,1);"
- "vec3 nd6sl0;"
- "{"
- " vec3 c = nd3sl0;"
- " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
- " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
- " nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
- "}"
- "COLOR.rgb=nd6sl0;";
-
-
diff --git a/scene/resources/default_theme/uv_editor.gsl b/scene/resources/default_theme/uv_editor.gsl
deleted file mode 100644
index 8c24e76dd5..0000000000
--- a/scene/resources/default_theme/uv_editor.gsl
+++ /dev/null
@@ -1,19 +0,0 @@
-vec3 nd1sl2=vec3(UV,0);
-uniform float H=0;
-float nd4sl0=H;
-float nd7sl0=nd1sl2.x;
-float nd7sl1=nd1sl2.y;
-float nd7sl2=nd1sl2.z;
-float nd2sl1def=-1;
-float nd2sl0=nd7sl1*nd2sl1def;
-float nd6sl1def=1;
-float nd6sl0=nd2sl0+nd6sl1def;
-vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);
-vec3 nd5sl0;
-{
- vec3 c = nd3sl0;
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
- nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
-}
-COLOR.rgb=nd5sl0; \ No newline at end of file
diff --git a/scene/resources/default_theme/w_editor.gsl b/scene/resources/default_theme/w_editor.gsl
deleted file mode 100644
index 6d2dd9a0bb..0000000000
--- a/scene/resources/default_theme/w_editor.gsl
+++ /dev/null
@@ -1,11 +0,0 @@
-vec3 nd1sl2=vec3(UV,0);
-float nd2sl1=1-nd1sl2.y;
-vec3 nd3sl0=vec3(nd2sl1,1,1);
-vec3 nd6sl0;
-{
- vec3 c = nd3sl0;
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
- nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
-}
-COLOR.rgb=nd6sl0; \ No newline at end of file
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 679c8a000c..63a7829d26 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -84,8 +84,8 @@ void DynamicFontData::set_force_autohinter(bool p_force) {
}
void DynamicFontData::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_font_path","path"),&DynamicFontData::set_font_path);
- ObjectTypeDB::bind_method(_MD("get_font_path"),&DynamicFontData::get_font_path);
+ ClassDB::bind_method(_MD("set_font_path","path"),&DynamicFontData::set_font_path);
+ ClassDB::bind_method(_MD("get_font_path"),&DynamicFontData::get_font_path);
ADD_PROPERTY(PropertyInfo(Variant::STRING,"font_path",PROPERTY_HINT_FILE,"*.ttf,*.otf"),_SCS("set_font_path"),_SCS("get_font_path"));
}
@@ -511,7 +511,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
break;
}
-// print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
+ //print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
if (tex_index==-1) {
//could not find texture to fit, create one
@@ -535,7 +535,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
{
//zero texture
- DVector<uint8_t>::Write w = tex.imgdata.write();
+ PoolVector<uint8_t>::Write w = tex.imgdata.write();
ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size());
for(int i=0;i<texsize*texsize*2;i++) {
w[i]=0;
@@ -556,7 +556,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
CharTexture &tex=textures[tex_index];
{
- DVector<uint8_t>::Write wr = tex.imgdata.write();
+ PoolVector<uint8_t>::Write wr = tex.imgdata.write();
for(int i=0;i<h;i++) {
@@ -573,7 +573,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_LA8,tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
@@ -879,34 +879,37 @@ void DynamicFont::_get_property_list( List<PropertyInfo> *p_list) const{
void DynamicFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
- ObjectTypeDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
-
- ObjectTypeDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
- ObjectTypeDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
-
- ObjectTypeDB::bind_method(_MD("set_use_mipmaps","enable"),&DynamicFont::set_use_mipmaps);
- ObjectTypeDB::bind_method(_MD("get_use_mipmaps"),&DynamicFont::get_use_mipmaps);
- ObjectTypeDB::bind_method(_MD("set_use_filter","enable"),&DynamicFont::set_use_filter);
- ObjectTypeDB::bind_method(_MD("get_use_filter"),&DynamicFont::get_use_filter);
- ObjectTypeDB::bind_method(_MD("set_spacing","type","value"),&DynamicFont::set_spacing);
- ObjectTypeDB::bind_method(_MD("get_spacing","type"),&DynamicFont::get_spacing);
-
- ObjectTypeDB::bind_method(_MD("add_fallback","data:DynamicFontData"),&DynamicFont::add_fallback);
- ObjectTypeDB::bind_method(_MD("set_fallback","idx","data:DynamicFontData"),&DynamicFont::set_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback:DynamicFontData","idx"),&DynamicFont::get_fallback);
- ObjectTypeDB::bind_method(_MD("remove_fallback","idx"),&DynamicFont::remove_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback_count"),&DynamicFont::get_fallback_count);
-
-
- ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),_SCS("set_size"),_SCS("get_size"));
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/top"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_TOP);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/bottom"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_BOTTOM);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/char"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_CHAR);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/space"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_SPACE);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"font/use_mipmaps"),_SCS("set_use_mipmaps"),_SCS("get_use_mipmaps"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"font/use_filter"),_SCS("set_use_filter"),_SCS("get_use_filter"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
+ ClassDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
+ ClassDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
+
+ ClassDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
+ ClassDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
+
+ ClassDB::bind_method(_MD("set_use_mipmaps","enable"),&DynamicFont::set_use_mipmaps);
+ ClassDB::bind_method(_MD("get_use_mipmaps"),&DynamicFont::get_use_mipmaps);
+ ClassDB::bind_method(_MD("set_use_filter","enable"),&DynamicFont::set_use_filter);
+ ClassDB::bind_method(_MD("get_use_filter"),&DynamicFont::get_use_filter);
+ ClassDB::bind_method(_MD("set_spacing","type","value"),&DynamicFont::set_spacing);
+ ClassDB::bind_method(_MD("get_spacing","type"),&DynamicFont::get_spacing);
+
+ ClassDB::bind_method(_MD("add_fallback","data:DynamicFontData"),&DynamicFont::add_fallback);
+ ClassDB::bind_method(_MD("set_fallback","idx","data:DynamicFontData"),&DynamicFont::set_fallback);
+ ClassDB::bind_method(_MD("get_fallback:DynamicFontData","idx"),&DynamicFont::get_fallback);
+ ClassDB::bind_method(_MD("remove_fallback","idx"),&DynamicFont::remove_fallback);
+ ClassDB::bind_method(_MD("get_fallback_count"),&DynamicFont::get_fallback_count);
+
+
+ ADD_GROUP("Settings","");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"size"),_SCS("set_size"),_SCS("get_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_mipmaps"),_SCS("set_use_mipmaps"),_SCS("get_use_mipmaps"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_filter"),_SCS("set_use_filter"),_SCS("get_use_filter"));
+ ADD_GROUP("Extra Spacing","extra_spacing");
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_top"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_bottom"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_BOTTOM);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_char"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_CHAR);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_space"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_SPACE);
+ ADD_GROUP("Font","");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font_data",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
BIND_CONSTANT( SPACING_TOP );
BIND_CONSTANT( SPACING_BOTTOM );
@@ -958,7 +961,7 @@ bool ResourceFormatLoaderDynamicFont::handles_type(const String& p_type) const {
String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const {
- String el = p_path.extension().to_lower();
+ String el = p_path.get_extension().to_lower();
if (el=="ttf" || el=="otf")
return "DynamicFontData";
return "";
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index 4ae58ab0dd..321ec7e332 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,7 +43,7 @@ class DynamicFont;
class DynamicFontData : public Resource {
- OBJ_TYPE(DynamicFontData,Resource);
+ GDCLASS(DynamicFontData,Resource);
public:
@@ -88,7 +88,7 @@ public:
class DynamicFontAtSize : public Reference {
- OBJ_TYPE(DynamicFontAtSize,Reference)
+ GDCLASS(DynamicFontAtSize,Reference)
_THREAD_SAFE_CLASS_
@@ -107,7 +107,7 @@ class DynamicFontAtSize : public Reference {
struct CharTexture {
- DVector<uint8_t> imgdata;
+ PoolVector<uint8_t> imgdata;
int texture_size;
Vector<int> offsets;
Ref<ImageTexture> texture;
@@ -168,7 +168,7 @@ public:
class DynamicFont : public Font {
- OBJ_TYPE( DynamicFont, Font );
+ GDCLASS( DynamicFont, Font );
public:
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 456e6a5ee7..cbbca49f0f 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -26,10 +26,10 @@ void DynamicFontData::lock() {
void DynamicFontData::unlock() {
- fr = DVector<uint8_t>::Read();
+ fr = PoolVector<uint8_t>::Read();
}
-void DynamicFontData::set_font_data(const DVector<uint8_t>& p_font) {
+void DynamicFontData::set_font_data(const PoolVector<uint8_t>& p_font) {
//clear caches and stuff
ERR_FAIL_COND(font_data.size()) ;
font_data=p_font;
@@ -260,7 +260,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
break;
}
-// print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
+ //print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
if (tex_index==-1) {
//could not find texture to fit, create one
@@ -284,7 +284,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
{
//zero texture
- DVector<uint8_t>::Write w = tex.imgdata.write();
+ PoolVector<uint8_t>::Write w = tex.imgdata.write();
ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size());
for(int i=0;i<texsize*texsize*2;i++) {
w[i]=0;
@@ -305,7 +305,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
CharTexture &tex=textures[tex_index];
{
- DVector<uint8_t>::Write wr = tex.imgdata.write();
+ PoolVector<uint8_t>::Write wr = tex.imgdata.write();
for(int i=0;i<h;i++) {
for(int j=0;j<w;j++) {
@@ -321,7 +321,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_LA8,tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
@@ -378,11 +378,11 @@ DynamicFontAtSize::~DynamicFontAtSize(){
void DynamicFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
- ObjectTypeDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
+ ClassDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
+ ClassDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
- ObjectTypeDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
- ObjectTypeDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
+ ClassDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
+ ClassDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),_SCS("set_size"),_SCS("get_size"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
@@ -485,14 +485,14 @@ RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_
FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
ERR_FAIL_COND_V(!f,RES());
- DVector<uint8_t> data;
+ PoolVector<uint8_t> data;
data.resize(f->get_len());
ERR_FAIL_COND_V(data.size()==0,RES());
{
- DVector<uint8_t>::Write w = data.write();
+ PoolVector<uint8_t>::Write w = data.write();
f->get_buffer(w.ptr(),data.size());
}
diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h
index 136edff2fc..07a3e5ee6c 100644
--- a/scene/resources/dynamic_font_stb.h
+++ b/scene/resources/dynamic_font_stb.h
@@ -14,12 +14,12 @@ class DynamicFont;
class DynamicFontData : public Resource {
- OBJ_TYPE(DynamicFontData,Resource);
+ GDCLASS(DynamicFontData,Resource);
bool valid;
- DVector<uint8_t> font_data;
- DVector<uint8_t>::Read fr;
+ PoolVector<uint8_t> font_data;
+ PoolVector<uint8_t>::Read fr;
const uint8_t* last_data_ptr;
struct KerningPairKey {
@@ -56,7 +56,7 @@ friend class DynamicFont;
Ref<DynamicFontAtSize> _get_dynamic_font_at_size(int p_size);
public:
- void set_font_data(const DVector<uint8_t>& p_font);
+ void set_font_data(const PoolVector<uint8_t>& p_font);
DynamicFontData();
~DynamicFontData();
};
@@ -64,14 +64,14 @@ public:
class DynamicFontAtSize : public Reference {
- OBJ_TYPE(DynamicFontAtSize,Reference);
+ GDCLASS(DynamicFontAtSize,Reference);
int rect_margin;
struct CharTexture {
- DVector<uint8_t> imgdata;
+ PoolVector<uint8_t> imgdata;
int texture_size;
Vector<int> offsets;
Ref<ImageTexture> texture;
@@ -124,7 +124,7 @@ public:
class DynamicFont : public Font {
- OBJ_TYPE( DynamicFont, Font );
+ GDCLASS( DynamicFont, Font );
Ref<DynamicFontData> data;
Ref<DynamicFontAtSize> data_at_size;
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 4551aff0ef..ffc0a38fc2 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,267 +28,1026 @@
/*************************************************************************/
#include "environment.h"
#include "texture.h"
-void Environment::set_background(BG p_bg) {
+#include "globals.h"
+#include "servers/visual_server.h"
+
+RID Environment::get_rid() const {
+
+ return environment;
+}
+
+
+void Environment::set_background(BGMode p_bg) {
- ERR_FAIL_INDEX(p_bg,BG_MAX);
bg_mode=p_bg;
VS::get_singleton()->environment_set_background(environment,VS::EnvironmentBG(p_bg));
+ _change_notify();
+}
+
+void Environment::set_skybox(const Ref<SkyBox> &p_skybox){
+
+ bg_skybox=p_skybox;
+
+ RID sb_rid;
+ if (bg_skybox.is_valid())
+ sb_rid=bg_skybox->get_rid();
+
+ VS::get_singleton()->environment_set_skybox(environment,sb_rid);
+}
+
+void Environment::set_skybox_scale(float p_scale) {
+
+ bg_skybox_scale=p_scale;
+ VS::get_singleton()->environment_set_skybox_scale(environment,p_scale);
+}
+
+void Environment::set_bg_color(const Color& p_color){
+
+ bg_color=p_color;
+ VS::get_singleton()->environment_set_bg_color(environment,p_color);
+}
+void Environment::set_bg_energy(float p_energy){
+
+ bg_energy=p_energy;
+ VS::get_singleton()->environment_set_bg_energy(environment,p_energy);
+}
+void Environment::set_canvas_max_layer(int p_max_layer){
+
+ bg_canvas_max_layer=p_max_layer;
+ VS::get_singleton()->environment_set_canvas_max_layer(environment,p_max_layer);
+}
+void Environment::set_ambient_light_color(const Color& p_color){
+
+ ambient_color=p_color;
+ VS::get_singleton()->environment_set_ambient_light(environment,ambient_color,ambient_energy,ambient_skybox_contribution);
+}
+void Environment::set_ambient_light_energy(float p_energy){
+
+ ambient_energy=p_energy;
+ VS::get_singleton()->environment_set_ambient_light(environment,ambient_color,ambient_energy,ambient_skybox_contribution);
}
+void Environment::set_ambient_light_skybox_contribution(float p_energy){
-Environment::BG Environment::get_background() const{
+ ambient_skybox_contribution=p_energy;
+ VS::get_singleton()->environment_set_ambient_light(environment,ambient_color,ambient_energy,ambient_skybox_contribution);
+}
+
+Environment::BGMode Environment::get_background() const{
return bg_mode;
}
+Ref<SkyBox> Environment::get_skybox() const{
-void Environment::set_background_param(BGParam p_param, const Variant& p_value){
+ return bg_skybox;
+}
- ERR_FAIL_INDEX(p_param,BG_PARAM_MAX);
- bg_param[p_param]=p_value;
- VS::get_singleton()->environment_set_background_param(environment,VS::EnvironmentBGParam(p_param),p_value);
+float Environment::get_skybox_scale() const {
+ return bg_skybox_scale;
}
-Variant Environment::get_background_param(BGParam p_param) const{
- ERR_FAIL_INDEX_V(p_param,BG_PARAM_MAX,Variant());
- return bg_param[p_param];
+Color Environment::get_bg_color() const{
+ return bg_color;
}
+float Environment::get_bg_energy() const{
-void Environment::set_enable_fx(Fx p_effect,bool p_enabled){
+ return bg_energy;
+}
+int Environment::get_canvas_max_layer() const{
- ERR_FAIL_INDEX(p_effect,FX_MAX);
- fx_enabled[p_effect]=p_enabled;
- VS::get_singleton()->environment_set_enable_fx(environment,VS::EnvironmentFx(p_effect),p_enabled);
+ return bg_canvas_max_layer;
+}
+Color Environment::get_ambient_light_color() const{
+ return ambient_color;
}
-bool Environment::is_fx_enabled(Fx p_effect) const{
+float Environment::get_ambient_light_energy() const{
- ERR_FAIL_INDEX_V(p_effect,FX_MAX,false);
- return fx_enabled[p_effect];
+ return ambient_energy;
+}
+float Environment::get_ambient_light_skybox_contribution() const{
+ return ambient_skybox_contribution;
}
-void Environment::fx_set_param(FxParam p_param,const Variant& p_value){
- ERR_FAIL_INDEX(p_param,FX_PARAM_MAX);
- fx_param[p_param]=p_value;
- VS::get_singleton()->environment_fx_set_param(environment,VS::EnvironmentFxParam(p_param),p_value);
+void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
+
+ tone_mapper=p_tone_mapper;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
}
-Variant Environment::fx_get_param(FxParam p_param) const{
- ERR_FAIL_INDEX_V(p_param,FX_PARAM_MAX,Variant());
- return fx_param[p_param];
+Environment::ToneMapper Environment::get_tonemapper() const{
+ return tone_mapper;
}
-RID Environment::get_rid() const {
+void Environment::set_tonemap_exposure(float p_exposure){
- return environment;
+ tonemap_exposure=p_exposure;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+}
+
+float Environment::get_tonemap_exposure() const{
+
+ return tonemap_exposure;
+}
+
+void Environment::set_tonemap_white(float p_white){
+
+ tonemap_white=p_white;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_white() const {
+
+ return tonemap_white;
+}
+
+void Environment::set_tonemap_auto_exposure(bool p_enabled) {
+
+ tonemap_auto_exposure=p_enabled;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+bool Environment::get_tonemap_auto_exposure() const {
+
+ return tonemap_auto_exposure;
+}
+
+void Environment::set_tonemap_auto_exposure_max(float p_auto_exposure_max) {
+
+ tonemap_auto_exposure_max=p_auto_exposure_max;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_max() const {
+
+ return tonemap_auto_exposure_max;
+}
+
+void Environment::set_tonemap_auto_exposure_min(float p_auto_exposure_min) {
+
+ tonemap_auto_exposure_min=p_auto_exposure_min;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_min() const {
+
+ return tonemap_auto_exposure_min;
+}
+
+void Environment::set_tonemap_auto_exposure_speed(float p_auto_exposure_speed) {
+
+ tonemap_auto_exposure_speed=p_auto_exposure_speed;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_speed() const {
+
+ return tonemap_auto_exposure_speed;
+}
+
+void Environment::set_tonemap_auto_exposure_grey(float p_auto_exposure_grey) {
+
+ tonemap_auto_exposure_grey=p_auto_exposure_grey;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_grey() const {
+
+ return tonemap_auto_exposure_grey;
+}
+
+void Environment::set_adjustment_enable(bool p_enable) {
+
+ adjustment_enabled=p_enable;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+}
+
+bool Environment::is_adjustment_enabled() const {
+
+ return adjustment_enabled;
+}
+
+
+void Environment::set_adjustment_brightness(float p_brightness) {
+
+ adjustment_brightness=p_brightness;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+float Environment::get_adjustment_brightness() const {
+
+ return adjustment_brightness;
+}
+
+void Environment::set_adjustment_contrast(float p_contrast) {
+
+ adjustment_contrast=p_contrast;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+float Environment::get_adjustment_contrast() const {
+
+ return adjustment_contrast;
+}
+
+void Environment::set_adjustment_saturation(float p_saturation) {
+
+ adjustment_saturation=p_saturation;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+float Environment::get_adjustment_saturation() const {
+
+ return adjustment_saturation;
+}
+
+void Environment::set_adjustment_color_correction(const Ref<Texture>& p_ramp) {
+
+ adjustment_color_correction=p_ramp;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+Ref<Texture> Environment::get_adjustment_color_correction() const {
+
+ return adjustment_color_correction;
+}
+
+
+void Environment::_validate_property(PropertyInfo& property) const {
+
+ if (property.name=="background/skybox" || property.name=="background/skybox_scale" || property.name=="ambient_light/skybox_contribution") {
+ if (bg_mode!=BG_SKYBOX) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+
+ if (property.name=="background/color") {
+ if (bg_mode!=BG_COLOR) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+
+ if (property.name=="background/canvas_max_layer") {
+ if (bg_mode!=BG_CANVAS) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+
+}
+
+void Environment::set_ssr_enabled(bool p_enable) {
+
+ ssr_enabled=p_enable;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+}
+
+bool Environment::is_ssr_enabled() const{
+
+ return ssr_enabled;
+}
+
+void Environment::set_ssr_max_steps(int p_steps){
+
+ ssr_max_steps=p_steps;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+int Environment::get_ssr_max_steps() const {
+
+ return ssr_max_steps;
+}
+
+void Environment::set_ssr_accel(float p_accel) {
+
+ ssr_accel=p_accel;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+float Environment::get_ssr_accel() const {
+
+ return ssr_accel;
+}
+
+void Environment::set_ssr_fade(float p_fade) {
+
+ ssr_fade=p_fade;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+float Environment::get_ssr_fade() const {
+
+ return ssr_fade;
+}
+
+void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) {
+
+ ssr_depth_tolerance=p_depth_tolerance;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+float Environment::get_ssr_depth_tolerance() const {
+
+ return ssr_depth_tolerance;
+}
+
+void Environment::set_ssr_smooth(bool p_enable) {
+
+ ssr_smooth=p_enable;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+bool Environment::is_ssr_smooth() const {
+
+ return ssr_smooth;
+}
+
+void Environment::set_ssr_rough(bool p_enable) {
+
+ ssr_roughness=p_enable;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+bool Environment::is_ssr_rough() const {
+
+ return ssr_roughness;
+}
+
+void Environment::set_ssao_enabled(bool p_enable) {
+
+ ssao_enabled=p_enable;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+
+}
+
+bool Environment::is_ssao_enabled() const{
+
+ return ssao_enabled;
+}
+
+void Environment::set_ssao_radius(float p_radius){
+
+ ssao_radius=p_radius;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_radius() const{
+
+ return ssao_radius;
+}
+
+
+void Environment::set_ssao_intensity(float p_intensity){
+
+ ssao_intensity=p_intensity;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+
+float Environment::get_ssao_intensity() const{
+
+ return ssao_intensity;
+}
+
+void Environment::set_ssao_radius2(float p_radius){
+
+ ssao_radius2=p_radius;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_radius2() const{
+
+ return ssao_radius2;
+}
+
+
+void Environment::set_ssao_intensity2(float p_intensity){
+
+ ssao_intensity2=p_intensity;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_intensity2() const{
+
+ return ssao_intensity2;
+}
+
+void Environment::set_ssao_bias(float p_bias){
+
+ ssao_bias=p_bias;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_bias() const{
+
+ return ssao_bias;
+}
+
+void Environment::set_ssao_direct_light_affect(float p_direct_light_affect){
+
+ ssao_direct_light_affect=p_direct_light_affect;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_direct_light_affect() const{
+
+ return ssao_direct_light_affect;
+}
+
+
+void Environment::set_ssao_color(const Color& p_color) {
+
+ ssao_color=p_color;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+
+Color Environment::get_ssao_color() const {
+
+ return ssao_color;
+}
+
+void Environment::set_ssao_blur(bool p_enable) {
+
+ ssao_blur=p_enable;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+bool Environment::is_ssao_blur_enabled() const {
+
+ return ssao_blur;
+}
+
+void Environment::set_glow_enabled(bool p_enabled) {
+
+ glow_enabled=p_enabled;
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+}
+
+bool Environment::is_glow_enabled() const{
+
+ return glow_enabled;
+}
+
+void Environment::set_glow_level(int p_level,bool p_enabled){
+
+ ERR_FAIL_INDEX(p_level,VS::MAX_GLOW_LEVELS);
+
+ if (p_enabled)
+ glow_levels|=(1<<p_level);
+ else
+ glow_levels&=~(1<<p_level);
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+bool Environment::is_glow_level_enabled(int p_level) const{
+
+ ERR_FAIL_INDEX_V(p_level,VS::MAX_GLOW_LEVELS,false);
+
+ return glow_levels&(1<<p_level);
+}
+
+void Environment::set_glow_intensity(float p_intensity){
+
+ glow_intensity=p_intensity;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_intensity() const{
+
+ return glow_intensity;
+}
+
+void Environment::set_glow_strength(float p_strength){
+
+ glow_strength=p_strength;
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_strength() const{
+
+ return glow_strength;
+}
+
+void Environment::set_glow_bloom(float p_treshold){
+
+ glow_bloom=p_treshold;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_bloom() const{
+
+ return glow_bloom;
+}
+
+void Environment::set_glow_blend_mode(GlowBlendMode p_mode){
+
+ glow_blend_mode=p_mode;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+Environment::GlowBlendMode Environment::get_glow_blend_mode() const{
+
+ return glow_blend_mode;
}
+void Environment::set_glow_hdr_bleed_treshold(float p_treshold){
+
+ glow_hdr_bleed_treshold=p_treshold;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_hdr_bleed_treshold() const{
+
+ return glow_hdr_bleed_treshold;
+}
+
+void Environment::set_glow_hdr_bleed_scale(float p_scale){
+
+ glow_hdr_bleed_scale=p_scale;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_hdr_bleed_scale() const{
+
+ return glow_hdr_bleed_scale;
+}
+
+void Environment::set_glow_bicubic_upscale(bool p_enable) {
+
+ glow_bicubic_upscale=p_enable;
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+
+bool Environment::is_glow_bicubic_upscale_enabled() const {
+
+ return glow_bicubic_upscale;
+}
+
+
+void Environment::set_dof_blur_far_enabled(bool p_enable) {
+
+ dof_blur_far_enabled=p_enable;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+}
+
+bool Environment::is_dof_blur_far_enabled() const{
+
+ return dof_blur_far_enabled;
+}
+
+void Environment::set_dof_blur_far_distance(float p_distance){
+
+ dof_blur_far_distance=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+
+}
+float Environment::get_dof_blur_far_distance() const{
+
+ return dof_blur_far_distance;
+}
+
+void Environment::set_dof_blur_far_transition(float p_distance){
+
+ dof_blur_far_transition=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+}
+float Environment::get_dof_blur_far_transition() const{
+
+ return dof_blur_far_transition;
+}
+
+void Environment::set_dof_blur_far_amount(float p_amount){
+
+ dof_blur_far_amount=p_amount;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+
+}
+float Environment::get_dof_blur_far_amount() const{
+
+ return dof_blur_far_amount;
+}
+
+void Environment::set_dof_blur_far_quality(DOFBlurQuality p_quality) {
+
+ dof_blur_far_quality=p_quality;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+}
+
+Environment::DOFBlurQuality Environment::get_dof_blur_far_quality() const {
+
+ return dof_blur_far_quality;
+}
+
+
+void Environment::set_dof_blur_near_enabled(bool p_enable) {
+
+ dof_blur_near_enabled=p_enable;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+bool Environment::is_dof_blur_near_enabled() const{
+
+ return dof_blur_near_enabled;
+}
+
+void Environment::set_dof_blur_near_distance(float p_distance){
+
+ dof_blur_near_distance=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+float Environment::get_dof_blur_near_distance() const{
+
+ return dof_blur_near_distance;
+}
+
+void Environment::set_dof_blur_near_transition(float p_distance){
+
+ dof_blur_near_transition=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+float Environment::get_dof_blur_near_transition() const{
+
+ return dof_blur_near_transition;
+}
+
+void Environment::set_dof_blur_near_amount(float p_amount){
+
+ dof_blur_near_amount=p_amount;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+float Environment::get_dof_blur_near_amount() const{
+
+ return dof_blur_near_amount;
+}
+
+void Environment::set_dof_blur_near_quality(DOFBlurQuality p_quality) {
+
+ dof_blur_near_quality=p_quality;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+Environment::DOFBlurQuality Environment::get_dof_blur_near_quality() const {
+
+ return dof_blur_near_quality;
+}
+
+
void Environment::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_background","bgmode"),&Environment::set_background);
- ObjectTypeDB::bind_method(_MD("get_background"),&Environment::get_background);
-
- ObjectTypeDB::bind_method(_MD("set_background_param","param","value"),&Environment::set_background_param);
- ObjectTypeDB::bind_method(_MD("get_background_param","param"),&Environment::get_background_param);
-
- ObjectTypeDB::bind_method(_MD("set_enable_fx","effect","enabled"),&Environment::set_enable_fx);
- ObjectTypeDB::bind_method(_MD("is_fx_enabled","effect"),&Environment::is_fx_enabled);
-
- ObjectTypeDB::bind_method(_MD("fx_set_param","param","value"),&Environment::fx_set_param);
- ObjectTypeDB::bind_method(_MD("fx_get_param","param"),&Environment::fx_get_param);
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"ambient_light/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_AMBIENT_LIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"ambient_light/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"ambient_light/energy",PROPERTY_HINT_RANGE,"0,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_ENERGY);
-
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fxaa/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FXAA);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Keep,Default Color,Color,Texture,Cubemap,Canvas"),_SCS("set_background"),_SCS("get_background"));
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"background/color"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_TEXTURE);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/cubemap",PROPERTY_HINT_RESOURCE_TYPE,"CubeMap"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CUBEMAP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,128,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/scale",PROPERTY_HINT_RANGE,"0.001,16,0.001"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/glow",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"background/canvas_max_layer"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CANVAS_MAX_LAYER);
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_scale",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_strength",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_STRENGTH);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,SoftLight"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_BLEND_MODE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom_treshold",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"dof_blur/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_DOF_BLUR);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"dof_blur/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/begin",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/range",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_RANGE);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"hdr/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_HDR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/tonemapper",PROPERTY_HINT_ENUM,"Linear,Log,Reinhardt,ReinhardtAutoWhite"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_TONEMAPPER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/white",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_WHITE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_treshold",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_scale",PROPERTY_HINT_RANGE,"0.00,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/min_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MIN_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/max_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MAX_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure_adj_speed",PROPERTY_HINT_RANGE,"0.001,64,0.001"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FOG);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/begin",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/begin_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/end_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_END_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/bg"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BG);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"bcs/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_BCS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_BRIGHTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_CONTRAST);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_SATURATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"srgb/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_SRGB);
-
-
-
-
-
-/*
- FX_PARAM_BLOOM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_BLOOM_GLOW_BLUR_PASSES,
- FX_PARAM_BLOOM_AMOUNT=VS::ENV_FX_PARAM_BLOOM_AMOUNT,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
- FX_PARAM_DOF_BLUR_END=VS::ENV_FX_PARAM_DOF_BLUR_END,
- FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
- FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
- FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
- FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
- FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_GAMMA_VALUE=VS::ENV_FX_PARAM_GAMMA_VALUE,
- FX_PARAM_BRIGHTNESS_VALUE=VS::ENV_FX_PARAM_BRIGHTNESS_VALUE,
- FX_PARAM_CONTRAST_VALUE=VS::ENV_FX_PARAM_CONTRAST_VALUE,
- FX_PARAM_SATURATION_VALUE=VS::ENV_FX_PARAM_SATURATION_VALUE,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
-*/
-
- BIND_CONSTANT( BG_KEEP );
- BIND_CONSTANT( BG_DEFAULT_COLOR );
- BIND_CONSTANT( BG_COLOR );
- BIND_CONSTANT( BG_TEXTURE );
- BIND_CONSTANT( BG_CUBEMAP );
- BIND_CONSTANT( BG_CANVAS );
- BIND_CONSTANT( BG_MAX );
-
- BIND_CONSTANT( BG_PARAM_CANVAS_MAX_LAYER );
- BIND_CONSTANT( BG_PARAM_COLOR );
- BIND_CONSTANT( BG_PARAM_TEXTURE );
- BIND_CONSTANT( BG_PARAM_CUBEMAP );
- BIND_CONSTANT( BG_PARAM_ENERGY );
- BIND_CONSTANT( BG_PARAM_GLOW );
- BIND_CONSTANT( BG_PARAM_MAX );
-
-
- BIND_CONSTANT( FX_AMBIENT_LIGHT );
- BIND_CONSTANT( FX_FXAA );
- BIND_CONSTANT( FX_GLOW );
- BIND_CONSTANT( FX_DOF_BLUR );
- BIND_CONSTANT( FX_HDR );
- BIND_CONSTANT( FX_FOG );
- BIND_CONSTANT( FX_BCS);
- BIND_CONSTANT( FX_SRGB );
- BIND_CONSTANT( FX_MAX );
-
-
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_ADDITIVE );
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_SCREEN );
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_SOFTLIGHT );
-
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_LINEAR );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_LOG );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE );
-
- BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_COLOR );
- BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_ENERGY );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_PASSES );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_SCALE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_STRENGTH );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_BLEND_MODE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM);
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM_TRESHOLD);
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_PASSES );
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_BEGIN );
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_RANGE );
- BIND_CONSTANT( FX_PARAM_HDR_TONEMAPPER);
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE );
- BIND_CONSTANT( FX_PARAM_HDR_WHITE );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_TRESHOLD );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_SCALE );
- BIND_CONSTANT( FX_PARAM_HDR_MIN_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_MAX_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN );
- BIND_CONSTANT( FX_PARAM_FOG_ATTENUATION );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_END_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_BG );
- BIND_CONSTANT( FX_PARAM_BCS_BRIGHTNESS );
- BIND_CONSTANT( FX_PARAM_BCS_CONTRAST );
- BIND_CONSTANT( FX_PARAM_BCS_SATURATION );
- BIND_CONSTANT( FX_PARAM_MAX );
+ ClassDB::bind_method(_MD("set_background","mode"),&Environment::set_background);
+ ClassDB::bind_method(_MD("set_skybox","skybox:CubeMap"),&Environment::set_skybox);
+ ClassDB::bind_method(_MD("set_skybox_scale","scale"),&Environment::set_skybox_scale);
+ ClassDB::bind_method(_MD("set_bg_color","color"),&Environment::set_bg_color);
+ ClassDB::bind_method(_MD("set_bg_energy","energy"),&Environment::set_bg_energy);
+ ClassDB::bind_method(_MD("set_canvas_max_layer","layer"),&Environment::set_canvas_max_layer);
+ ClassDB::bind_method(_MD("set_ambient_light_color","color"),&Environment::set_ambient_light_color);
+ ClassDB::bind_method(_MD("set_ambient_light_energy","energy"),&Environment::set_ambient_light_energy);
+ ClassDB::bind_method(_MD("set_ambient_light_skybox_contribution","energy"),&Environment::set_ambient_light_skybox_contribution);
+
+
+ ClassDB::bind_method(_MD("get_background"),&Environment::get_background);
+ ClassDB::bind_method(_MD("get_skybox:CubeMap"),&Environment::get_skybox);
+ ClassDB::bind_method(_MD("get_skybox_scale"),&Environment::get_skybox_scale);
+ ClassDB::bind_method(_MD("get_bg_color"),&Environment::get_bg_color);
+ ClassDB::bind_method(_MD("get_bg_energy"),&Environment::get_bg_energy);
+ ClassDB::bind_method(_MD("get_canvas_max_layer"),&Environment::get_canvas_max_layer);
+ ClassDB::bind_method(_MD("get_ambient_light_color"),&Environment::get_ambient_light_color);
+ ClassDB::bind_method(_MD("get_ambient_light_energy"),&Environment::get_ambient_light_energy);
+ ClassDB::bind_method(_MD("get_ambient_light_skybox_contribution"),&Environment::get_ambient_light_skybox_contribution);
+
+
+ ADD_GROUP("Background","background_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"background_mode",PROPERTY_HINT_ENUM,"Clear Color,Custom Color,Skybox,Canvas,Keep"),_SCS("set_background"),_SCS("get_background") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"background_skybox",PROPERTY_HINT_RESOURCE_TYPE,"SkyBox"),_SCS("set_skybox"),_SCS("get_skybox") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"background_skybox_scale",PROPERTY_HINT_RANGE,"0,32,0.01"),_SCS("set_skybox_scale"),_SCS("get_skybox_scale") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"background_color"),_SCS("set_bg_color"),_SCS("get_bg_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"background_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_bg_energy"),_SCS("get_bg_energy") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"background_canvas_max_layer",PROPERTY_HINT_RANGE,"-1000,1000,1"),_SCS("set_canvas_max_layer"),_SCS("get_canvas_max_layer") );
+ ADD_GROUP("Ambient Light","ambient_light_");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ambient_light_color"),_SCS("set_ambient_light_color"),_SCS("get_ambient_light_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_ambient_light_energy"),_SCS("get_ambient_light_energy") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light_skybox_contribution",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_ambient_light_skybox_contribution"),_SCS("get_ambient_light_skybox_contribution") );
+
+
+ ClassDB::bind_method(_MD("set_ssr_enabled","enabled"),&Environment::set_ssr_enabled);
+ ClassDB::bind_method(_MD("is_ssr_enabled"),&Environment::is_ssr_enabled);
+
+ ClassDB::bind_method(_MD("set_ssr_max_steps","max_steps"),&Environment::set_ssr_max_steps);
+ ClassDB::bind_method(_MD("get_ssr_max_steps"),&Environment::get_ssr_max_steps);
+
+ ClassDB::bind_method(_MD("set_ssr_accel","accel"),&Environment::set_ssr_accel);
+ ClassDB::bind_method(_MD("get_ssr_accel"),&Environment::get_ssr_accel);
+
+ ClassDB::bind_method(_MD("set_ssr_fade","fade"),&Environment::set_ssr_fade);
+ ClassDB::bind_method(_MD("get_ssr_fade"),&Environment::get_ssr_fade);
+
+ ClassDB::bind_method(_MD("set_ssr_depth_tolerance","depth_tolerance"),&Environment::set_ssr_depth_tolerance);
+ ClassDB::bind_method(_MD("get_ssr_depth_tolerance"),&Environment::get_ssr_depth_tolerance);
+
+ ClassDB::bind_method(_MD("set_ssr_smooth","smooth"),&Environment::set_ssr_smooth);
+ ClassDB::bind_method(_MD("is_ssr_smooth"),&Environment::is_ssr_smooth);
+
+ ClassDB::bind_method(_MD("set_ssr_rough","rough"),&Environment::set_ssr_rough);
+ ClassDB::bind_method(_MD("is_ssr_rough"),&Environment::is_ssr_rough);
+
+ ADD_GROUP("SS Reflections","ss_reflections_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_enabled"),_SCS("set_ssr_enabled"),_SCS("is_ssr_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"ss_reflections_max_steps",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_ssr_max_steps"),_SCS("get_ssr_max_steps") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_accel",PROPERTY_HINT_RANGE,"0,4,0.01"),_SCS("set_ssr_accel"),_SCS("get_ssr_accel") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_fade",PROPERTY_HINT_EXP_EASING),_SCS("set_ssr_fade"),_SCS("get_ssr_fade") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_depth_tolerance",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_ssr_depth_tolerance"),_SCS("get_ssr_depth_tolerance") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_accel_smooth"),_SCS("set_ssr_smooth"),_SCS("is_ssr_smooth") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_roughness"),_SCS("set_ssr_rough"),_SCS("is_ssr_rough") );
+
+ ClassDB::bind_method(_MD("set_ssao_enabled","enabled"),&Environment::set_ssao_enabled);
+ ClassDB::bind_method(_MD("is_ssao_enabled"),&Environment::is_ssao_enabled);
+
+ ClassDB::bind_method(_MD("set_ssao_radius","radius"),&Environment::set_ssao_radius);
+ ClassDB::bind_method(_MD("get_ssao_radius"),&Environment::get_ssao_radius);
+
+ ClassDB::bind_method(_MD("set_ssao_intensity","intensity"),&Environment::set_ssao_intensity);
+ ClassDB::bind_method(_MD("get_ssao_intensity"),&Environment::get_ssao_intensity);
+
+ ClassDB::bind_method(_MD("set_ssao_radius2","radius"),&Environment::set_ssao_radius2);
+ ClassDB::bind_method(_MD("get_ssao_radius2"),&Environment::get_ssao_radius2);
+
+ ClassDB::bind_method(_MD("set_ssao_intensity2","intensity"),&Environment::set_ssao_intensity2);
+ ClassDB::bind_method(_MD("get_ssao_intensity2"),&Environment::get_ssao_intensity2);
+
+ ClassDB::bind_method(_MD("set_ssao_bias","bias"),&Environment::set_ssao_bias);
+ ClassDB::bind_method(_MD("get_ssao_bias"),&Environment::get_ssao_bias);
+
+ ClassDB::bind_method(_MD("set_ssao_direct_light_affect","amount"),&Environment::set_ssao_direct_light_affect);
+ ClassDB::bind_method(_MD("get_ssao_direct_light_affect"),&Environment::get_ssao_direct_light_affect);
+
+ ClassDB::bind_method(_MD("set_ssao_color","color"),&Environment::set_ssao_color);
+ ClassDB::bind_method(_MD("get_ssao_color"),&Environment::get_ssao_color);
+
+ ClassDB::bind_method(_MD("set_ssao_blur","enabled"),&Environment::set_ssao_blur);
+ ClassDB::bind_method(_MD("is_ssao_blur_enabled"),&Environment::is_ssao_blur_enabled);
+
+ ADD_GROUP("SSAO","ssao_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ssao_enabled"),_SCS("set_ssao_enabled"),_SCS("is_ssao_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_radius",PROPERTY_HINT_RANGE,"0.1,16,0.1"),_SCS("set_ssao_radius"),_SCS("get_ssao_radius") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_intensity",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity"),_SCS("get_ssao_intensity") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_radius2",PROPERTY_HINT_RANGE,"0.0,16,0.1"),_SCS("set_ssao_radius2"),_SCS("get_ssao_radius2") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_intensity2",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity2"),_SCS("get_ssao_intensity2") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_bias",PROPERTY_HINT_RANGE,"0.001,8,0.001"),_SCS("set_ssao_bias"),_SCS("get_ssao_bias") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_light_affect",PROPERTY_HINT_RANGE,"0.00,1,0.01"),_SCS("set_ssao_direct_light_affect"),_SCS("get_ssao_direct_light_affect") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ssao_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_ssao_color"),_SCS("get_ssao_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ssao_blur"),_SCS("set_ssao_blur"),_SCS("is_ssao_blur_enabled") );
+
+ ClassDB::bind_method(_MD("set_dof_blur_far_enabled","enabled"),&Environment::set_dof_blur_far_enabled);
+ ClassDB::bind_method(_MD("is_dof_blur_far_enabled"),&Environment::is_dof_blur_far_enabled);
+
+ ClassDB::bind_method(_MD("set_dof_blur_far_distance","intensity"),&Environment::set_dof_blur_far_distance);
+ ClassDB::bind_method(_MD("get_dof_blur_far_distance"),&Environment::get_dof_blur_far_distance);
+
+ ClassDB::bind_method(_MD("set_dof_blur_far_transition","intensity"),&Environment::set_dof_blur_far_transition);
+ ClassDB::bind_method(_MD("get_dof_blur_far_transition"),&Environment::get_dof_blur_far_transition);
+
+ ClassDB::bind_method(_MD("set_dof_blur_far_amount","intensity"),&Environment::set_dof_blur_far_amount);
+ ClassDB::bind_method(_MD("get_dof_blur_far_amount"),&Environment::get_dof_blur_far_amount);
+
+ ClassDB::bind_method(_MD("set_dof_blur_far_quality","intensity"),&Environment::set_dof_blur_far_quality);
+ ClassDB::bind_method(_MD("get_dof_blur_far_quality"),&Environment::get_dof_blur_far_quality);
+
+ ClassDB::bind_method(_MD("set_dof_blur_near_enabled","enabled"),&Environment::set_dof_blur_near_enabled);
+ ClassDB::bind_method(_MD("is_dof_blur_near_enabled"),&Environment::is_dof_blur_near_enabled);
+
+ ClassDB::bind_method(_MD("set_dof_blur_near_distance","intensity"),&Environment::set_dof_blur_near_distance);
+ ClassDB::bind_method(_MD("get_dof_blur_near_distance"),&Environment::get_dof_blur_near_distance);
+
+ ClassDB::bind_method(_MD("set_dof_blur_near_transition","intensity"),&Environment::set_dof_blur_near_transition);
+ ClassDB::bind_method(_MD("get_dof_blur_near_transition"),&Environment::get_dof_blur_near_transition);
+
+ ClassDB::bind_method(_MD("set_dof_blur_near_amount","intensity"),&Environment::set_dof_blur_near_amount);
+ ClassDB::bind_method(_MD("get_dof_blur_near_amount"),&Environment::get_dof_blur_near_amount);
+
+ ClassDB::bind_method(_MD("set_dof_blur_near_quality","level"),&Environment::set_dof_blur_near_quality);
+ ClassDB::bind_method(_MD("get_dof_blur_near_quality"),&Environment::get_dof_blur_near_quality);
+
+ ADD_GROUP("DOF Far Blur","dof_blur_far_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_far_enabled"),_SCS("set_dof_blur_far_enabled"),_SCS("is_dof_blur_far_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_far_distance"),_SCS("get_dof_blur_far_distance") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_far_transition"),_SCS("get_dof_blur_far_transition") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_dof_blur_far_amount"),_SCS("get_dof_blur_far_amount") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_far_quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),_SCS("set_dof_blur_far_quality"),_SCS("get_dof_blur_far_quality") );
+
+ ADD_GROUP("DOF Far Near","dof_blur_near_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_near_enabled"),_SCS("set_dof_blur_near_enabled"),_SCS("is_dof_blur_near_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_near_distance"),_SCS("get_dof_blur_near_distance") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_near_transition"),_SCS("get_dof_blur_near_transition") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_dof_blur_near_amount"),_SCS("get_dof_blur_near_amount") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_near_quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),_SCS("set_dof_blur_near_quality"),_SCS("get_dof_blur_near_quality") );
+
+
+ ClassDB::bind_method(_MD("set_glow_enabled","enabled"),&Environment::set_glow_enabled);
+ ClassDB::bind_method(_MD("is_glow_enabled"),&Environment::is_glow_enabled);
+
+ ClassDB::bind_method(_MD("set_glow_level","idx","enabled"),&Environment::set_glow_level);
+ ClassDB::bind_method(_MD("is_glow_level_enabled","idx"),&Environment::is_glow_level_enabled);
+
+ ClassDB::bind_method(_MD("set_glow_intensity","intensity"),&Environment::set_glow_intensity);
+ ClassDB::bind_method(_MD("get_glow_intensity"),&Environment::get_glow_intensity);
+
+ ClassDB::bind_method(_MD("set_glow_strength","strength"),&Environment::set_glow_strength);
+ ClassDB::bind_method(_MD("get_glow_strength"),&Environment::get_glow_strength);
+
+ ClassDB::bind_method(_MD("set_glow_bloom","amount"),&Environment::set_glow_bloom);
+ ClassDB::bind_method(_MD("get_glow_bloom"),&Environment::get_glow_bloom);
+
+ ClassDB::bind_method(_MD("set_glow_blend_mode","mode"),&Environment::set_glow_blend_mode);
+ ClassDB::bind_method(_MD("get_glow_blend_mode"),&Environment::get_glow_blend_mode);
+
+ ClassDB::bind_method(_MD("set_glow_hdr_bleed_treshold","treshold"),&Environment::set_glow_hdr_bleed_treshold);
+ ClassDB::bind_method(_MD("get_glow_hdr_bleed_treshold"),&Environment::get_glow_hdr_bleed_treshold);
+
+ ClassDB::bind_method(_MD("set_glow_hdr_bleed_scale","scale"),&Environment::set_glow_hdr_bleed_scale);
+ ClassDB::bind_method(_MD("get_glow_hdr_bleed_scale"),&Environment::get_glow_hdr_bleed_scale);
+
+ ClassDB::bind_method(_MD("set_glow_bicubic_upscale","enabled"),&Environment::set_glow_bicubic_upscale);
+ ClassDB::bind_method(_MD("is_glow_bicubic_upscale_enabled"),&Environment::is_glow_bicubic_upscale_enabled);
+
+ ADD_GROUP("Glow","glow_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow_enabled"),_SCS("set_glow_enabled"),_SCS("is_glow_enabled") );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/1"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),0 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/2"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),1 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/3"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),2 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/4"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),3 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/5"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),4 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/6"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),5 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/7"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),6 );
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_intensity",PROPERTY_HINT_RANGE,"0.0,8.0,0.01"),_SCS("set_glow_intensity"),_SCS("get_glow_intensity") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_strength",PROPERTY_HINT_RANGE,"0.0,2.0,0.01"),_SCS("set_glow_strength"),_SCS("get_glow_strength") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_bloom",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_glow_bloom"),_SCS("get_glow_bloom") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"glow_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,Softlight,Replace"),_SCS("set_glow_blend_mode"),_SCS("get_glow_blend_mode") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_hdr_treshold",PROPERTY_HINT_RANGE,"0.0,4.0,0.01"),_SCS("set_glow_hdr_bleed_treshold"),_SCS("get_glow_hdr_bleed_treshold") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_hdr_scale",PROPERTY_HINT_RANGE,"0.0,4.0,0.01"),_SCS("set_glow_hdr_bleed_scale"),_SCS("get_glow_hdr_bleed_scale") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow_bicubic_upscale"),_SCS("set_glow_bicubic_upscale"),_SCS("is_glow_bicubic_upscale_enabled") );
+
+
+ ClassDB::bind_method(_MD("set_tonemapper","mode"),&Environment::set_tonemapper);
+ ClassDB::bind_method(_MD("get_tonemapper"),&Environment::get_tonemapper);
+
+ ClassDB::bind_method(_MD("set_tonemap_exposure","exposure"),&Environment::set_tonemap_exposure);
+ ClassDB::bind_method(_MD("get_tonemap_exposure"),&Environment::get_tonemap_exposure);
+
+ ClassDB::bind_method(_MD("set_tonemap_white","white"),&Environment::set_tonemap_white);
+ ClassDB::bind_method(_MD("get_tonemap_white"),&Environment::get_tonemap_white);
+
+ ClassDB::bind_method(_MD("set_tonemap_auto_exposure","auto_exposure"),&Environment::set_tonemap_auto_exposure);
+ ClassDB::bind_method(_MD("get_tonemap_auto_exposure"),&Environment::get_tonemap_auto_exposure);
+
+ ClassDB::bind_method(_MD("set_tonemap_auto_exposure_max","exposure_max"),&Environment::set_tonemap_auto_exposure_max);
+ ClassDB::bind_method(_MD("get_tonemap_auto_exposure_max"),&Environment::get_tonemap_auto_exposure_max);
+
+ ClassDB::bind_method(_MD("set_tonemap_auto_exposure_min","exposure_min"),&Environment::set_tonemap_auto_exposure_min);
+ ClassDB::bind_method(_MD("get_tonemap_auto_exposure_min"),&Environment::get_tonemap_auto_exposure_min);
+
+ ClassDB::bind_method(_MD("set_tonemap_auto_exposure_speed","exposure_speed"),&Environment::set_tonemap_auto_exposure_speed);
+ ClassDB::bind_method(_MD("get_tonemap_auto_exposure_speed"),&Environment::get_tonemap_auto_exposure_speed);
+
+ ClassDB::bind_method(_MD("set_tonemap_auto_exposure_grey","exposure_grey"),&Environment::set_tonemap_auto_exposure_grey);
+ ClassDB::bind_method(_MD("get_tonemap_auto_exposure_grey"),&Environment::get_tonemap_auto_exposure_grey);
+
+
+ ADD_GROUP("Tonemap","tonemap_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"tonemap_mode",PROPERTY_HINT_ENUM,"Linear,Reindhart,Filmic,Aces"),_SCS("set_tonemapper"),_SCS("get_tonemapper") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap_exposure",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_exposure"),_SCS("get_tonemap_exposure") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap_white",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_white"),_SCS("get_tonemap_white") );
+ ADD_GROUP("Auto Exposure","auto_exposure_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"auto_expoure_enabled"),_SCS("set_tonemap_auto_exposure"),_SCS("get_tonemap_auto_exposure") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_grey"),_SCS("get_tonemap_auto_exposure_grey") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_min_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_min"),_SCS("get_tonemap_auto_exposure_min") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_max_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_max"),_SCS("get_tonemap_auto_exposure_max") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_speed",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_speed"),_SCS("get_tonemap_auto_exposure_speed") );
+
+ ClassDB::bind_method(_MD("set_adjustment_enable","enabled"),&Environment::set_adjustment_enable);
+ ClassDB::bind_method(_MD("is_adjustment_enabled"),&Environment::is_adjustment_enabled);
+
+ ClassDB::bind_method(_MD("set_adjustment_brightness","brightness"),&Environment::set_adjustment_brightness);
+ ClassDB::bind_method(_MD("get_adjustment_brightness"),&Environment::get_adjustment_brightness);
+
+ ClassDB::bind_method(_MD("set_adjustment_contrast","contrast"),&Environment::set_adjustment_contrast);
+ ClassDB::bind_method(_MD("get_adjustment_contrast"),&Environment::get_adjustment_contrast);
+
+ ClassDB::bind_method(_MD("set_adjustment_saturation","saturation"),&Environment::set_adjustment_saturation);
+ ClassDB::bind_method(_MD("get_adjustment_saturation"),&Environment::get_adjustment_saturation);
+
+ ClassDB::bind_method(_MD("set_adjustment_color_correction","color_correction"),&Environment::set_adjustment_color_correction);
+ ClassDB::bind_method(_MD("get_adjustment_color_correction"),&Environment::get_adjustment_color_correction);
+
+ ADD_GROUP("Adjustments","adjustment_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"adjustment_enabled"),_SCS("set_adjustment_enable"),_SCS("is_adjustment_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_brightness"),_SCS("get_adjustment_brightness") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_contrast"),_SCS("get_adjustment_contrast") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_saturation"),_SCS("get_adjustment_saturation") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"adjustment_color_correction",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_adjustment_color_correction"),_SCS("get_adjustment_color_correction") );
+
+
+ GLOBAL_DEF("rendering/skybox/irradiance_cube_resolution",256);
+
+ BIND_CONSTANT(BG_KEEP);
+ BIND_CONSTANT(BG_CLEAR_COLOR);
+ BIND_CONSTANT(BG_COLOR);
+ BIND_CONSTANT(BG_SKYBOX);
+ 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);
+
}
Environment::Environment() {
+ bg_mode=BG_CLEAR_COLOR;
+ bg_skybox_scale=1.0;
+ bg_energy=1.0;
+ bg_canvas_max_layer=0;
+ ambient_energy=1.0;
+ ambient_skybox_contribution=0;
+
+
+ tone_mapper=TONE_MAPPER_LINEAR;
+ tonemap_exposure=1.0;
+ tonemap_white=1.0;
+ tonemap_auto_exposure=false;
+ tonemap_auto_exposure_max=8;
+ tonemap_auto_exposure_min=0.05;
+ tonemap_auto_exposure_speed=0.5;
+ tonemap_auto_exposure_grey=0.4;
+
+ set_tonemapper(tone_mapper); //update
+
+ adjustment_enabled=false;
+ adjustment_contrast=1.0;
+ adjustment_saturation=1.0;
+ adjustment_brightness=1.0;
+
+ set_adjustment_enable(adjustment_enabled); //update
+
environment = VS::get_singleton()->environment_create();
- set_background(BG_DEFAULT_COLOR);
- set_background_param(BG_PARAM_COLOR,Color(0,0,0));
- set_background_param(BG_PARAM_TEXTURE,Ref<ImageTexture>());
- set_background_param(BG_PARAM_CUBEMAP,Ref<CubeMap>());
- set_background_param(BG_PARAM_ENERGY,1.0);
- set_background_param(BG_PARAM_SCALE,1.0);
- set_background_param(BG_PARAM_GLOW,0.0);
-
- for(int i=0;i<FX_MAX;i++)
- set_enable_fx(Fx(i),false);
-
- fx_set_param(FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_AMBIENT_LIGHT_ENERGY,1.0);
- fx_set_param(FX_PARAM_GLOW_BLUR_PASSES,1);
- fx_set_param(FX_PARAM_GLOW_BLUR_SCALE,1);
- fx_set_param(FX_PARAM_GLOW_BLUR_STRENGTH,1);
- fx_set_param(FX_PARAM_GLOW_BLOOM,0.0);
- fx_set_param(FX_PARAM_GLOW_BLOOM_TRESHOLD,0.5);
- fx_set_param(FX_PARAM_DOF_BLUR_PASSES,1);
- fx_set_param(FX_PARAM_DOF_BLUR_BEGIN,100.0);
- fx_set_param(FX_PARAM_DOF_BLUR_RANGE,10.0);
- fx_set_param(FX_PARAM_HDR_TONEMAPPER,FX_HDR_TONE_MAPPER_LINEAR);
- fx_set_param(FX_PARAM_HDR_EXPOSURE,0.4);
- fx_set_param(FX_PARAM_HDR_WHITE,1.0);
- fx_set_param(FX_PARAM_HDR_GLOW_TRESHOLD,0.95);
- fx_set_param(FX_PARAM_HDR_GLOW_SCALE,0.2);
- fx_set_param(FX_PARAM_HDR_MIN_LUMINANCE,0.4);
- fx_set_param(FX_PARAM_HDR_MAX_LUMINANCE,8.0);
- fx_set_param(FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,0.5);
- fx_set_param(FX_PARAM_FOG_BEGIN,100.0);
- fx_set_param(FX_PARAM_FOG_ATTENUATION,1.0);
- fx_set_param(FX_PARAM_FOG_BEGIN_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_END_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_BG,true);
- fx_set_param(FX_PARAM_BCS_BRIGHTNESS,1.0);
- fx_set_param(FX_PARAM_BCS_CONTRAST,1.0);
- fx_set_param(FX_PARAM_BCS_SATURATION,1.0);
+ ssr_enabled=false;
+ ssr_max_steps=64;
+ ssr_accel=0.04;
+ ssr_fade=2.0;
+ ssr_depth_tolerance=0.2;
+ ssr_smooth=true;
+ ssr_roughness=true;
+
+ ssao_enabled=false;
+ ssao_radius=1;
+ ssao_intensity=1;
+ ssao_radius2=0;
+ ssao_intensity2=1;
+ ssao_bias=0.01;
+ ssao_direct_light_affect=false;
+ ssao_blur=true;
+
+ glow_enabled=false;
+ glow_levels=(1<<2)|(1<<4);
+ glow_intensity=0.8;
+ glow_strength=1.0;
+ glow_bloom=0.0;
+ glow_blend_mode=GLOW_BLEND_MODE_SOFTLIGHT;
+ glow_hdr_bleed_treshold=1.0;
+ glow_hdr_bleed_scale=2.0;
+ glow_bicubic_upscale=false;
+
+ dof_blur_far_enabled=false;
+ dof_blur_far_distance=10;
+ dof_blur_far_transition=5;
+ dof_blur_far_amount=0.1;
+ dof_blur_far_quality=DOF_BLUR_QUALITY_MEDIUM;
+
+ dof_blur_near_enabled=false;
+ dof_blur_near_distance=2;
+ dof_blur_near_transition=1;
+ dof_blur_near_amount=0.1;
+ dof_blur_near_quality=DOF_BLUR_QUALITY_MEDIUM;
}
+
Environment::~Environment() {
VS::get_singleton()->free(environment);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index a72cc6a47f..b8c243b588 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,113 +31,288 @@
#include "resource.h"
#include "servers/visual_server.h"
+#include "scene/resources/texture.h"
+#include "scene/resources/sky_box.h"
class Environment : public Resource {
- OBJ_TYPE(Environment,Resource);
+ GDCLASS(Environment,Resource);
public:
- enum BG {
+ enum BGMode {
- BG_KEEP=VS::ENV_BG_KEEP,
- BG_DEFAULT_COLOR=VS::ENV_BG_DEFAULT_COLOR,
- BG_COLOR=VS::ENV_BG_COLOR,
- BG_TEXTURE=VS::ENV_BG_TEXTURE,
- BG_CUBEMAP=VS::ENV_BG_CUBEMAP,
- BG_CANVAS=VS::ENV_BG_CANVAS,
- BG_MAX=VS::ENV_BG_MAX
+ BG_CLEAR_COLOR,
+ BG_COLOR,
+ BG_SKYBOX,
+ BG_CANVAS,
+ BG_KEEP,
+ BG_MAX
};
- enum BGParam {
- BG_PARAM_CANVAS_MAX_LAYER=VS::ENV_BG_PARAM_CANVAS_MAX_LAYER,
- BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR,
- BG_PARAM_TEXTURE=VS::ENV_BG_PARAM_TEXTURE,
- BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP,
- BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY,
- BG_PARAM_SCALE=VS::ENV_BG_PARAM_SCALE,
- BG_PARAM_GLOW=VS::ENV_BG_PARAM_GLOW,
- BG_PARAM_MAX=VS::ENV_BG_PARAM_MAX
- };
- enum Fx {
- FX_AMBIENT_LIGHT=VS::ENV_FX_AMBIENT_LIGHT,
- FX_FXAA=VS::ENV_FX_FXAA,
- FX_GLOW=VS::ENV_FX_GLOW,
- FX_DOF_BLUR=VS::ENV_FX_DOF_BLUR,
- FX_HDR=VS::ENV_FX_HDR,
- FX_FOG=VS::ENV_FX_FOG,
- FX_BCS=VS::ENV_FX_BCS,
- FX_SRGB=VS::ENV_FX_SRGB,
- FX_MAX=VS::ENV_FX_MAX,
+ enum ToneMapper {
+ TONE_MAPPER_LINEAR,
+ TONE_MAPPER_REINHARDT,
+ TONE_MAPPER_FILMIC,
+ TONE_MAPPER_ACES
};
- enum FxBlurBlendMode {
- FX_BLUR_BLEND_MODE_ADDITIVE,
- FX_BLUR_BLEND_MODE_SCREEN,
- FX_BLUR_BLEND_MODE_SOFTLIGHT,
+ enum GlowBlendMode {
+ GLOW_BLEND_MODE_ADDITIVE,
+ GLOW_BLEND_MODE_SCREEN,
+ GLOW_BLEND_MODE_SOFTLIGHT,
+ GLOW_BLEND_MODE_REPLACE,
};
- enum FxHDRToneMapper {
- FX_HDR_TONE_MAPPER_LINEAR,
- FX_HDR_TONE_MAPPER_LOG,
- FX_HDR_TONE_MAPPER_REINHARDT,
- FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE,
+ enum DOFBlurQuality {
+ DOF_BLUR_QUALITY_LOW,
+ DOF_BLUR_QUALITY_MEDIUM,
+ DOF_BLUR_QUALITY_HIGH,
};
- enum FxParam {
- FX_PARAM_AMBIENT_LIGHT_COLOR=VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR,
- FX_PARAM_AMBIENT_LIGHT_ENERGY=VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY,
- FX_PARAM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_GLOW_BLUR_PASSES,
- FX_PARAM_GLOW_BLUR_SCALE=VS::ENV_FX_PARAM_GLOW_BLUR_SCALE,
- FX_PARAM_GLOW_BLUR_STRENGTH=VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
- FX_PARAM_GLOW_BLUR_BLEND_MODE=VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE,
- FX_PARAM_GLOW_BLOOM=VS::ENV_FX_PARAM_GLOW_BLOOM,
- FX_PARAM_GLOW_BLOOM_TRESHOLD=VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
- FX_PARAM_DOF_BLUR_RANGE=VS::ENV_FX_PARAM_DOF_BLUR_RANGE,
- FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
- FX_PARAM_HDR_TONEMAPPER=VS::ENV_FX_PARAM_HDR_TONEMAPPER,
- FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
- FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
- FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
- FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_BCS_BRIGHTNESS=VS::ENV_FX_PARAM_BCS_BRIGHTNESS,
- FX_PARAM_BCS_CONTRAST=VS::ENV_FX_PARAM_BCS_CONTRAST,
- FX_PARAM_BCS_SATURATION=VS::ENV_FX_PARAM_BCS_SATURATION,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
- };
private:
-
- BG bg_mode;
- Variant bg_param[BG_PARAM_MAX];
- bool fx_enabled[FX_MAX];
- Variant fx_param[FX_PARAM_MAX];
RID environment;
+ BGMode bg_mode;
+ Ref<SkyBox> bg_skybox;
+ float bg_skybox_scale;
+ Color bg_color;
+ float bg_energy;
+ int bg_canvas_max_layer;
+ Color ambient_color;
+ float ambient_energy;
+ float ambient_skybox_contribution;
+
+ ToneMapper tone_mapper;
+ float tonemap_exposure;
+ float tonemap_white;
+ bool tonemap_auto_exposure;
+ float tonemap_auto_exposure_max;
+ float tonemap_auto_exposure_min;
+ float tonemap_auto_exposure_speed;
+ float tonemap_auto_exposure_grey;
+
+ bool adjustment_enabled;
+ float adjustment_contrast;
+ float adjustment_saturation;
+ float adjustment_brightness;
+ Ref<Texture> adjustment_color_correction;
+
+ bool ssr_enabled;
+ int ssr_max_steps;
+ float ssr_accel;
+ float ssr_fade;
+ float ssr_depth_tolerance;
+ bool ssr_smooth;
+ bool ssr_roughness;
+
+ bool ssao_enabled;
+ float ssao_radius;
+ float ssao_intensity;
+ float ssao_radius2;
+ float ssao_intensity2;
+ float ssao_bias;
+ float ssao_direct_light_affect;
+ Color ssao_color;
+ bool ssao_blur;
+
+ bool glow_enabled;
+ int glow_levels;
+ float glow_intensity;
+ float glow_strength;
+ float glow_bloom;
+ GlowBlendMode glow_blend_mode;
+ float glow_hdr_bleed_treshold;
+ float glow_hdr_bleed_scale;
+ bool glow_bicubic_upscale;
+
+ bool dof_blur_far_enabled;
+ float dof_blur_far_distance;
+ float dof_blur_far_transition;
+ float dof_blur_far_amount;
+ DOFBlurQuality dof_blur_far_quality;
+
+ bool dof_blur_near_enabled;
+ float dof_blur_near_distance;
+ float dof_blur_near_transition;
+ float dof_blur_near_amount;
+ DOFBlurQuality dof_blur_near_quality;
+
protected:
static void _bind_methods();
+ virtual void _validate_property(PropertyInfo& property) const;
+
public:
- void set_background(BG p_bg);
- BG get_background() const;
- void set_background_param(BGParam p_param, const Variant& p_value);
- Variant get_background_param(BGParam p_param) const;
- void set_enable_fx(Fx p_effect,bool p_enabled);
- bool is_fx_enabled(Fx p_effect) const;
+ void set_background(BGMode p_bg);
+ void set_skybox(const Ref<SkyBox>& p_skybox);
+ void set_skybox_scale(float p_scale);
+ void set_bg_color(const Color& p_color);
+ void set_bg_energy(float p_energy);
+ void set_canvas_max_layer(int p_max_layer);
+ void set_ambient_light_color(const Color& p_color);
+ void set_ambient_light_energy(float p_energy);
+ void set_ambient_light_skybox_contribution(float p_energy);
+
+ BGMode get_background() const;
+ Ref<SkyBox> get_skybox() const;
+ float get_skybox_scale() const;
+ Color get_bg_color() const;
+ float get_bg_energy() const;
+ int get_canvas_max_layer() const;
+ Color get_ambient_light_color() const;
+ float get_ambient_light_energy() const;
+ float get_ambient_light_skybox_contribution() const;
+
+
+ void set_tonemapper(ToneMapper p_tone_mapper);
+ ToneMapper get_tonemapper() const;
+
+ void set_tonemap_exposure(float p_exposure);
+ float get_tonemap_exposure() const;
+
+ void set_tonemap_white(float p_white);
+ float get_tonemap_white() const;
+
+ void set_tonemap_auto_exposure(bool p_enabled);
+ bool get_tonemap_auto_exposure() const;
+
+ void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
+ float get_tonemap_auto_exposure_max() const;
+
+ void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
+ float get_tonemap_auto_exposure_min() const;
+
+ void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
+ float get_tonemap_auto_exposure_speed() const;
+
+ void set_tonemap_auto_exposure_grey(float p_auto_exposure_grey);
+ float get_tonemap_auto_exposure_grey() const;
+
+ void set_adjustment_enable(bool p_enable);
+ bool is_adjustment_enabled() const;
+
+ void set_adjustment_brightness(float p_brightness);
+ float get_adjustment_brightness() const;
+
+ void set_adjustment_contrast(float p_contrast);
+ float get_adjustment_contrast() const;
+
+ void set_adjustment_saturation(float p_saturation);
+ float get_adjustment_saturation() const;
+
+ void set_adjustment_color_correction(const Ref<Texture>& p_ramp);
+ Ref<Texture> get_adjustment_color_correction() const;
+
+ void set_ssr_enabled(bool p_enable);
+ bool is_ssr_enabled() const;
+
+ void set_ssr_max_steps(int p_steps);
+ int get_ssr_max_steps() const;
+
+ void set_ssr_accel(float p_accel);
+ float get_ssr_accel() const;
+
+ void set_ssr_fade(float p_transition);
+ float get_ssr_fade() const;
+
+ void set_ssr_depth_tolerance(float p_depth_tolerance);
+ float get_ssr_depth_tolerance() const;
+
+ void set_ssr_smooth(bool p_enable);
+ bool is_ssr_smooth() const;
+
+ void set_ssr_rough(bool p_enable);
+ bool is_ssr_rough() const;
+
+ void set_ssao_enabled(bool p_enable);
+ bool is_ssao_enabled() const;
+
+ void set_ssao_radius(float p_radius);
+ float get_ssao_radius() const;
+
+ void set_ssao_intensity(float p_intensity);
+ float get_ssao_intensity() const;
+
+ void set_ssao_radius2(float p_radius);
+ float get_ssao_radius2() const;
+
+ void set_ssao_intensity2(float p_intensity);
+ float get_ssao_intensity2() const;
+
+ void set_ssao_bias(float p_bias);
+ float get_ssao_bias() const;
+
+ void set_ssao_direct_light_affect(float p_direct_light_affect);
+ float get_ssao_direct_light_affect() const;
+
+ void set_ssao_color(const Color& p_color);
+ Color get_ssao_color() const;
+
+ void set_ssao_blur(bool p_enable);
+ bool is_ssao_blur_enabled() const;
+
+
+ void set_glow_enabled(bool p_enabled);
+ bool is_glow_enabled() const;
+
+ void set_glow_level(int p_level,bool p_enabled);
+ bool is_glow_level_enabled(int p_level) const;
+
+ void set_glow_intensity(float p_intensity);
+ float get_glow_intensity() const;
+
+ void set_glow_strength(float p_strength);
+ float get_glow_strength() const;
+
+ void set_glow_bloom(float p_treshold);
+ float get_glow_bloom() const;
+
+ void set_glow_blend_mode(GlowBlendMode p_mode);
+ GlowBlendMode get_glow_blend_mode() const;
+
+ void set_glow_hdr_bleed_treshold(float p_treshold);
+ float get_glow_hdr_bleed_treshold() const;
+
+ void set_glow_hdr_bleed_scale(float p_scale);
+ float get_glow_hdr_bleed_scale() const;
+
+ void set_glow_bicubic_upscale(bool p_enable);
+ bool is_glow_bicubic_upscale_enabled() const;
+
+ void set_dof_blur_far_enabled(bool p_enable);
+ bool is_dof_blur_far_enabled() const;
+
+ void set_dof_blur_far_distance(float p_distance);
+ float get_dof_blur_far_distance() const;
+
+ void set_dof_blur_far_transition(float p_distance);
+ float get_dof_blur_far_transition() const;
+
+ void set_dof_blur_far_amount(float p_amount);
+ float get_dof_blur_far_amount() const;
+
+ void set_dof_blur_far_quality(DOFBlurQuality p_quality);
+ DOFBlurQuality get_dof_blur_far_quality() const;
+
+ void set_dof_blur_near_enabled(bool p_enable);
+ bool is_dof_blur_near_enabled() const;
+
+ void set_dof_blur_near_distance(float p_distance);
+ float get_dof_blur_near_distance() const;
+
+ void set_dof_blur_near_transition(float p_distance);
+ float get_dof_blur_near_transition() const;
+
+ void set_dof_blur_near_amount(float p_amount);
+ float get_dof_blur_near_amount() const;
+
+ void set_dof_blur_near_quality(DOFBlurQuality p_quality);
+ DOFBlurQuality get_dof_blur_near_quality() const;
- void fx_set_param(FxParam p_param,const Variant& p_value);
- Variant fx_get_param(FxParam p_param) const;
virtual RID get_rid() const;
@@ -145,9 +320,12 @@ public:
~Environment();
};
-VARIANT_ENUM_CAST( Environment::BG );
-VARIANT_ENUM_CAST( Environment::BGParam );
-VARIANT_ENUM_CAST( Environment::Fx );
-VARIANT_ENUM_CAST( Environment::FxParam );
+
+
+
+VARIANT_ENUM_CAST(Environment::BGMode)
+VARIANT_ENUM_CAST(Environment::ToneMapper)
+VARIANT_ENUM_CAST(Environment::GlowBlendMode)
+VARIANT_ENUM_CAST(Environment::DOFBlurQuality)
#endif // ENVIRONMENT_H
diff --git a/scene/resources/event_stream.cpp b/scene/resources/event_stream.cpp
index 8667bcc5db..521f305327 100644
--- a/scene/resources/event_stream.cpp
+++ b/scene/resources/event_stream.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/event_stream.h b/scene/resources/event_stream.h
index 6ee9b76717..40af78fcce 100644
--- a/scene/resources/event_stream.h
+++ b/scene/resources/event_stream.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class EventStreamPlayback : public Reference {
- OBJ_TYPE(EventStreamPlayback,Reference);
+ GDCLASS(EventStreamPlayback,Reference);
class InternalEventStream : public AudioServer::EventStream {
public:
@@ -99,7 +99,7 @@ public:
class EventStream : public Resource {
- OBJ_TYPE(EventStream,Resource);
+ GDCLASS(EventStream,Resource);
OBJ_SAVE_TYPE( EventStream ); //children are all saved as EventStream, so they can be exchanged
public:
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 1afa3fec19..b1d0611f48 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -78,14 +78,14 @@ void Font::update_changes() {
void Font::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_ascent"),&Font::get_ascent);
- ObjectTypeDB::bind_method(_MD("get_descent"),&Font::get_descent);
- ObjectTypeDB::bind_method(_MD("get_height"),&Font::get_height);
- ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
- ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
- ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
- ObjectTypeDB::bind_method(_MD("update_changes"),&Font::update_changes);
+ ClassDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
+ ClassDB::bind_method(_MD("get_ascent"),&Font::get_ascent);
+ ClassDB::bind_method(_MD("get_descent"),&Font::get_descent);
+ ClassDB::bind_method(_MD("get_height"),&Font::get_height);
+ ClassDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
+ ClassDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
+ ClassDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
+ ClassDB::bind_method(_MD("update_changes"),&Font::update_changes);
}
@@ -97,7 +97,7 @@ Font::Font() {
/////////////////////////////////////////////////////////////////
-void BitmapFont::_set_chars(const DVector<int>& p_chars) {
+void BitmapFont::_set_chars(const PoolVector<int>& p_chars) {
int len = p_chars.size();
//char 1 charsize 1 texture, 4 rect, 2 align, advance 1
@@ -107,7 +107,7 @@ void BitmapFont::_set_chars(const DVector<int>& p_chars) {
int chars = len/9;
- DVector<int>::Read r=p_chars.read();
+ PoolVector<int>::Read r=p_chars.read();
for(int i=0;i<chars;i++) {
const int* data = &r[i*9];
@@ -116,9 +116,9 @@ void BitmapFont::_set_chars(const DVector<int>& p_chars) {
}
-DVector<int> BitmapFont::_get_chars() const {
+PoolVector<int> BitmapFont::_get_chars() const {
- DVector<int> chars;
+ PoolVector<int> chars;
const CharType* key=NULL;
@@ -140,13 +140,13 @@ DVector<int> BitmapFont::_get_chars() const {
return chars;
}
-void BitmapFont::_set_kernings(const DVector<int>& p_kernings) {
+void BitmapFont::_set_kernings(const PoolVector<int>& p_kernings) {
int len=p_kernings.size();
ERR_FAIL_COND(len%3);
if (!len)
return;
- DVector<int>::Read r=p_kernings.read();
+ PoolVector<int>::Read r=p_kernings.read();
for(int i=0;i<len/3;i++) {
@@ -155,9 +155,9 @@ void BitmapFont::_set_kernings(const DVector<int>& p_kernings) {
}
}
-DVector<int> BitmapFont::_get_kernings() const {
+PoolVector<int> BitmapFont::_get_kernings() const {
- DVector<int> kernings;
+ PoolVector<int> kernings;
for(Map<KerningPairKey,int>::Element *E=kerning_map.front();E;E=E->next()) {
@@ -252,8 +252,10 @@ Error BitmapFont::create_from_fnt(const String& p_string) {
if (keys.has("face"))
set_name(keys["face"]);
- //if (keys.has("size"))
- // font->set_height(keys["size"].to_int());
+ /*
+ if (keys.has("size"))
+ font->set_height(keys["size"].to_int());
+ */
} else if (type=="common") {
@@ -564,43 +566,43 @@ Size2 BitmapFont::get_char_size(CharType p_char,CharType p_next) const {
void BitmapFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
- ObjectTypeDB::bind_method(_MD("set_height","px"),&BitmapFont::set_height);
+ ClassDB::bind_method(_MD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
+ ClassDB::bind_method(_MD("set_height","px"),&BitmapFont::set_height);
- ObjectTypeDB::bind_method(_MD("set_ascent","px"),&BitmapFont::set_ascent);
+ ClassDB::bind_method(_MD("set_ascent","px"),&BitmapFont::set_ascent);
- ObjectTypeDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
- ObjectTypeDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);
+ ClassDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
+ ClassDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);
- ObjectTypeDB::bind_method(_MD("add_texture","texture:Texture"),&BitmapFont::add_texture);
- ObjectTypeDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));
+ ClassDB::bind_method(_MD("add_texture","texture:Texture"),&BitmapFont::add_texture);
+ ClassDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_texture_count"),&BitmapFont::get_texture_count);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","idx"),&BitmapFont::get_texture);
+ ClassDB::bind_method(_MD("get_texture_count"),&BitmapFont::get_texture_count);
+ ClassDB::bind_method(_MD("get_texture:Texture","idx"),&BitmapFont::get_texture);
- ObjectTypeDB::bind_method(_MD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));
+ ClassDB::bind_method(_MD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);
+ ClassDB::bind_method(_MD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);
- ObjectTypeDB::bind_method(_MD("clear"),&BitmapFont::clear);
+ ClassDB::bind_method(_MD("clear"),&BitmapFont::clear);
- ObjectTypeDB::bind_method(_MD("_set_chars"),&BitmapFont::_set_chars);
- ObjectTypeDB::bind_method(_MD("_get_chars"),&BitmapFont::_get_chars);
+ ClassDB::bind_method(_MD("_set_chars"),&BitmapFont::_set_chars);
+ ClassDB::bind_method(_MD("_get_chars"),&BitmapFont::_get_chars);
- ObjectTypeDB::bind_method(_MD("_set_kernings"),&BitmapFont::_set_kernings);
- ObjectTypeDB::bind_method(_MD("_get_kernings"),&BitmapFont::_get_kernings);
+ ClassDB::bind_method(_MD("_set_kernings"),&BitmapFont::_set_kernings);
+ ClassDB::bind_method(_MD("_get_kernings"),&BitmapFont::_get_kernings);
- ObjectTypeDB::bind_method(_MD("_set_textures"),&BitmapFont::_set_textures);
- ObjectTypeDB::bind_method(_MD("_get_textures"),&BitmapFont::_get_textures);
+ ClassDB::bind_method(_MD("_set_textures"),&BitmapFont::_set_textures);
+ ClassDB::bind_method(_MD("_get_textures"),&BitmapFont::_get_textures);
- ObjectTypeDB::bind_method(_MD("set_fallback","fallback"),&BitmapFont::set_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback"),&BitmapFont::get_fallback);
+ ClassDB::bind_method(_MD("set_fallback","fallback"),&BitmapFont::set_fallback);
+ ClassDB::bind_method(_MD("get_fallback"),&BitmapFont::get_fallback);
ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") );
- ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") );
- ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "kernings", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_kernings"), _SCS("_get_kernings") );
+ ADD_PROPERTY( PropertyInfo( Variant::POOL_INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") );
+ ADD_PROPERTY( PropertyInfo( Variant::POOL_INT_ARRAY, "kernings", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_kernings"), _SCS("_get_kernings") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
diff --git a/scene/resources/font.h b/scene/resources/font.h
index fe4558f9e3..ad0f0176db 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@
class Font : public Resource {
- OBJ_TYPE( Font, Resource );
+ GDCLASS( Font, Resource );
protected:
@@ -69,7 +69,7 @@ public:
class BitmapFont : public Font {
- OBJ_TYPE( BitmapFont, Font );
+ GDCLASS( BitmapFont, Font );
RES_BASE_EXTENSION("fnt");
Vector< Ref<Texture> > textures;
@@ -109,10 +109,10 @@ private:
float ascent;
bool distance_field_hint;
- void _set_chars(const DVector<int>& p_chars);
- DVector<int> _get_chars() const;
- void _set_kernings(const DVector<int>& p_kernings);
- DVector<int> _get_kernings() const;
+ void _set_chars(const PoolVector<int>& p_chars);
+ PoolVector<int> _get_chars() const;
+ void _set_kernings(const PoolVector<int>& p_kernings);
+ PoolVector<int> _get_kernings() const;
void _set_textures(const Vector<Variant> & p_textures);
Vector<Variant> _get_textures() const;
diff --git a/scene/resources/gibberish_stream.cpp b/scene/resources/gibberish_stream.cpp
index 73c135a913..3a6a6df7ea 100644
--- a/scene/resources/gibberish_stream.cpp
+++ b/scene/resources/gibberish_stream.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -305,17 +305,17 @@ float AudioStreamGibberish::get_pitch_random_scale() const {
void AudioStreamGibberish::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
- ObjectTypeDB::bind_method(_MD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
+ ClassDB::bind_method(_MD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
+ ClassDB::bind_method(_MD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
- ObjectTypeDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale);
+ ClassDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale);
+ ClassDB::bind_method(_MD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale);
- ObjectTypeDB::bind_method(_MD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale);
- ObjectTypeDB::bind_method(_MD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale);
+ ClassDB::bind_method(_MD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale);
+ ClassDB::bind_method(_MD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale);
- ObjectTypeDB::bind_method(_MD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time);
- ObjectTypeDB::bind_method(_MD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time);
+ ClassDB::bind_method(_MD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time);
+ ClassDB::bind_method(_MD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"phonemes",PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_phonemes"),_SCS("get_phonemes"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_pitch_scale"),_SCS("get_pitch_scale"));
diff --git a/scene/resources/gibberish_stream.h b/scene/resources/gibberish_stream.h
index 7affb4bd4d..257a1faebf 100644
--- a/scene/resources/gibberish_stream.h
+++ b/scene/resources/gibberish_stream.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
#include "scene/resources/sample_library.h"
class AudioStreamGibberish : public AudioStream {
- OBJ_TYPE( AudioStreamGibberish, AudioStream );
+ GDCLASS( AudioStreamGibberish, AudioStream );
enum {
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 9dc54ef0e4..112ecaae2f 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,576 +29,1128 @@
#include "material.h"
#include "scene/scene_string_names.h"
+RID Material::get_rid() const {
-static const char*_flag_names[Material::FLAG_MAX]={
- "visible",
- "double_sided",
- "invert_faces",
- "unshaded",
- "on_top",
- "lightmap_on_uv2",
- "colarray_is_srgb"
-};
-
+ return material;
+}
-static const Material::Flag _flag_indices[Material::FLAG_MAX]={
- Material::FLAG_VISIBLE,
- Material::FLAG_DOUBLE_SIDED,
- Material::FLAG_INVERT_FACES,
- Material::FLAG_UNSHADED,
- Material::FLAG_ONTOP,
- Material::FLAG_LIGHTMAP_ON_UV2,
- Material::FLAG_COLOR_ARRAY_SRGB,
-};
+Material::Material() {
+ material=VisualServer::get_singleton()->material_create();
+}
-RID Material::get_rid() const {
+Material::~Material() {
- return material;
+ VisualServer::get_singleton()->free(material);
}
-void Material::set_flag(Flag p_flag,bool p_enabled) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags[p_flag]=p_enabled;
- VisualServer::get_singleton()->material_set_flag(material,(VS::MaterialFlag)p_flag,p_enabled);
- _change_notify();
+/////////////////////////////////
+
+Mutex *FixedSpatialMaterial::material_mutex=NULL;
+SelfList<FixedSpatialMaterial>::List FixedSpatialMaterial::dirty_materials;
+Map<FixedSpatialMaterial::MaterialKey,FixedSpatialMaterial::ShaderData> FixedSpatialMaterial::shader_map;
+FixedSpatialMaterial::ShaderNames* FixedSpatialMaterial::shader_names=NULL;
+
+void FixedSpatialMaterial::init_shaders() {
+
+#ifndef NO_THREADS
+ material_mutex = Mutex::create();
+#endif
+
+ shader_names = memnew( ShaderNames );
+
+ shader_names->albedo="albedo";
+ shader_names->specular="specular";
+ shader_names->roughness="roughness";
+ shader_names->metalness="metalness";
+ shader_names->emission="emission";
+ shader_names->emission_energy="emission_energy";
+ shader_names->normal_scale="normal_scale";
+ shader_names->rim="rim";
+ shader_names->rim_tint="rim_tint";
+ shader_names->clearcoat="clearcoat";
+ shader_names->clearcoat_gloss="clearcoat_gloss";
+ shader_names->anisotropy="anisotropy_ratio";
+ shader_names->height_scale="height_scale";
+ shader_names->subsurface_scattering_strength="subsurface_scattering_strength";
+ shader_names->refraction="refraction";
+ shader_names->refraction_roughness="refraction_roughness";
+ shader_names->point_size="point_size";
+ shader_names->uv1_scale="uv1_scale";
+ shader_names->uv1_offset="uv1_offset";
+ shader_names->uv2_scale="uv2_scale";
+ shader_names->uv2_offset="uv2_offset";
+
+ shader_names->texture_names[TEXTURE_ALBEDO]="texture_albedo";
+ shader_names->texture_names[TEXTURE_SPECULAR]="texture_specular";
+ shader_names->texture_names[TEXTURE_EMISSION]="texture_emission";
+ shader_names->texture_names[TEXTURE_NORMAL]="texture_normal";
+ shader_names->texture_names[TEXTURE_RIM]="texture_rim";
+ shader_names->texture_names[TEXTURE_CLEARCOAT]="texture_clearcoat";
+ shader_names->texture_names[TEXTURE_FLOWMAP]="texture_flowmap";
+ shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION]="texture_ambient_occlusion";
+ shader_names->texture_names[TEXTURE_HEIGHT]="texture_height";
+ shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING]="texture_subsurface_scattering";
+ shader_names->texture_names[TEXTURE_REFRACTION]="texture_refraction";
+ shader_names->texture_names[TEXTURE_REFRACTION_ROUGHNESS]="texture_refraction_roughness";
+ shader_names->texture_names[TEXTURE_DETAIL_MASK]="texture_detail_mask";
+ shader_names->texture_names[TEXTURE_DETAIL_ALBEDO]="texture_detail_albedo";
+ shader_names->texture_names[TEXTURE_DETAIL_NORMAL]="texture_detail_normal";
+
}
+void FixedSpatialMaterial::finish_shaders(){
-void Material::set_blend_mode(BlendMode p_blend_mode) {
+#ifndef NO_THREADS
+ memdelete( material_mutex );
+#endif
+
+ memdelete( shader_names );
- ERR_FAIL_INDEX(p_blend_mode,4);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->material_set_blend_mode(material,(VS::MaterialBlendMode)p_blend_mode);
- _change_notify();
}
-Material::BlendMode Material::get_blend_mode() const {
- return blend_mode;
+
+void FixedSpatialMaterial::_update_shader() {
+
+ dirty_materials.remove( &element );
+
+ MaterialKey mk = _compute_key();
+ if (mk.key==current_key.key)
+ return; //no update required in the end
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users==0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+ }
+
+ current_key=mk;
+
+ if (shader_map.has(mk)) {
+
+ VS::get_singleton()->material_set_shader(_get_material(),shader_map[mk].shader);
+ shader_map[mk].users++;
+ return;
+ }
+
+ //must create a shader!
+
+ String code="render_mode ";
+ switch(blend_mode) {
+ case BLEND_MODE_MIX: code+="blend_mix"; break;
+ case BLEND_MODE_ADD: code+="blend_add"; break;
+ case BLEND_MODE_SUB: code+="blend_sub"; break;
+ case BLEND_MODE_MUL: code+="blend_mul"; break;
+ }
+
+ switch(depth_draw_mode) {
+ case DEPTH_DRAW_OPAQUE_ONLY: code+=",depth_draw_opaque"; break;
+ case DEPTH_DRAW_ALWAYS: code+=",depth_draw_always"; break;
+ case DEPTH_DRAW_DISABLED: code+=",depth_draw_never"; break;
+ case DEPTH_DRAW_ALPHA_OPAQUE_PREPASS: code+=",depth_draw_alpha_prepass"; break;
+ }
+
+ switch(cull_mode) {
+ case CULL_BACK: code+=",cull_back"; break;
+ case CULL_FRONT: code+=",cull_front"; break;
+ case CULL_DISABLED: code+=",cull_disabled"; break;
+
+ }
+
+ if (flags[FLAG_UNSHADED]) {
+ code+=",unshaded";
+ }
+ if (flags[FLAG_ONTOP]) {
+ code+=",ontop";
+ }
+
+ code+=";\n";
+
+
+ code+="uniform vec4 albedo : hint_color;\n";
+ code+="uniform sampler2D texture_albedo : hint_albedo;\n";
+ if (specular_mode==SPECULAR_MODE_SPECULAR) {
+ code+="uniform vec4 specular : hint_color;\n";
+ } else {
+ code+="uniform float metalness;\n";
+ }
+
+ code+="uniform float roughness : hint_range(0,1);\n";
+ code+="uniform float point_size : hint_range(0,128);\n";
+ code+="uniform sampler2D texture_specular : hint_white;\n";
+ code+="uniform vec2 uv1_scale;\n";
+ code+="uniform vec2 uv1_offset;\n";
+ code+="uniform vec2 uv2_scale;\n";
+ code+="uniform vec2 uv2_offset;\n";
+
+ if (features[FEATURE_EMISSION]) {
+
+ code+="uniform sampler2D texture_emission : hint_black_albedo;\n";
+ code+="uniform vec4 emission : hint_color;\n";
+ code+="uniform float emission_energy;\n";
+ }
+
+ if (features[FEATURE_NORMAL_MAPPING]) {
+ code+="uniform sampler2D texture_normal : hint_normal;\n";
+ code+="uniform float normal_scale : hint_range(-16,16);\n";
+ }
+ if (features[FEATURE_RIM]) {
+ code+="uniform float rim : hint_range(0,1);\n";
+ code+="uniform float rim_tint : hint_range(0,1);\n";
+ code+="uniform sampler2D texture_rim : hint_white;\n";
+ }
+ if (features[FEATURE_CLEARCOAT]) {
+ code+="uniform float clearcoat : hint_range(0,1);\n";
+ code+="uniform float clearcoat_gloss : hint_range(0,1);\n";
+ code+="uniform sampler2D texture_clearcoat : hint_white;\n";
+ }
+ if (features[FEATURE_ANISOTROPY]) {
+ code+="uniform float anisotropy_ratio : hint_range(0,256);\n";
+ code+="uniform sampler2D texture_flowmap : hint_aniso;\n";
+ }
+ if (features[FEATURE_AMBIENT_OCCLUSION]) {
+ code+="uniform sampler2D texture_ambient_occlusion : hint_white;\n";
+ }
+
+ if (features[FEATURE_DETAIL]) {
+ code+="uniform sampler2D texture_detail_albedo : hint_albedo;\n";
+ code+="uniform sampler2D texture_detail_normal : hint_normal;\n";
+ code+="uniform sampler2D texture_detail_mask : hint_white;\n";
+ }
+
+ if (features[FEATURE_SUBSURACE_SCATTERING]) {
+
+ code+="uniform float subsurface_scattering_strength : hint_range(0,1);\n";
+ code+="uniform sampler2D texture_subsurface_scattering : hint_white;\n";
+
+ }
+
+
+ code+="\n\n";
+
+ code+="void vertex() {\n";
+
+ if (flags[FLAG_SRGB_VERTEX_COLOR]) {
+
+ code+="\tCOLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) );\n";
+ }
+ if (flags[FLAG_USE_POINT_SIZE]) {
+
+ code+="\tPOINT_SIZE=point_size;\n";
+ }
+ code+="\tUV=UV*uv1_scale+uv1_offset;\n";
+ if (detail_uv==DETAIL_UV_2) {
+ code+="\tUV2=UV2*uv2_scale+uv2_offset;\n";
+ }
+
+ code+="}\n";
+ code+="\n\n";
+ code+="void fragment() {\n";
+
+ if (flags[FLAG_USE_POINT_SIZE]) {
+ code+="\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n";
+ } else {
+ code+="\tvec4 albedo_tex = texture(texture_albedo,UV);\n";
+ }
+
+ if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) {
+ code+="\talbedo_tex *= COLOR;\n";
+ }
+
+ code+="\tALBEDO = albedo.rgb * albedo_tex.rgb;\n";
+ if (features[FEATURE_TRANSPARENT]) {
+ code+="\tALPHA = albedo.a * albedo_tex.a;\n";
+ }
+
+ if (features[FEATURE_EMISSION]) {
+ code+="\tEMISSION = (emission.rgb+texture(texture_emission,UV).rgb)*emission_energy;\n";
+ }
+
+ if (features[FEATURE_NORMAL_MAPPING]) {
+ code+="\tNORMALMAP = texture(texture_normal,UV).rgb;\n";
+ code+="\tNORMALMAP_DEPTH = normal_scale;\n";
+ }
+
+ if (features[FEATURE_RIM]) {
+ code+="\tvec2 rim_tex = texture(texture_rim,UV).xw;\n";
+ code+="\tRIM = rim*rim_tex.x;";
+ code+="\tRIM_TINT = rim_tint*rim_tex.y;\n";
+ }
+
+ if (features[FEATURE_CLEARCOAT]) {
+ code+="\tvec2 clearcoat_tex = texture(texture_clearcoat,UV).xw;\n";
+ code+="\tCLEARCOAT = clearcoat*clearcoat_tex.x;";
+ code+="\tCLEARCOAT_GLOSS = clearcoat_gloss*clearcoat_tex.y;\n";
+ }
+
+ if (features[FEATURE_ANISOTROPY]) {
+ code+="\tvec4 anisotropy_tex = texture(texture_flowmap,UV);\n";
+ code+="\tANISOTROPY = anisotropy_ratio*anisotropy_tex.a;\n";
+ code+="\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n";
+ }
+
+ if (features[FEATURE_AMBIENT_OCCLUSION]) {
+ code+="\tAO = texture(texture_ambient_occlusion,UV).r;\n";
+ }
+
+ if (features[FEATURE_SUBSURACE_SCATTERING]) {
+
+ code+="\tfloat sss_tex = texture(texture_subsurface_scattering,UV).r;\n";
+ code+="\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n";
+ }
+
+ if (features[FEATURE_DETAIL]) {
+ String det_uv=detail_uv==DETAIL_UV_1?"UV":"UV2";
+ code+="\tvec4 detail_tex = texture(texture_detail_albedo,"+det_uv+");\n";
+ code+="\tvec4 detail_norm_tex = texture(texture_detail_normal,"+det_uv+");\n";
+ code+="\tvec4 detail_mask_tex = texture(texture_detail_mask,UV);\n";
+
+ switch(detail_blend_mode) {
+ case BLEND_MODE_MIX: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,detail_tex.rgb,detail_tex.a);\n";
+ } break;
+ case BLEND_MODE_ADD: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb+detail_tex.rgb,detail_tex.a);\n";
+ } break;
+ case BLEND_MODE_SUB: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb-detail_tex.rgb,detail_tex.a);\n";
+ } break;
+ case BLEND_MODE_MUL: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb*detail_tex.rgb,detail_tex.a);\n";
+ } break;
+
+ }
+
+ code+="\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n";
+
+ code+="\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n";
+ code+="\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n";
+ }
+
+ if (specular_mode==SPECULAR_MODE_SPECULAR) {
+
+ code+="\tvec4 specular_tex = texture(texture_specular,UV);\n";
+ code+="\tSPECULAR = specular.rgb * specular_tex.rgb;\n";
+ code+="\tROUGHNESS = specular_tex.a * roughness;\n";
+ } else {
+ code+="\tvec4 specular_tex = texture(texture_specular,UV);\n";
+ code+="\tSPECULAR = vec3(metalness * specular_tex.r);\n";
+ code+="\tROUGHNESS = specular_tex.a * roughness;\n";
+ }
+
+ code+="}\n";
+
+ ShaderData shader_data;
+ shader_data.shader = VS::get_singleton()->shader_create(VS::SHADER_SPATIAL);
+ shader_data.users=1;
+
+ VS::get_singleton()->shader_set_code( shader_data.shader, code );
+
+ shader_map[mk]=shader_data;
+
+ VS::get_singleton()->material_set_shader(_get_material(),shader_data.shader);
+
}
+void FixedSpatialMaterial::flush_changes() {
-void Material::set_depth_draw_mode(DepthDrawMode p_depth_draw_mode) {
+ if (material_mutex)
+ material_mutex->lock();
- depth_draw_mode=p_depth_draw_mode;
- VisualServer::get_singleton()->material_set_depth_draw_mode(material,(VS::MaterialDepthDrawMode)p_depth_draw_mode);
+ while (dirty_materials.first()) {
+
+ dirty_materials.first()->self()->_update_shader();
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
}
-Material::DepthDrawMode Material::get_depth_draw_mode() const {
+void FixedSpatialMaterial::_queue_shader_change() {
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (!element.in_list()) {
+ dirty_materials.add(&element);
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
+
- return depth_draw_mode;
}
-bool Material::get_flag(Flag p_flag) const {
+bool FixedSpatialMaterial::_is_shader_dirty() const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
- return flags[p_flag];
+ bool dirty=false;
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ dirty=element.in_list();
+
+ if (material_mutex)
+ material_mutex->unlock();
+
+ return dirty;
}
+void FixedSpatialMaterial::set_albedo(const Color& p_albedo) {
-void Material::set_line_width(float p_width) {
+ albedo=p_albedo;
- line_width=p_width;
- VisualServer::get_singleton()->material_set_line_width(material,p_width);
- _change_notify("line_width");
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->albedo,p_albedo);
}
-float Material::get_line_width() const {
+Color FixedSpatialMaterial::get_albedo() const{
- return line_width;
+ return albedo;
}
+void FixedSpatialMaterial::set_specular_mode(SpecularMode p_mode) {
+ specular_mode=p_mode;
+ _change_notify();
+ _queue_shader_change();
+}
-void Material::_bind_methods() {
+FixedSpatialMaterial::SpecularMode FixedSpatialMaterial::get_specular_mode() const {
- ObjectTypeDB::bind_method(_MD("set_flag","flag","enable"),&Material::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"),&Material::get_flag);
- ObjectTypeDB::bind_method(_MD("set_blend_mode","mode"),&Material::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&Material::get_blend_mode);
- ObjectTypeDB::bind_method(_MD("set_line_width","width"),&Material::set_line_width);
- ObjectTypeDB::bind_method(_MD("get_line_width"),&Material::get_line_width);
- ObjectTypeDB::bind_method(_MD("set_depth_draw_mode","mode"),&Material::set_depth_draw_mode);
- ObjectTypeDB::bind_method(_MD("get_depth_draw_mode"),&Material::get_depth_draw_mode);
+ return specular_mode;
+}
+void FixedSpatialMaterial::set_specular(const Color& p_specular){
- for(int i=0;i<FLAG_MAX;i++)
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, String()+"flags/"+_flag_names[i] ),_SCS("set_flag"),_SCS("get_flag"),_flag_indices[i]);
+ specular=p_specular;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->specular,p_specular);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,PMAlpha" ), _SCS("set_blend_mode"),_SCS("get_blend_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/depth_draw",PROPERTY_HINT_ENUM,"Always,Opaque Only,Pre-Pass Alpha,Never" ), _SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/line_width",PROPERTY_HINT_RANGE,"0.1,32.0,0.1" ), _SCS("set_line_width"),_SCS("get_line_width"));
+}
+Color FixedSpatialMaterial::get_specular() const{
- BIND_CONSTANT( FLAG_VISIBLE );
- BIND_CONSTANT( FLAG_DOUBLE_SIDED );
- BIND_CONSTANT( FLAG_INVERT_FACES );
- BIND_CONSTANT( FLAG_UNSHADED );
- BIND_CONSTANT( FLAG_ONTOP );
- BIND_CONSTANT( FLAG_LIGHTMAP_ON_UV2 );
- BIND_CONSTANT( FLAG_COLOR_ARRAY_SRGB );
- BIND_CONSTANT( FLAG_MAX );
+ return specular;
+}
- BIND_CONSTANT( DEPTH_DRAW_ALWAYS );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_ONLY );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA );
- BIND_CONSTANT( DEPTH_DRAW_NEVER );
+void FixedSpatialMaterial::set_roughness(float p_roughness){
- 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 );
+ roughness=p_roughness;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->roughness,p_roughness);
}
-Material::Material(const RID& p_material) {
- material=p_material;
+float FixedSpatialMaterial::get_roughness() const{
- flags[FLAG_VISIBLE]=true;
- flags[FLAG_DOUBLE_SIDED]=false;
- flags[FLAG_INVERT_FACES]=false;
- flags[FLAG_UNSHADED]=false;
- flags[FLAG_ONTOP]=false;
- flags[FLAG_LIGHTMAP_ON_UV2]=true;
- flags[FLAG_COLOR_ARRAY_SRGB]=false;
+ return roughness;
+}
- depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
+void FixedSpatialMaterial::set_metalness(float p_metalness){
- blend_mode=BLEND_MODE_MIX;
+ metalness=p_metalness;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->metalness,p_metalness);
+}
+
+float FixedSpatialMaterial::get_metalness() const{
+
+ return metalness;
}
-Material::~Material() {
+void FixedSpatialMaterial::set_emission(const Color& p_emission){
+
+ emission=p_emission;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->emission,p_emission);
- VisualServer::get_singleton()->free(material);
}
+Color FixedSpatialMaterial::get_emission() const{
-static const char*_param_names[FixedMaterial::PARAM_MAX]={
- "diffuse",
- "detail",
- "specular",
- "emission",
- "specular_exp",
- "glow",
- "normal",
- "shade_param"
-};
-
-static const char*_full_param_names[FixedMaterial::PARAM_MAX]={
- "params/diffuse",
- "params/detail",
- "params/specular",
- "params/emission",
- "params/specular_exp",
- "params/glow",
- "params/normal",
- "params/shade_param"
-};
-
-/*
-static const char*_texture_param_names[FixedMaterial::PARAM_MAX]={
- "tex_diffuse",
- "tex_detail",
- "tex_specular",
- "tex_emission",
- "tex_specular_exp",
- "tex_glow",
- "tex_detail_mix",
- "tex_normal",
- "tex_shade_param"
-};
-*/
-static const FixedMaterial::Parameter _param_indices[FixedMaterial::PARAM_MAX]={
- FixedMaterial::PARAM_DIFFUSE,
- FixedMaterial::PARAM_DETAIL,
- FixedMaterial::PARAM_SPECULAR,
- FixedMaterial::PARAM_EMISSION,
- FixedMaterial::PARAM_SPECULAR_EXP,
- FixedMaterial::PARAM_GLOW,
- FixedMaterial::PARAM_NORMAL,
- FixedMaterial::PARAM_SHADE_PARAM,
-};
-
-
-
-
-void FixedMaterial::set_parameter(Parameter p_parameter, const Variant& p_value) {
-
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- if ((p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION)) {
-
- if (p_value.get_type()!=Variant::COLOR) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects Color");
- ERR_FAIL();
- }
- } else {
+ return emission;
+}
- if (!p_value.is_num()) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects scalar");
- ERR_FAIL();
- }
- }
- ERR_FAIL_COND( (p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION) && p_value.get_type()!=Variant::COLOR );
- ERR_FAIL_COND( p_parameter!=PARAM_SHADE_PARAM && p_parameter!=PARAM_DIFFUSE && p_parameter!=PARAM_DETAIL && p_parameter!=PARAM_SPECULAR && p_parameter!=PARAM_EMISSION && p_value.get_type()!=Variant::REAL && p_value.get_type()!=Variant::INT );
+void FixedSpatialMaterial::set_emission_energy(float p_emission_energy){
- param[p_parameter]=p_value;
+ emission_energy=p_emission_energy;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->emission_energy,p_emission_energy);
- VisualServer::get_singleton()->fixed_material_set_param(material,(VS::FixedMaterialParam)p_parameter,p_value);
+}
+float FixedSpatialMaterial::get_emission_energy() const{
- _change_notify(_full_param_names[p_parameter]);
+ return emission_energy;
}
-Variant FixedMaterial::get_parameter(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Variant());
- return param[p_parameter];
+void FixedSpatialMaterial::set_normal_scale(float p_normal_scale){
+
+ normal_scale=p_normal_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->normal_scale,p_normal_scale);
+
}
+float FixedSpatialMaterial::get_normal_scale() const{
+ return normal_scale;
+}
+void FixedSpatialMaterial::set_rim(float p_rim){
-void FixedMaterial::set_texture(Parameter p_parameter, Ref<Texture> p_texture) {
+ rim=p_rim;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->rim,p_rim);
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- texture_param[p_parameter]=p_texture;
- VisualServer::get_singleton()->fixed_material_set_texture(material,(VS::FixedMaterialParam)p_parameter,p_texture.is_null()?RID():p_texture->get_rid());
+}
+float FixedSpatialMaterial::get_rim() const{
- _change_notify();
+ return rim;
}
-Ref<Texture> FixedMaterial::get_texture(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Ref<Texture>());
- return texture_param[p_parameter];
+void FixedSpatialMaterial::set_rim_tint(float p_rim_tint){
+
+ rim_tint=p_rim_tint;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->rim_tint,p_rim_tint);
+
}
+float FixedSpatialMaterial::get_rim_tint() const{
-void FixedMaterial::set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode) {
+ return rim_tint;
+}
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- ERR_FAIL_INDEX(p_mode,4);
+void FixedSpatialMaterial::set_clearcoat(float p_clearcoat){
- if (p_mode==texture_texcoord[p_parameter])
- return;
+ clearcoat=p_clearcoat;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->clearcoat,p_clearcoat);
- texture_texcoord[p_parameter]=p_mode;
+}
- VisualServer::get_singleton()->fixed_material_set_texcoord_mode(material,(VS::FixedMaterialParam)p_parameter,(VS::FixedMaterialTexCoordMode)p_mode);
+float FixedSpatialMaterial::get_clearcoat() const{
- _change_notify();
+ return clearcoat;
}
-FixedMaterial::TexCoordMode FixedMaterial::get_texcoord_mode(Parameter p_parameter) const {
+void FixedSpatialMaterial::set_clearcoat_gloss(float p_clearcoat_gloss){
+
+ clearcoat_gloss=p_clearcoat_gloss;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->clearcoat_gloss,p_clearcoat_gloss);
+
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,TEXCOORD_UV);
- return texture_texcoord[p_parameter];
}
-void FixedMaterial::set_light_shader(LightShader p_shader) {
+float FixedSpatialMaterial::get_clearcoat_gloss() const{
- light_shader=p_shader;
- VS::get_singleton()->fixed_material_set_light_shader(material,VS::FixedMaterialLightShader(p_shader));
+ return clearcoat_gloss;
}
-FixedMaterial::LightShader FixedMaterial::get_light_shader() const {
+void FixedSpatialMaterial::set_anisotropy(float p_anisotropy){
+
+ anisotropy=p_anisotropy;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->anisotropy,p_anisotropy);
- return light_shader;
}
+float FixedSpatialMaterial::get_anisotropy() const{
+ return anisotropy;
+}
+
+void FixedSpatialMaterial::set_height_scale(float p_height_scale){
+
+ height_scale=p_height_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->height_scale,p_height_scale);
-void FixedMaterial::set_uv_transform(const Transform& p_transform) {
- uv_transform=p_transform;
- VisualServer::get_singleton()->fixed_material_set_uv_transform(material, p_transform );
- _change_notify();
}
-Transform FixedMaterial::get_uv_transform() const {
+float FixedSpatialMaterial::get_height_scale() const{
- return uv_transform;
+ return height_scale;
}
+void FixedSpatialMaterial::set_subsurface_scattering_strength(float p_subsurface_scattering_strength){
+
+ subsurface_scattering_strength=p_subsurface_scattering_strength;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->subsurface_scattering_strength,subsurface_scattering_strength);
+}
-void FixedMaterial::set_fixed_flag(FixedFlag p_flag, bool p_value) {
- ERR_FAIL_INDEX(p_flag,5);
- fixed_flags[p_flag]=p_value;
- VisualServer::get_singleton()->fixed_material_set_flag(material,(VS::FixedMaterialFlags)p_flag,p_value);
+float FixedSpatialMaterial::get_subsurface_scattering_strength() const{
+ return subsurface_scattering_strength;
}
-bool FixedMaterial::get_fixed_flag(FixedFlag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,5,false);
- return fixed_flags[p_flag];
+void FixedSpatialMaterial::set_refraction(float p_refraction){
+
+ refraction=p_refraction;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->refraction,refraction);
+
}
-void FixedMaterial::set_point_size(float p_size) {
+float FixedSpatialMaterial::get_refraction() const {
- ERR_FAIL_COND(p_size<0);
- point_size=p_size;
- VisualServer::get_singleton()->fixed_material_set_point_size(material,p_size);
+ return refraction;
}
-float FixedMaterial::get_point_size() const{
+void FixedSpatialMaterial::set_refraction_roughness(float p_refraction_roughness) {
+ refraction_roughness=p_refraction_roughness;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->refraction_roughness,refraction_roughness);
- return point_size;
+
+}
+float FixedSpatialMaterial::get_refraction_roughness() const {
+
+ return refraction_roughness;
}
+void FixedSpatialMaterial::set_detail_uv(DetailUV p_detail_uv) {
+
+ if (detail_uv==p_detail_uv)
+ return;
+
+ detail_uv=p_detail_uv;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::DetailUV FixedSpatialMaterial::get_detail_uv() const {
-void FixedMaterial::_bind_methods() {
+ return detail_uv;
+}
+void FixedSpatialMaterial::set_blend_mode(BlendMode p_mode) {
- ObjectTypeDB::bind_method(_MD("set_parameter","param","value"),&FixedMaterial::set_parameter);
- ObjectTypeDB::bind_method(_MD("get_parameter","param"),&FixedMaterial::get_parameter);
+ if (blend_mode==p_mode)
+ return;
- ObjectTypeDB::bind_method(_MD("set_texture","param","texture:Texture"),&FixedMaterial::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","param"),&FixedMaterial::get_texture);
+ blend_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::BlendMode FixedSpatialMaterial::get_blend_mode() const {
+ return blend_mode;
+}
- ObjectTypeDB::bind_method(_MD("set_texcoord_mode","param","mode"),&FixedMaterial::set_texcoord_mode);
- ObjectTypeDB::bind_method(_MD("get_texcoord_mode","param"),&FixedMaterial::get_texcoord_mode);
+void FixedSpatialMaterial::set_detail_blend_mode(BlendMode p_mode) {
- ObjectTypeDB::bind_method(_MD("set_fixed_flag","flag","value"),&FixedMaterial::set_fixed_flag);
- ObjectTypeDB::bind_method(_MD("get_fixed_flag","flag"),&FixedMaterial::get_fixed_flag);
+ detail_blend_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::BlendMode FixedSpatialMaterial::get_detail_blend_mode() const {
- ObjectTypeDB::bind_method(_MD("set_uv_transform","transform"),&FixedMaterial::set_uv_transform);
- ObjectTypeDB::bind_method(_MD("get_uv_transform"),&FixedMaterial::get_uv_transform);
+ return detail_blend_mode;
+}
- ObjectTypeDB::bind_method(_MD("set_light_shader","shader"),&FixedMaterial::set_light_shader);
- ObjectTypeDB::bind_method(_MD("get_light_shader"),&FixedMaterial::get_light_shader);
+void FixedSpatialMaterial::set_depth_draw_mode(DepthDrawMode p_mode) {
- ObjectTypeDB::bind_method(_MD("set_point_size","size"),&FixedMaterial::set_point_size);
- ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedMaterial::get_point_size);
+ if (depth_draw_mode==p_mode)
+ return;
+ depth_draw_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::DepthDrawMode FixedSpatialMaterial::get_depth_draw_mode() const {
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_color_array" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_COLOR_ARRAY);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_point_size" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_POINT_SIZE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/discard_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_DISCARD_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_xy_normalmap" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_XY_NORMALMAP);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/diffuse" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/specular", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/emission", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_EMISSION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/specular_exp", PROPERTY_HINT_RANGE,"1,64,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR_EXP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/detail_mix", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DETAIL );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/normal_depth", PROPERTY_HINT_RANGE,"-4,4,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_NORMAL );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/shader", PROPERTY_HINT_ENUM,"Lambert,Wrap,Velvet,Toon" ), _SCS("set_light_shader"), _SCS("get_light_shader") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/shader_param", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADE_PARAM );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/glow", PROPERTY_HINT_RANGE,"0,8,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_GLOW );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/point_size", PROPERTY_HINT_RANGE,"0,1024,1" ), _SCS("set_point_size"), _SCS("get_point_size"));
- ADD_PROPERTY( PropertyInfo( Variant::TRANSFORM, "uv_xform"), _SCS("set_uv_transform"), _SCS("get_uv_transform") );
+ return depth_draw_mode;
+}
- for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYI( PropertyInfo( Variant::OBJECT, String()+"textures/"+_param_names[i],PROPERTY_HINT_RESOURCE_TYPE,"Texture" ), _SCS("set_texture"), _SCS("get_texture"), _param_indices[i]);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, String()+"textures/"+_param_names[i]+"_tc",PROPERTY_HINT_ENUM,"UV,UV Xform,UV2,Sphere" ), _SCS("set_texcoord_mode"), _SCS("get_texcoord_mode"), _param_indices[i] );
- }
+void FixedSpatialMaterial::set_cull_mode(CullMode p_mode) {
+ if (cull_mode==p_mode)
+ return;
- BIND_CONSTANT( PARAM_DIFFUSE );
- BIND_CONSTANT( PARAM_DETAIL );
- BIND_CONSTANT( PARAM_SPECULAR );
- BIND_CONSTANT( PARAM_EMISSION );
- BIND_CONSTANT( PARAM_SPECULAR_EXP );
- BIND_CONSTANT( PARAM_GLOW );
- BIND_CONSTANT( PARAM_NORMAL );
- BIND_CONSTANT( PARAM_SHADE_PARAM );
- BIND_CONSTANT( PARAM_MAX );
+ cull_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::CullMode FixedSpatialMaterial::get_cull_mode() const {
- BIND_CONSTANT( TEXCOORD_UV );
- BIND_CONSTANT( TEXCOORD_UV_TRANSFORM );
- BIND_CONSTANT( TEXCOORD_UV2 );
- BIND_CONSTANT( TEXCOORD_SPHERE );
+ return cull_mode;
+}
- BIND_CONSTANT( FLAG_USE_ALPHA );
- BIND_CONSTANT( FLAG_USE_COLOR_ARRAY );
- BIND_CONSTANT( FLAG_USE_POINT_SIZE );
- BIND_CONSTANT( FLAG_DISCARD_ALPHA );
+void FixedSpatialMaterial::set_diffuse_mode(DiffuseMode p_mode) {
- BIND_CONSTANT( LIGHT_SHADER_LAMBERT );
- BIND_CONSTANT( LIGHT_SHADER_WRAP );
- BIND_CONSTANT( LIGHT_SHADER_VELVET );
- BIND_CONSTANT( LIGHT_SHADER_TOON );
+ if (diffuse_mode==p_mode)
+ return;
+ diffuse_mode=p_mode;
+ _queue_shader_change();
}
+FixedSpatialMaterial::DiffuseMode FixedSpatialMaterial::get_diffuse_mode() const {
+ return diffuse_mode;
+}
-FixedMaterial::FixedMaterial() : Material(VS::get_singleton()->fixed_material_create()) {
+void FixedSpatialMaterial::set_flag(Flags p_flag,bool p_enabled) {
+ ERR_FAIL_INDEX(p_flag,FLAG_MAX);
+ if (flags[p_flag]==p_enabled)
+ return;
- param[PARAM_DIFFUSE]=Color(1,1,1);
- param[PARAM_SPECULAR]=Color(0.0,0.0,0.0);
- param[PARAM_EMISSION]=Color(0.0,0.0,0.0);
- param[PARAM_SPECULAR_EXP]=40;
- param[PARAM_GLOW]=0;
- param[PARAM_NORMAL]=1;
- param[PARAM_SHADE_PARAM]=0.5;
- param[PARAM_DETAIL]=1.0;
+ flags[p_flag]=p_enabled;
+ _queue_shader_change();
+}
- set_flag(FLAG_COLOR_ARRAY_SRGB,true);
+bool FixedSpatialMaterial::get_flag(Flags p_flag) const {
- fixed_flags[FLAG_USE_ALPHA]=false;
- fixed_flags[FLAG_USE_COLOR_ARRAY]=false;
- fixed_flags[FLAG_USE_POINT_SIZE]=false;
- fixed_flags[FLAG_USE_XY_NORMALMAP]=false;
- fixed_flags[FLAG_DISCARD_ALPHA]=false;
+ ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ return flags[p_flag];
+}
+void FixedSpatialMaterial::set_feature(Feature p_feature,bool p_enabled) {
- for(int i=0;i<PARAM_MAX;i++) {
+ ERR_FAIL_INDEX(p_feature,FEATURE_MAX);
+ if (features[p_feature]==p_enabled)
+ return;
- texture_texcoord[i]=TEXCOORD_UV;
- }
+ features[p_feature]=p_enabled;
+ _change_notify();
+ _queue_shader_change();
- light_shader=LIGHT_SHADER_LAMBERT;
- point_size=1.0;
}
+bool FixedSpatialMaterial::get_feature(Feature p_feature) const {
-FixedMaterial::~FixedMaterial() {
-
+ ERR_FAIL_INDEX_V(p_feature,FEATURE_MAX,false);
+ return features[p_feature];
}
+void FixedSpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_texture) {
-bool ShaderMaterial::_set(const StringName& p_name, const Variant& p_value) {
+ ERR_FAIL_INDEX(p_param,TEXTURE_MAX);
+ textures[p_param]=p_texture;
+ RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->texture_names[p_param],rid);
+}
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
- set_shader(p_value);
- return true;
- } else {
+Ref<Texture> FixedSpatialMaterial::get_texture(TextureParam p_param) const {
- if (shader.is_valid()) {
+ ERR_FAIL_INDEX_V(p_param,TEXTURE_MAX,Ref<Texture>());
+ return textures[p_param];
+}
- StringName pr = shader->remap_param(p_name);
- if (!pr) {
- String n = p_name;
- if (n.find("param/")==0) { //backwards compatibility
- pr = n.substr(6,n.length());
- }
- }
- if (pr) {
- VisualServer::get_singleton()->material_set_param(material,pr,p_value);
- return true;
- }
- }
+void FixedSpatialMaterial::_validate_feature(const String& text, Feature feature,PropertyInfo& property) const {
+ if (property.name.begins_with(text) && property.name!=text+"/enabled" && !features[feature]) {
+ property.usage=0;
}
- return false;
}
-bool ShaderMaterial::_get(const StringName& p_name,Variant &r_ret) const {
-
+void FixedSpatialMaterial::_validate_property(PropertyInfo& property) const {
+ _validate_feature("normal",FEATURE_NORMAL_MAPPING,property);
+ _validate_feature("emission",FEATURE_EMISSION,property);
+ _validate_feature("rim",FEATURE_RIM,property);
+ _validate_feature("clearcoat",FEATURE_CLEARCOAT,property);
+ _validate_feature("anisotropy",FEATURE_ANISOTROPY,property);
+ _validate_feature("ao",FEATURE_AMBIENT_OCCLUSION,property);
+ _validate_feature("height",FEATURE_HEIGHT_MAPPING,property);
+ _validate_feature("subsurf_scatter",FEATURE_SUBSURACE_SCATTERING,property);
+ _validate_feature("refraction",FEATURE_REFRACTION,property);
+ _validate_feature("detail",FEATURE_DETAIL,property);
+
+ if (property.name=="specular/color" && specular_mode==SPECULAR_MODE_METALLIC) {
+ property.usage=0;
+ }
+ if (property.name=="specular/metalness" && specular_mode==SPECULAR_MODE_SPECULAR) {
+ property.usage=0;
+ }
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+}
- r_ret=get_shader();
- return true;
- } else {
+void FixedSpatialMaterial::set_line_width(float p_line_width) {
- if (shader.is_valid()) {
+ line_width=p_line_width;
+ VS::get_singleton()->material_set_line_width(_get_material(),line_width);
+}
- StringName pr = shader->remap_param(p_name);
- if (pr) {
- r_ret=VisualServer::get_singleton()->material_get_param(material,pr);
- return true;
- }
- }
+float FixedSpatialMaterial::get_line_width() const {
- }
+ return line_width;
+}
+void FixedSpatialMaterial::set_point_size(float p_point_size) {
- return false;
+ point_size=p_point_size;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->point_size,p_point_size);
}
+float FixedSpatialMaterial::get_point_size() const {
-void ShaderMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
+ return point_size;
+}
- p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"MaterialShader,MaterialShaderGraph" ) );
- if (!shader.is_null()) {
+void FixedSpatialMaterial::set_uv1_scale(const Vector2& p_scale) {
- shader->get_param_list(p_list);
- }
+ uv1_scale=p_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv1_scale,p_scale);
+}
+
+Vector2 FixedSpatialMaterial::get_uv1_scale() const{
+ return uv1_scale;
}
+void FixedSpatialMaterial::set_uv1_offset(const Vector2& p_offset){
-void ShaderMaterial::_shader_changed() {
+ uv1_offset=p_offset;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv1_offset,p_offset);
- _change_notify(); //also all may have changed then
}
+Vector2 FixedSpatialMaterial::get_uv1_offset() const{
-void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) {
+ return uv1_offset;
+}
- ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL);
- if (shader.is_valid())
- shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- shader=p_shader;
- VS::get_singleton()->material_set_shader(material,shader.is_valid()?shader->get_rid():RID());
- if (shader.is_valid()) {
- shader->connect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- }
- _change_notify();
+void FixedSpatialMaterial::set_uv2_scale(const Vector2& p_scale) {
+ uv2_scale=p_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv2_scale,p_scale);
}
-Ref<Shader> ShaderMaterial::get_shader() const {
+Vector2 FixedSpatialMaterial::get_uv2_scale() const{
- return shader;
+ return uv2_scale;
}
+void FixedSpatialMaterial::set_uv2_offset(const Vector2& p_offset){
-void ShaderMaterial::set_shader_param(const StringName& p_param,const Variant& p_value) {
-
- VisualServer::get_singleton()->material_set_param(material,p_param,p_value);
+ uv2_offset=p_offset;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv2_offset,p_offset);
}
-Variant ShaderMaterial::get_shader_param(const StringName& p_param) const{
+Vector2 FixedSpatialMaterial::get_uv2_offset() const{
- return VisualServer::get_singleton()->material_get_param(material,p_param);
+ return uv2_offset;
}
+void FixedSpatialMaterial::_bind_methods() {
-void ShaderMaterial::_bind_methods() {
+ ClassDB::bind_method(_MD("set_albedo","albedo"),&FixedSpatialMaterial::set_albedo);
+ ClassDB::bind_method(_MD("get_albedo"),&FixedSpatialMaterial::get_albedo);
- ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"), &ShaderMaterial::set_shader );
- ObjectTypeDB::bind_method(_MD("get_shader:Shader"), &ShaderMaterial::get_shader );
+ ClassDB::bind_method(_MD("set_specular_mode","specular_mode"),&FixedSpatialMaterial::set_specular_mode);
+ ClassDB::bind_method(_MD("get_specular_mode"),&FixedSpatialMaterial::get_specular_mode);
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value:Variant"), &ShaderMaterial::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param:Variant","param"), &ShaderMaterial::get_shader_param);
+ ClassDB::bind_method(_MD("set_specular","specular"),&FixedSpatialMaterial::set_specular);
+ ClassDB::bind_method(_MD("get_specular"),&FixedSpatialMaterial::get_specular);
- ObjectTypeDB::bind_method(_MD("_shader_changed"), &ShaderMaterial::_shader_changed );
-}
+ ClassDB::bind_method(_MD("set_metalness","metalness"),&FixedSpatialMaterial::set_metalness);
+ ClassDB::bind_method(_MD("get_metalness"),&FixedSpatialMaterial::get_metalness);
+ ClassDB::bind_method(_MD("set_roughness","roughness"),&FixedSpatialMaterial::set_roughness);
+ ClassDB::bind_method(_MD("get_roughness"),&FixedSpatialMaterial::get_roughness);
-void ShaderMaterial::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+ ClassDB::bind_method(_MD("set_emission","emission"),&FixedSpatialMaterial::set_emission);
+ ClassDB::bind_method(_MD("get_emission"),&FixedSpatialMaterial::get_emission);
- String f = p_function.operator String();
- if ((f=="get_shader_param" || f=="set_shader_param") && p_idx==0) {
+ ClassDB::bind_method(_MD("set_emission_energy","emission_energy"),&FixedSpatialMaterial::set_emission_energy);
+ ClassDB::bind_method(_MD("get_emission_energy"),&FixedSpatialMaterial::get_emission_energy);
+
+ ClassDB::bind_method(_MD("set_normal_scale","normal_scale"),&FixedSpatialMaterial::set_normal_scale);
+ ClassDB::bind_method(_MD("get_normal_scale"),&FixedSpatialMaterial::get_normal_scale);
+
+ ClassDB::bind_method(_MD("set_rim","rim"),&FixedSpatialMaterial::set_rim);
+ ClassDB::bind_method(_MD("get_rim"),&FixedSpatialMaterial::get_rim);
+
+ ClassDB::bind_method(_MD("set_rim_tint","rim_tint"),&FixedSpatialMaterial::set_rim_tint);
+ ClassDB::bind_method(_MD("get_rim_tint"),&FixedSpatialMaterial::get_rim_tint);
+
+ ClassDB::bind_method(_MD("set_clearcoat","clearcoat"),&FixedSpatialMaterial::set_clearcoat);
+ ClassDB::bind_method(_MD("get_clearcoat"),&FixedSpatialMaterial::get_clearcoat);
+
+ ClassDB::bind_method(_MD("set_clearcoat_gloss","clearcoat_gloss"),&FixedSpatialMaterial::set_clearcoat_gloss);
+ ClassDB::bind_method(_MD("get_clearcoat_gloss"),&FixedSpatialMaterial::get_clearcoat_gloss);
+
+ ClassDB::bind_method(_MD("set_anisotropy","anisotropy"),&FixedSpatialMaterial::set_anisotropy);
+ ClassDB::bind_method(_MD("get_anisotropy"),&FixedSpatialMaterial::get_anisotropy);
+
+ ClassDB::bind_method(_MD("set_height_scale","height_scale"),&FixedSpatialMaterial::set_height_scale);
+ ClassDB::bind_method(_MD("get_height_scale"),&FixedSpatialMaterial::get_height_scale);
+
+ ClassDB::bind_method(_MD("set_subsurface_scattering_strength","strength"),&FixedSpatialMaterial::set_subsurface_scattering_strength);
+ ClassDB::bind_method(_MD("get_subsurface_scattering_strength"),&FixedSpatialMaterial::get_subsurface_scattering_strength);
+
+ ClassDB::bind_method(_MD("set_refraction","refraction"),&FixedSpatialMaterial::set_refraction);
+ ClassDB::bind_method(_MD("get_refraction"),&FixedSpatialMaterial::get_refraction);
+
+ ClassDB::bind_method(_MD("set_refraction_roughness","refraction_roughness"),&FixedSpatialMaterial::set_refraction_roughness);
+ ClassDB::bind_method(_MD("get_refraction_roughness"),&FixedSpatialMaterial::get_refraction_roughness);
+
+ ClassDB::bind_method(_MD("set_line_width","line_width"),&FixedSpatialMaterial::set_line_width);
+ ClassDB::bind_method(_MD("get_line_width"),&FixedSpatialMaterial::get_line_width);
+
+ ClassDB::bind_method(_MD("set_point_size","point_size"),&FixedSpatialMaterial::set_point_size);
+ ClassDB::bind_method(_MD("get_point_size"),&FixedSpatialMaterial::get_point_size);
+
+ ClassDB::bind_method(_MD("set_detail_uv","detail_uv"),&FixedSpatialMaterial::set_detail_uv);
+ ClassDB::bind_method(_MD("get_detail_uv"),&FixedSpatialMaterial::get_detail_uv);
+
+ ClassDB::bind_method(_MD("set_blend_mode","blend_mode"),&FixedSpatialMaterial::set_blend_mode);
+ ClassDB::bind_method(_MD("get_blend_mode"),&FixedSpatialMaterial::get_blend_mode);
+
+ ClassDB::bind_method(_MD("set_depth_draw_mode","depth_draw_mode"),&FixedSpatialMaterial::set_depth_draw_mode);
+ ClassDB::bind_method(_MD("get_depth_draw_mode"),&FixedSpatialMaterial::get_depth_draw_mode);
+
+ ClassDB::bind_method(_MD("set_cull_mode","cull_mode"),&FixedSpatialMaterial::set_cull_mode);
+ ClassDB::bind_method(_MD("get_cull_mode"),&FixedSpatialMaterial::get_cull_mode);
+
+ ClassDB::bind_method(_MD("set_diffuse_mode","diffuse_mode"),&FixedSpatialMaterial::set_diffuse_mode);
+ ClassDB::bind_method(_MD("get_diffuse_mode"),&FixedSpatialMaterial::get_diffuse_mode);
+
+ ClassDB::bind_method(_MD("set_flag","flag","enable"),&FixedSpatialMaterial::set_flag);
+ ClassDB::bind_method(_MD("get_flag"),&FixedSpatialMaterial::get_flag);
+
+ ClassDB::bind_method(_MD("set_feature","feature","enable"),&FixedSpatialMaterial::set_feature);
+ ClassDB::bind_method(_MD("get_feature","feature"),&FixedSpatialMaterial::get_feature);
+
+ ClassDB::bind_method(_MD("set_texture","param:Texture","texture"),&FixedSpatialMaterial::set_texture);
+ ClassDB::bind_method(_MD("get_texture:Texture","param:Texture"),&FixedSpatialMaterial::get_texture);
+
+ ClassDB::bind_method(_MD("set_detail_blend_mode","detail_blend_mode"),&FixedSpatialMaterial::set_detail_blend_mode);
+ ClassDB::bind_method(_MD("get_detail_blend_mode"),&FixedSpatialMaterial::get_detail_blend_mode);
+
+ ClassDB::bind_method(_MD("set_uv1_scale","scale"),&FixedSpatialMaterial::set_uv1_scale);
+ ClassDB::bind_method(_MD("get_uv1_scale"),&FixedSpatialMaterial::get_uv1_scale);
+
+ ClassDB::bind_method(_MD("set_uv1_offset","offset"),&FixedSpatialMaterial::set_uv1_offset);
+ ClassDB::bind_method(_MD("get_uv1_offset"),&FixedSpatialMaterial::get_uv1_offset);
+
+ ClassDB::bind_method(_MD("set_uv2_scale","scale"),&FixedSpatialMaterial::set_uv2_scale);
+ ClassDB::bind_method(_MD("get_uv2_scale"),&FixedSpatialMaterial::get_uv2_scale);
+
+ ClassDB::bind_method(_MD("set_uv2_offset","offset"),&FixedSpatialMaterial::set_uv2_offset);
+ ClassDB::bind_method(_MD("get_uv2_offset"),&FixedSpatialMaterial::get_uv2_offset);
+
+ ADD_GROUP("Flags","flags_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_transparent"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_TRANSPARENT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_unshaded"),_SCS("set_flag"),_SCS("get_flag"),FLAG_UNSHADED);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_on_top"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ONTOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_use_point_size"),_SCS("set_flag"),_SCS("get_flag"),FLAG_USE_POINT_SIZE);
+ ADD_GROUP("Vertex Color","vertex_color");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color_use_as_albedo"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ALBEDO_FROM_VERTEX_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color_is_srgb"),_SCS("set_flag"),_SCS("get_flag"),FLAG_SRGB_VERTEX_COLOR);
+
+ ADD_GROUP("Parameters","params_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params_diffuse_mode",PROPERTY_HINT_ENUM,"Labert,Lambert Wrap,Oren Nayar,Burley"),_SCS("set_diffuse_mode"),_SCS("get_diffuse_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params_blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_blend_mode"),_SCS("get_blend_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params_cull_mode",PROPERTY_HINT_ENUM,"Back,Front,Disabled"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params_depth_draw_mode",PROPERTY_HINT_ENUM,"Opaque Only,Always,Never,Opaque Pre-Pass"),_SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"params_line_width",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_line_width"),_SCS("get_line_width"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"params_point_size",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_point_size"),_SCS("get_point_size"));
+
+ ADD_GROUP("Albedo","albedo_");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"albedo_color"),_SCS("set_albedo"),_SCS("get_albedo"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"albedo_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_ALBEDO);
+
+ ADD_GROUP("Specular","specular_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"specular_mode",PROPERTY_HINT_ENUM,"Metallic,Specular"),_SCS("set_specular_mode"),_SCS("get_specular_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"specular_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_specular"),_SCS("get_specular"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular_metalness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_metalness"),_SCS("get_metalness"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular_roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_roughness"),_SCS("get_roughness"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"specular_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_SPECULAR);
+
+ ADD_GROUP("Emission","emission_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"emission_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_EMISSION);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"emission_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_emission"),_SCS("get_emission"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"emission_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_emission_energy"),_SCS("get_emission_energy"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"emission_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_EMISSION);
+
+ ADD_GROUP("NormapMap","normal_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"normal_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_NORMAL_MAPPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"normal_scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),_SCS("set_normal_scale"),_SCS("get_normal_scale"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"normal_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_NORMAL);
+
+ ADD_GROUP("Rim","rim_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"rim_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_RIM);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_rim"),_SCS("get_rim"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim_tint",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_rim_tint"),_SCS("get_rim_tint"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"rim_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_RIM);
+
+ ADD_GROUP("Clearcoat","clearcoat_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"clearcoat_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_CLEARCOAT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_clearcoat"),_SCS("get_clearcoat"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat_gloss",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_clearcoat_gloss"),_SCS("get_clearcoat_gloss"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"clearcoat_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_CLEARCOAT);
+
+ ADD_GROUP("Anisotropy","anisotropy_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"anisotropy_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_ANISOTROPY);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"anisotropy_anisotropy",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_anisotropy"),_SCS("get_anisotropy"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"anisotropy_flowmap",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_FLOWMAP);
+
+ ADD_GROUP("Ambient Occlusion","ao_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"ao_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_AMBIENT_OCCLUSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"ao_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_AMBIENT_OCCLUSION);
+
+ ADD_GROUP("Height","height_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"height_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_HEIGHT_MAPPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"height_scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),_SCS("set_height_scale"),_SCS("get_height_scale"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"height_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_HEIGHT);
+
+ ADD_GROUP("Subsurf Scatter","subsurf_scatter_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"subsurf_scatter_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_SUBSURACE_SCATTERING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"subsurf_scatter_strength",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_subsurface_scattering_strength"),_SCS("get_subsurface_scattering_strength"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"subsurf_scatter_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_SUBSURFACE_SCATTERING);
+
+ ADD_GROUP("Refraction","refraction_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"refraction_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_REFRACTION);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction_displacement",PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_refraction"),_SCS("get_refraction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction_roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_refraction_roughness"),_SCS("get_refraction_roughness"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"refraction_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_REFRACTION);
+
+ ADD_GROUP("Detail","detail_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"detail_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_DETAIL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_mask",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_MASK);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"detail_blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_detail_blend_mode"),_SCS("get_detail_blend_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"detail_uv_layer",PROPERTY_HINT_ENUM,"UV1,UV2"),_SCS("set_detail_uv"),_SCS("get_detail_uv"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_albedo",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_ALBEDO);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_NORMAL);
+
+ ADD_GROUP("UV1","uv1_");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv1_scale"),_SCS("set_uv1_scale"),_SCS("get_uv1_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv1_offset"),_SCS("set_uv1_offset"),_SCS("get_uv1_offset"));
+
+ ADD_GROUP("UV2","uv2_");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv2_scale"),_SCS("set_uv2_scale"),_SCS("get_uv2_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv2_offset"),_SCS("set_uv2_offset"),_SCS("get_uv2_offset"));
+
+
+ BIND_CONSTANT( TEXTURE_ALBEDO );
+ BIND_CONSTANT( TEXTURE_SPECULAR );
+ 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_HEIGHT );
+ BIND_CONSTANT( TEXTURE_SUBSURFACE_SCATTERING );
+ BIND_CONSTANT( TEXTURE_REFRACTION );
+ BIND_CONSTANT( TEXTURE_REFRACTION_ROUGHNESS );
+ 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_HEIGHT_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_ONTOP );
+ BIND_CONSTANT( FLAG_ALBEDO_FROM_VERTEX_COLOR );
+ BIND_CONSTANT( FLAG_SRGB_VERTEX_COLOR )
+ BIND_CONSTANT( FLAG_USE_POINT_SIZE )
+ BIND_CONSTANT( FLAG_MAX );
+
+ BIND_CONSTANT( DIFFUSE_LAMBERT );
+ BIND_CONSTANT( DIFFUSE_LAMBERT_WRAP );
+ BIND_CONSTANT( DIFFUSE_OREN_NAYAR );
+ BIND_CONSTANT( DIFFUSE_BURLEY );
+
+ BIND_CONSTANT( SPECULAR_MODE_METALLIC );
+ BIND_CONSTANT( SPECULAR_MODE_SPECULAR );
- if (shader.is_valid()) {
- List<PropertyInfo> pl;
- shader->get_param_list(&pl);
- for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
- r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
- }
- }
- }
- Material::get_argument_options(p_function,p_idx,r_options);
}
-ShaderMaterial::ShaderMaterial() :Material(VisualServer::get_singleton()->material_create()){
+FixedSpatialMaterial::FixedSpatialMaterial() : element(this) {
+
+ //initialize to right values
+ specular_mode=SPECULAR_MODE_METALLIC;
+ set_albedo(Color(0.7,0.7,0.7,1.0));
+ set_specular(Color(0.1,0.1,0.1));
+ set_roughness(0.0);
+ set_metalness(0.1);
+ set_emission(Color(0,0,0));
+ set_emission_energy(1.0);
+ set_normal_scale(1);
+ set_rim(1.0);
+ set_rim_tint(0.5);
+ set_clearcoat(1);
+ set_clearcoat_gloss(0.5);
+ set_anisotropy(0);
+ set_height_scale(1);
+ set_subsurface_scattering_strength(0);
+ set_refraction(0);
+ set_refraction_roughness(0);
+ set_line_width(1);
+ set_point_size(1);
+ set_uv1_offset(Vector2(0,0));
+ set_uv1_scale(Vector2(1,1));
+ set_uv2_offset(Vector2(0,0));
+ set_uv2_scale(Vector2(1,1));
+
+ detail_uv=DETAIL_UV_1;
+ blend_mode=BLEND_MODE_MIX;
+ detail_blend_mode=BLEND_MODE_MIX;
+ depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
+ cull_mode=CULL_BACK;
+ for(int i=0;i<FLAG_MAX;i++) {
+ flags[i]=0;
+ }
+ diffuse_mode=DIFFUSE_LAMBERT;
+
+ for(int i=0;i<FEATURE_MAX;i++) {
+ features[i]=false;
+ }
+ current_key.key=0;
+ current_key.invalid_key=1;
+ _queue_shader_change();
}
+FixedSpatialMaterial::~FixedSpatialMaterial() {
-/////////////////////////////////
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users==0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+
+ VS::get_singleton()->material_set_shader(_get_material(),RID());
+ }
+
+
+ if (material_mutex)
+ material_mutex->unlock();
+
+}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index dbd05c466f..6b957d0203 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,220 +34,378 @@
#include "scene/resources/shader.h"
#include "resource.h"
#include "servers/visual/shader_language.h"
-
+#include "self_list.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class Material : public Resource {
- OBJ_TYPE(Material,Resource);
+ GDCLASS(Material,Resource);
RES_BASE_EXTENSION("mtl");
OBJ_SAVE_TYPE( Material );
-public:
+ RID material;
+protected:
- enum Flag {
- FLAG_VISIBLE = VS::MATERIAL_FLAG_VISIBLE,
- FLAG_DOUBLE_SIDED = VS::MATERIAL_FLAG_DOUBLE_SIDED,
- FLAG_INVERT_FACES = VS::MATERIAL_FLAG_INVERT_FACES,
- FLAG_UNSHADED = VS::MATERIAL_FLAG_UNSHADED,
- FLAG_ONTOP = VS::MATERIAL_FLAG_ONTOP,
- FLAG_LIGHTMAP_ON_UV2 = VS::MATERIAL_FLAG_LIGHTMAP_ON_UV2,
- FLAG_COLOR_ARRAY_SRGB = VS::MATERIAL_FLAG_COLOR_ARRAY_SRGB,
- FLAG_MAX = VS::MATERIAL_FLAG_MAX
- };
+ _FORCE_INLINE_ RID _get_material() const { return material; }
+public:
- enum BlendMode {
- BLEND_MODE_MIX = VS::MATERIAL_BLEND_MODE_MIX,
- BLEND_MODE_MUL = VS::MATERIAL_BLEND_MODE_MUL,
- BLEND_MODE_ADD = VS::MATERIAL_BLEND_MODE_ADD,
- BLEND_MODE_SUB = VS::MATERIAL_BLEND_MODE_SUB,
- BLEND_MODE_PREMULT_ALPHA = VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA,
+ virtual RID get_rid() const;
+ Material();
+ virtual ~Material();
+};
- };
- enum DepthDrawMode {
- DEPTH_DRAW_ALWAYS = VS::MATERIAL_DEPTH_DRAW_ALWAYS,
- DEPTH_DRAW_OPAQUE_ONLY = VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY,
- DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA = VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA,
- DEPTH_DRAW_NEVER = VS::MATERIAL_DEPTH_DRAW_NEVER
- };
+class FixedSpatialMaterial : public Material {
+ GDCLASS(FixedSpatialMaterial,Material)
-private:
- BlendMode blend_mode;
- bool flags[VS::MATERIAL_FLAG_MAX];
- float line_width;
- DepthDrawMode depth_draw_mode;
-protected:
- RID material;
+public:
- static void _bind_methods();
+ enum TextureParam {
+ TEXTURE_ALBEDO,
+ TEXTURE_SPECULAR,
+ TEXTURE_EMISSION,
+ TEXTURE_NORMAL,
+ TEXTURE_RIM,
+ TEXTURE_CLEARCOAT,
+ TEXTURE_FLOWMAP,
+ TEXTURE_AMBIENT_OCCLUSION,
+ TEXTURE_HEIGHT,
+ TEXTURE_SUBSURFACE_SCATTERING,
+ TEXTURE_REFRACTION,
+ TEXTURE_REFRACTION_ROUGHNESS,
+ TEXTURE_DETAIL_MASK,
+ TEXTURE_DETAIL_ALBEDO,
+ TEXTURE_DETAIL_NORMAL,
+ TEXTURE_MAX
-public:
- void set_flag(Flag p_flag,bool p_enabled);
- bool get_flag(Flag p_flag) const;
- void set_blend_mode(BlendMode p_blend_mode);
- BlendMode get_blend_mode() const;
+ };
- void set_depth_draw_mode(DepthDrawMode p_depth_draw_mode);
- DepthDrawMode get_depth_draw_mode() const;
- void set_line_width(float p_width);
- float get_line_width() const;
+ enum DetailUV {
+ DETAIL_UV_1,
+ DETAIL_UV_2
+ };
- virtual RID get_rid() const;
+ enum Feature {
+ FEATURE_TRANSPARENT,
+ FEATURE_EMISSION,
+ FEATURE_NORMAL_MAPPING,
+ FEATURE_RIM,
+ FEATURE_CLEARCOAT,
+ FEATURE_ANISOTROPY,
+ FEATURE_AMBIENT_OCCLUSION,
+ FEATURE_HEIGHT_MAPPING,
+ FEATURE_SUBSURACE_SCATTERING,
+ FEATURE_REFRACTION,
+ FEATURE_DETAIL,
+ FEATURE_MAX
+ };
- Material(const RID& p_rid=RID());
- virtual ~Material();
-};
-VARIANT_ENUM_CAST( Material::Flag );
-VARIANT_ENUM_CAST( Material::DepthDrawMode );
+ enum BlendMode {
+ BLEND_MODE_MIX,
+ BLEND_MODE_ADD,
+ BLEND_MODE_SUB,
+ BLEND_MODE_MUL,
+ };
-VARIANT_ENUM_CAST( Material::BlendMode );
+ enum DepthDrawMode {
+ DEPTH_DRAW_OPAQUE_ONLY,
+ DEPTH_DRAW_ALWAYS,
+ DEPTH_DRAW_DISABLED,
+ DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
+ };
-class FixedMaterial : public Material {
+ enum CullMode {
+ CULL_BACK,
+ CULL_FRONT,
+ CULL_DISABLED
+ };
- OBJ_TYPE( FixedMaterial, Material );
- REVERSE_GET_PROPERTY_LIST
-public:
+ enum Flags {
+ FLAG_UNSHADED,
+ FLAG_ONTOP,
+ FLAG_ALBEDO_FROM_VERTEX_COLOR,
+ FLAG_SRGB_VERTEX_COLOR,
+ FLAG_USE_POINT_SIZE,
+ FLAG_MAX
+ };
- enum Parameter {
- PARAM_DIFFUSE=VS::FIXED_MATERIAL_PARAM_DIFFUSE,
- PARAM_DETAIL=VS::FIXED_MATERIAL_PARAM_DETAIL,
- PARAM_SPECULAR=VS::FIXED_MATERIAL_PARAM_SPECULAR,
- PARAM_EMISSION=VS::FIXED_MATERIAL_PARAM_EMISSION,
- PARAM_SPECULAR_EXP=VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP,
- PARAM_GLOW=VS::FIXED_MATERIAL_PARAM_GLOW,
- PARAM_NORMAL=VS::FIXED_MATERIAL_PARAM_NORMAL,
- PARAM_SHADE_PARAM=VS::FIXED_MATERIAL_PARAM_SHADE_PARAM,
- PARAM_MAX=VS::FIXED_MATERIAL_PARAM_MAX
+ enum DiffuseMode {
+ DIFFUSE_LAMBERT,
+ DIFFUSE_LAMBERT_WRAP,
+ DIFFUSE_OREN_NAYAR,
+ DIFFUSE_BURLEY,
};
+ enum SpecularMode {
+ SPECULAR_MODE_METALLIC,
+ SPECULAR_MODE_SPECULAR,
+ };
- enum TexCoordMode {
+private:
+ union MaterialKey {
+
+ struct {
+ uint32_t feature_mask : 14;
+ uint32_t detail_uv : 1;
+ uint32_t blend_mode : 2;
+ uint32_t depth_draw_mode : 2;
+ uint32_t cull_mode : 2;
+ uint32_t flags : 5;
+ uint32_t detail_blend_mode : 2;
+ uint32_t diffuse_mode : 2;
+ uint32_t invalid_key : 1;
+ uint32_t specular_mode : 1;
+ };
+
+ uint32_t key;
+
+ bool operator<(const MaterialKey& p_key) const {
+ return key < p_key.key;
+ }
- TEXCOORD_UV=VS::FIXED_MATERIAL_TEXCOORD_UV,
- TEXCOORD_UV_TRANSFORM=VS::FIXED_MATERIAL_TEXCOORD_UV_TRANSFORM,
- TEXCOORD_UV2=VS::FIXED_MATERIAL_TEXCOORD_UV2,
- TEXCOORD_SPHERE=VS::FIXED_MATERIAL_TEXCOORD_SPHERE
};
- enum FixedFlag {
- FLAG_USE_ALPHA=VS::FIXED_MATERIAL_FLAG_USE_ALPHA,
- FLAG_USE_COLOR_ARRAY=VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,
- FLAG_USE_POINT_SIZE=VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE,
- FLAG_DISCARD_ALPHA=VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA,
- FLAG_USE_XY_NORMALMAP=VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP,
- FLAG_MAX=VS::FIXED_MATERIAL_FLAG_MAX
+ struct ShaderData {
+ RID shader;
+ int users;
};
- enum LightShader {
+ static Map<MaterialKey,ShaderData> shader_map;
+
+ MaterialKey current_key;
+
+ _FORCE_INLINE_ MaterialKey _compute_key() const {
+
+ MaterialKey mk;
+ mk.key=0;
+ for(int i=0;i<FEATURE_MAX;i++) {
+ if (features[i]) {
+ mk.feature_mask|=(1<<i);
+ }
+ }
+ mk.detail_uv=detail_uv;
+ mk.blend_mode=blend_mode;
+ mk.depth_draw_mode=depth_draw_mode;
+ mk.cull_mode=cull_mode;
+ for(int i=0;i<FLAG_MAX;i++) {
+ if (flags[i]) {
+ mk.flags|=(1<<i);
+ }
+ }
+ mk.detail_blend_mode=detail_blend_mode;
+ mk.diffuse_mode=diffuse_mode;
+ mk.specular_mode=specular_mode;
+
+ return mk;
+ }
+
+ struct ShaderNames {
+ StringName albedo;
+ StringName specular;
+ StringName metalness;
+ StringName roughness;
+ StringName emission;
+ StringName emission_energy;
+ StringName normal_scale;
+ StringName rim;
+ StringName rim_tint;
+ StringName clearcoat;
+ StringName clearcoat_gloss;
+ StringName anisotropy;
+ StringName height_scale;
+ StringName subsurface_scattering_strength;
+ StringName refraction;
+ StringName refraction_roughness;
+ StringName point_size;
+ StringName uv1_scale;
+ StringName uv1_offset;
+ StringName uv2_scale;
+ StringName uv2_offset;
+ StringName texture_names[TEXTURE_MAX];
- LIGHT_SHADER_LAMBERT=VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT,
- LIGHT_SHADER_WRAP=VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP,
- LIGHT_SHADER_VELVET=VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET,
- LIGHT_SHADER_TOON=VS::FIXED_MATERIAL_LIGHT_SHADER_TOON
};
-private:
+ static Mutex *material_mutex;
+ static SelfList<FixedSpatialMaterial>::List dirty_materials;
+ static ShaderNames* shader_names;
+
+ SelfList<FixedSpatialMaterial> element;
+
+ void _update_shader();
+ _FORCE_INLINE_ void _queue_shader_change();
+ _FORCE_INLINE_ bool _is_shader_dirty() const;
+
+ Color albedo;
+ Color specular;
+ float metalness;
+ float roughness;
+ Color emission;
+ float emission_energy;
+ float normal_scale;
+ float rim;
+ float rim_tint;
+ float clearcoat;
+ float clearcoat_gloss;
+ float anisotropy;
+ float height_scale;
+ float subsurface_scattering_strength;
+ float refraction;
+ float refraction_roughness;
+ float line_width;
+ float point_size;
+ Vector2 uv1_scale;
+ Vector2 uv1_offset;
- struct Node {
+ Vector2 uv2_scale;
+ Vector2 uv2_offset;
- int param;
- int mult;
- int tex;
- };
+ DetailUV detail_uv;
- Variant param[PARAM_MAX];
- Ref<Texture> texture_param[PARAM_MAX];
- TexCoordMode texture_texcoord[PARAM_MAX];
- LightShader light_shader;
- bool fixed_flags[FLAG_MAX];
- float point_size;
+ BlendMode blend_mode;
+ BlendMode detail_blend_mode;
+ DepthDrawMode depth_draw_mode;
+ CullMode cull_mode;
+ bool flags[FLAG_MAX];
+ DiffuseMode diffuse_mode;
+ SpecularMode specular_mode;
+ bool features[FEATURE_MAX];
- Transform uv_transform;
+ Ref<Texture> textures[TEXTURE_MAX];
-protected:
+ _FORCE_INLINE_ void _validate_feature(const String& text, Feature feature,PropertyInfo& property) const;
+protected:
static void _bind_methods();
-
+ void _validate_property(PropertyInfo& property) const;
public:
- void set_fixed_flag(FixedFlag p_flag, bool p_value);
- bool get_fixed_flag(FixedFlag p_flag) const;
- void set_parameter(Parameter p_parameter, const Variant& p_value);
- Variant get_parameter(Parameter p_parameter) const;
+ void set_albedo(const Color& p_albedo);
+ Color get_albedo() const;
- void set_texture(Parameter p_parameter, Ref<Texture> p_texture);
- Ref<Texture> get_texture(Parameter p_parameter) const;
+ void set_specular_mode(SpecularMode p_mode);
+ SpecularMode get_specular_mode() const;
- void set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode);
- TexCoordMode get_texcoord_mode(Parameter p_parameter) const;
+ void set_specular(const Color& p_specular);
+ Color get_specular() const;
- void set_light_shader(LightShader p_shader);
- LightShader get_light_shader() const;
+ void set_metalness(float p_metalness);
+ float get_metalness() const;
- void set_uv_transform(const Transform& p_transform);
- Transform get_uv_transform() const;
+ void set_roughness(float p_roughness);
+ float get_roughness() const;
- void set_point_size(float p_transform);
- float get_point_size() const;
+ void set_emission(const Color& p_emission);
+ Color get_emission() const;
- FixedMaterial();
- ~FixedMaterial();
+ void set_emission_energy(float p_emission_energy);
+ float get_emission_energy() const;
-};
+ void set_normal_scale(float p_normal_scale);
+ float get_normal_scale() const;
+ void set_rim(float p_rim);
+ float get_rim() const;
+ void set_rim_tint(float p_rim_tint);
+ float get_rim_tint() const;
-VARIANT_ENUM_CAST( FixedMaterial::Parameter );
-VARIANT_ENUM_CAST( FixedMaterial::TexCoordMode );
-VARIANT_ENUM_CAST( FixedMaterial::FixedFlag );
-VARIANT_ENUM_CAST( FixedMaterial::LightShader );
+ void set_clearcoat(float p_clearcoat);
+ float get_clearcoat() const;
-class ShaderMaterial : public Material {
+ void set_clearcoat_gloss(float p_clearcoat_gloss);
+ float get_clearcoat_gloss() const;
- OBJ_TYPE( ShaderMaterial, Material );
+ void set_anisotropy(float p_anisotropy);
+ float get_anisotropy() const;
- Ref<Shader> shader;
+ void set_height_scale(float p_height_scale);
+ float get_height_scale() const;
+ void set_subsurface_scattering_strength(float p_strength);
+ float get_subsurface_scattering_strength() const;
+ void set_refraction(float p_refraction);
+ float get_refraction() const;
- void _shader_changed();
- static void _shader_parse(void*p_self,ShaderLanguage::ProgramNode*p_node);
+ void set_refraction_roughness(float p_refraction_roughness);
+ float get_refraction_roughness() const;
-protected:
+ void set_line_width(float p_line_width);
+ float get_line_width() const;
- 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 set_point_size(float p_point_size);
+ float get_point_size() const;
- static void _bind_methods();
+ void set_detail_uv(DetailUV p_detail_uv);
+ DetailUV get_detail_uv() const;
-public:
+ void set_blend_mode(BlendMode p_mode);
+ BlendMode get_blend_mode() const;
+
+ void set_detail_blend_mode(BlendMode p_mode);
+ BlendMode get_detail_blend_mode() const;
+
+ void set_depth_draw_mode(DepthDrawMode p_mode);
+ DepthDrawMode get_depth_draw_mode() const;
- void set_shader(const Ref<Shader>& p_shader);
- Ref<Shader> get_shader() const;
+ void set_cull_mode(CullMode p_mode);
+ CullMode get_cull_mode() const;
- void set_shader_param(const StringName& p_param,const Variant& p_value);
- Variant get_shader_param(const StringName& p_param) const;
+ void set_diffuse_mode(DiffuseMode p_mode);
+ DiffuseMode get_diffuse_mode() const;
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ void set_flag(Flags p_flag,bool p_enabled);
+ bool get_flag(Flags p_flag) const;
- ShaderMaterial();
+ void set_texture(TextureParam p_param,const Ref<Texture>& p_texture);
+ Ref<Texture> get_texture(TextureParam p_param) const;
+
+ void set_feature(Feature p_feature,bool p_enabled);
+ bool get_feature(Feature p_feature) const;
+
+ void set_uv1_scale(const Vector2& p_scale);
+ Vector2 get_uv1_scale() const;
+
+ void set_uv1_offset(const Vector2& p_offset);
+ Vector2 get_uv1_offset() const;
+
+ void set_uv2_scale(const Vector2& p_scale);
+ Vector2 get_uv2_scale() const;
+
+ void set_uv2_offset(const Vector2& p_offset);
+ Vector2 get_uv2_offset() const;
+
+ static void init_shaders();
+ static void finish_shaders();
+ static void flush_changes();
+
+ FixedSpatialMaterial();
+ virtual ~FixedSpatialMaterial();
};
+VARIANT_ENUM_CAST( FixedSpatialMaterial::TextureParam )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::DetailUV )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::Feature )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::BlendMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::DepthDrawMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::CullMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::Flags )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::DiffuseMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::SpecularMode )
+
//////////////////////
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 921466585d..99911eddeb 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -77,19 +77,19 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
String sname=p_name;
- if (p_name=="morph_target/names") {
+ if (p_name=="blend_shape/names") {
- DVector<String> sk=p_value;
+ PoolVector<String> sk=p_value;
int sz = sk.size();
- DVector<String>::Read r = sk.read();
+ PoolVector<String>::Read r = sk.read();
for(int i=0;i<sz;i++)
- add_morph_target(r[i]);
+ add_blend_shape(r[i]);
return true;
}
- if (p_name=="morph_target/mode") {
+ if (p_name=="blend_shape/mode") {
- set_morph_target_mode(MorphTargetMode(int(p_value)));
+ set_blend_shape_mode(BlendShapeMode(int(p_value)));
return true;
}
@@ -122,22 +122,64 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (idx==surfaces.size()) {
- if (what=="custom") {
- add_custom_surface(p_value);
- return true;
-
- }
-
//create
Dictionary d=p_value;
ERR_FAIL_COND_V(!d.has("primitive"),false);
- ERR_FAIL_COND_V(!d.has("arrays"),false);
- ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
- bool alphasort = d.has("alphasort") && bool(d["alphasort"]);
+ if (d.has("arrays")) {
+ //old format
+ ERR_FAIL_COND_V(!d.has("blend_shape_arrays"),false);
+ add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["blend_shape_arrays"]);
+
+ } else if (d.has("array_data")) {
+
+ PoolVector<uint8_t> array_data = d["array_data"];
+ PoolVector<uint8_t> array_index_data;
+ if (d.has("array_index_data"))
+ array_index_data=d["array_index_data"];
+
+ ERR_FAIL_COND_V(!d.has("format"),false);
+ uint32_t format = d["format"];
+
+ ERR_FAIL_COND_V(!d.has("primitive"),false);
+ uint32_t primitive = d["primitive"];
+
+ ERR_FAIL_COND_V(!d.has("vertex_count"),false);
+ int vertex_count = d["vertex_count"];
+
+ int index_count=0;
+ if (d.has("index_count"))
+ index_count=d["index_count"];
+
+ Vector< PoolVector<uint8_t> > blend_shapes;
+
+ if (d.has("blend_shape_data")) {
+ Array blend_shape_data=d["blend_shape_data"];
+ for(int i=0;i<blend_shape_data.size();i++) {
+ PoolVector<uint8_t> shape = blend_shape_data[i];
+ blend_shapes.push_back(shape);
+ }
+ }
+
+ ERR_FAIL_COND_V(!d.has("aabb"),false);
+ Rect3 aabb = d["aabb"];
+
+ Vector<Rect3> bone_aabb;
+ if (d.has("bone_aabb")) {
+ Array baabb = d["bone_aabb"];
+ bone_aabb.resize(baabb.size());
+
+ for(int i=0;i<baabb.size();i++) {
+ bone_aabb[i]=baabb[i];
+ }
+ }
+
+ add_surface(format,PrimitiveType(primitive),array_data,vertex_count,array_index_data,index_count,aabb,blend_shapes,bone_aabb);
+ } else {
+ ERR_FAIL_V(false);
+ }
- add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"],alphasort);
if (d.has("material")) {
surface_set_material(idx,d["material"]);
@@ -157,16 +199,16 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
String sname=p_name;
- if (p_name=="morph_target/names") {
+ if (p_name=="blend_shape/names") {
- DVector<String> sk;
- for(int i=0;i<morph_targets.size();i++)
- sk.push_back(morph_targets[i]);
+ PoolVector<String> sk;
+ for(int i=0;i<blend_shapes.size();i++)
+ sk.push_back(blend_shapes[i]);
r_ret=sk;
return true;
- } else if (p_name=="morph_target/mode") {
+ } else if (p_name=="blend_shape/mode") {
- r_ret = get_morph_target_mode();
+ r_ret = get_blend_shape_mode();
return true;
} else if (sname.begins_with("surface_")) {
@@ -193,10 +235,31 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
ERR_FAIL_INDEX_V(idx,surfaces.size(),false);
Dictionary d;
- d["primitive"]=surface_get_primitive_type(idx);
- d["arrays"]=surface_get_arrays(idx);
- d["morph_arrays"]=surface_get_morph_arrays(idx);
- d["alphasort"]=surface_is_alpha_sorting_enabled(idx);
+
+ d["array_data"]=VS::get_singleton()->mesh_surface_get_array(mesh,idx);
+ d["vertex_count"]=VS::get_singleton()->mesh_surface_get_array_len(mesh,idx);
+ d["array_index_data"]=VS::get_singleton()->mesh_surface_get_index_array(mesh,idx);
+ d["index_count"]=VS::get_singleton()->mesh_surface_get_array_index_len(mesh,idx);
+ d["primitive"]=VS::get_singleton()->mesh_surface_get_primitive_type(mesh,idx);
+ d["format"]=VS::get_singleton()->mesh_surface_get_format(mesh,idx);
+ d["aabb"]=VS::get_singleton()->mesh_surface_get_aabb(mesh,idx);
+
+ Vector<Rect3> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh,idx);
+ Array arr;
+ for(int i=0;i<skel_aabb.size();i++) {
+ arr[i]=skel_aabb[i];
+ }
+ d["skeleton_aabb"]=arr;
+
+ Vector< PoolVector<uint8_t> > blend_shape_data = VS::get_singleton()->mesh_surface_get_blend_shapes(mesh,idx);
+
+ Array md;
+ for(int i=0;i<blend_shape_data.size();i++) {
+ md.push_back(blend_shape_data[i]);
+ }
+
+ d["blend_shape_data"]=md;
+
Ref<Material> m = surface_get_material(idx);
if (m.is_valid())
d["material"]=m;
@@ -211,9 +274,9 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
void Mesh::_get_property_list( List<PropertyInfo> *p_list) const {
- if (morph_targets.size()) {
- p_list->push_back(PropertyInfo(Variant::STRING_ARRAY,"morph_target/names",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
- p_list->push_back(PropertyInfo(Variant::INT,"morph_target/mode",PROPERTY_HINT_ENUM,"Normalized,Relative"));
+ if (blend_shapes.size()) {
+ p_list->push_back(PropertyInfo(Variant::POOL_STRING_ARRAY,"blend_shape/names",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT,"blend_shape/mode",PROPERTY_HINT_ENUM,"Normalized,Relative"));
}
for (int i=0;i<surfaces.size();i++) {
@@ -223,7 +286,7 @@ void Mesh::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::OBJECT,"surface_"+itos(i+1)+"/material", PROPERTY_HINT_RESOURCE_TYPE,"Material",PROPERTY_USAGE_EDITOR ) );
}
- p_list->push_back( PropertyInfo( Variant::_AABB,"custom_aabb/custom_aabb" ) );
+ p_list->push_back( PropertyInfo( Variant::RECT3,"custom_aabb/custom_aabb" ) );
}
@@ -231,7 +294,7 @@ void Mesh::_get_property_list( List<PropertyInfo> *p_list) const {
void Mesh::_recompute_aabb() {
// regenerate AABB
- aabb=AABB();
+ aabb=Rect3();
for (int i=0;i<surfaces.size();i++) {
@@ -243,28 +306,38 @@ void Mesh::_recompute_aabb() {
}
-void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,bool p_alphasort) {
+void Mesh::add_surface(uint32_t p_format,PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes,const Vector<Rect3>& p_bone_aabbs) {
+
+ Surface s;
+ s.aabb=p_aabb;
+ surfaces.push_back(s);
+
+ VisualServer::get_singleton()->mesh_add_surface(mesh,p_format,(VS::PrimitiveType)p_primitive,p_array,p_vertex_count,p_index_array,p_index_count,p_aabb,p_blend_shapes,p_bone_aabbs);
+
+}
+
+void Mesh::add_surface_from_arrays(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,uint32_t p_flags) {
ERR_FAIL_COND(p_arrays.size()!=ARRAY_MAX);
Surface s;
- VisualServer::get_singleton()->mesh_add_surface(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes,p_alphasort);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes,p_flags);
surfaces.push_back(s);
/* make aABB? */ {
- DVector<Vector3> vertices=p_arrays[ARRAY_VERTEX];
+ PoolVector<Vector3> vertices=p_arrays[ARRAY_VERTEX];
int len=vertices.size();
ERR_FAIL_COND(len==0);
- DVector<Vector3>::Read r=vertices.read();
+ PoolVector<Vector3>::Read r=vertices.read();
const Vector3 *vtx=r.ptr();
// check AABB
- AABB aabb;
+ Rect3 aabb;
for (int i=0;i<len;i++) {
if (i==0)
@@ -274,7 +347,6 @@ void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Arr
}
surfaces[surfaces.size()-1].aabb=aabb;
- surfaces[surfaces.size()-1].alphasort=p_alphasort;
_recompute_aabb();
@@ -289,36 +361,25 @@ void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Arr
Array Mesh::surface_get_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_arrays(mesh,p_surface);
+ return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh,p_surface);
}
-Array Mesh::surface_get_morph_arrays(int p_surface) const {
+Array Mesh::surface_get_blend_shape_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_morph_arrays(mesh,p_surface);
+ return Array();
}
-void Mesh::add_custom_surface(const Variant& p_data) {
-
- Surface s;
- s.aabb=AABB();
- VisualServer::get_singleton()->mesh_add_custom_surface(mesh,p_data);
- surfaces.push_back(s);
-
- triangle_mesh=Ref<TriangleMesh>();
- _change_notify();
-}
-
int Mesh::get_surface_count() const {
return surfaces.size();
}
-void Mesh::add_morph_target(const StringName& p_name) {
+void Mesh::add_blend_shape(const StringName& p_name) {
if (surfaces.size()) {
ERR_EXPLAIN("Can't add a shape key count if surfaces are already created.");
@@ -327,49 +388,49 @@ void Mesh::add_morph_target(const StringName& p_name) {
StringName name=p_name;
- if (morph_targets.find(name)!=-1 ) {
+ if (blend_shapes.find(name)!=-1 ) {
int count=2;
do {
name = String(p_name) + " " + itos(count);
count++;
- } while(morph_targets.find(name)!=-1);
+ } while(blend_shapes.find(name)!=-1);
}
- morph_targets.push_back(name);
- VS::get_singleton()->mesh_set_morph_target_count(mesh,morph_targets.size());
+ blend_shapes.push_back(name);
+ VS::get_singleton()->mesh_set_blend_shape_count(mesh,blend_shapes.size());
}
-int Mesh::get_morph_target_count() const {
+int Mesh::get_blend_shape_count() const {
- return morph_targets.size();
+ return blend_shapes.size();
}
-StringName Mesh::get_morph_target_name(int p_index) const {
- ERR_FAIL_INDEX_V( p_index, morph_targets.size(),StringName() );
- return morph_targets[p_index];
+StringName Mesh::get_blend_shape_name(int p_index) const {
+ ERR_FAIL_INDEX_V( p_index, blend_shapes.size(),StringName() );
+ return blend_shapes[p_index];
}
-void Mesh::clear_morph_targets() {
+void Mesh::clear_blend_shapes() {
if (surfaces.size()) {
ERR_EXPLAIN("Can't set shape key count if surfaces are already created.");
ERR_FAIL_COND(surfaces.size());
}
- morph_targets.clear();
+ blend_shapes.clear();
}
-void Mesh::set_morph_target_mode(MorphTargetMode p_mode) {
+void Mesh::set_blend_shape_mode(BlendShapeMode p_mode) {
- morph_target_mode=p_mode;
- VS::get_singleton()->mesh_set_morph_target_mode(mesh,(VS::MorphTargetMode)p_mode);
+ blend_shape_mode=p_mode;
+ VS::get_singleton()->mesh_set_blend_shape_mode(mesh,(VS::BlendShapeMode)p_mode);
}
-Mesh::MorphTargetMode Mesh::get_morph_target_mode() const {
+Mesh::BlendShapeMode Mesh::get_blend_shape_mode() const {
- return morph_target_mode;
+ return blend_shape_mode;
}
@@ -418,11 +479,6 @@ Mesh::PrimitiveType Mesh::surface_get_primitive_type(int p_idx) const {
return (PrimitiveType)VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, p_idx );
}
-bool Mesh::surface_is_alpha_sorting_enabled(int p_idx) const {
-
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), 0 );
- return surfaces[p_idx].alphasort;
-}
void Mesh::surface_set_material(int p_idx, const Ref<Material>& p_material) {
@@ -449,7 +505,7 @@ String Mesh::surface_get_name(int p_idx) const{
}
-void Mesh::surface_set_custom_aabb(int p_idx,const AABB& p_aabb) {
+void Mesh::surface_set_custom_aabb(int p_idx,const Rect3& p_aabb) {
ERR_FAIL_INDEX( p_idx, surfaces.size() );
surfaces[p_idx].aabb=p_aabb;
@@ -466,7 +522,7 @@ Ref<Material> Mesh::surface_get_material(int p_idx) const {
void Mesh::add_surface_from_mesh_data(const Geometry::MeshData& p_mesh_data) {
VisualServer::get_singleton()->mesh_add_surface_from_mesh_data( mesh, p_mesh_data );
- AABB aabb;
+ Rect3 aabb;
for (int i=0;i<p_mesh_data.vertices.size();i++) {
if (i==0)
@@ -495,39 +551,39 @@ RID Mesh::get_rid() const {
return mesh;
}
-AABB Mesh::get_aabb() const {
+Rect3 Mesh::get_aabb() const {
return aabb;
}
-void Mesh::set_custom_aabb(const AABB& p_custom) {
+void Mesh::set_custom_aabb(const Rect3& p_custom) {
custom_aabb=p_custom;
VS::get_singleton()->mesh_set_custom_aabb(mesh,custom_aabb);
}
-AABB Mesh::get_custom_aabb() const {
+Rect3 Mesh::get_custom_aabb() const {
return custom_aabb;
}
-DVector<Face3> Mesh::get_faces() const {
+PoolVector<Face3> Mesh::get_faces() const {
Ref<TriangleMesh> tm = generate_triangle_mesh();
if (tm.is_valid())
return tm->get_faces();
- return DVector<Face3>();
+ return PoolVector<Face3>();
/*
for (int i=0;i<surfaces.size();i++) {
if (VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != VisualServer::PRIMITIVE_TRIANGLES )
continue;
- DVector<int> indices;
- DVector<Vector3> vertices;
+ PoolVector<int> indices;
+ PoolVector<Vector3> vertices;
vertices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_VERTEX);
@@ -548,10 +604,10 @@ DVector<Face3> Mesh::get_faces() const {
if (len<=0)
continue;
- DVector<int>::Read indicesr = indices.read();
+ PoolVector<int>::Read indicesr = indices.read();
const int *indicesptr = indicesr.ptr();
- DVector<Vector3>::Read verticesr = vertices.read();
+ PoolVector<Vector3>::Read verticesr = vertices.read();
const Vector3 *verticesptr = verticesr.ptr();
int old_faces=faces.size();
@@ -559,7 +615,7 @@ DVector<Face3> Mesh::get_faces() const {
faces.resize(new_faces);
- DVector<Face3>::Write facesw = faces.write();
+ PoolVector<Face3>::Write facesw = faces.write();
Face3 *facesptr=facesw.ptr();
@@ -583,12 +639,12 @@ DVector<Face3> Mesh::get_faces() const {
Ref<Shape> Mesh::create_convex_shape() const {
- DVector<Vector3> vertices;
+ PoolVector<Vector3> vertices;
for(int i=0;i<get_surface_count();i++) {
Array a = surface_get_arrays(i);
- DVector<Vector3> v=a[ARRAY_VERTEX];
+ PoolVector<Vector3> v=a[ARRAY_VERTEX];
vertices.append_array(v);
}
@@ -600,11 +656,11 @@ Ref<Shape> Mesh::create_convex_shape() const {
Ref<Shape> Mesh::create_trimesh_shape() const {
- DVector<Face3> faces = get_faces();
+ PoolVector<Face3> faces = get_faces();
if (faces.size()==0)
return Ref<Shape>();
- DVector<Vector3> face_points;
+ PoolVector<Vector3> face_points;
face_points.resize( faces.size()*3 );
for (int i=0;i<face_points.size();i++) {
@@ -625,9 +681,9 @@ void Mesh::center_geometry() {
for(int i=0;i<get_surface_count();i++) {
- DVector<Vector3> geom = surface_get_array(i,ARRAY_VERTEX);
+ PoolVector<Vector3> geom = surface_get_array(i,ARRAY_VERTEX);
int gc =geom.size();
- DVector<Vector3>::Write w = geom.write();
+ PoolVector<Vector3>::Write w = geom.write();
surfaces[i].aabb.pos-=ofs;
for(int i=0;i<gc;i++) {
@@ -635,7 +691,7 @@ void Mesh::center_geometry() {
w[i]-=ofs;
}
- w = DVector<Vector3>::Write();
+ w = PoolVector<Vector3>::Write();
surface_set_array(i,ARRAY_VERTEX,geom);
@@ -696,9 +752,9 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
if (facecount==0 || (facecount%3)!=0)
return triangle_mesh;
- DVector<Vector3> faces;
+ PoolVector<Vector3> faces;
faces.resize(facecount);
- DVector<Vector3>::Write facesw=faces.write();
+ PoolVector<Vector3>::Write facesw=faces.write();
int widx=0;
@@ -710,17 +766,19 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
Array a = surface_get_arrays(i);
int vc = surface_get_array_len(i);
- DVector<Vector3> vertices = a[ARRAY_VERTEX];
- DVector<Vector3>::Read vr=vertices.read();
+ PoolVector<Vector3> vertices = a[ARRAY_VERTEX];
+ PoolVector<Vector3>::Read vr=vertices.read();
if (surface_get_format(i)&ARRAY_FORMAT_INDEX) {
int ic=surface_get_array_index_len(i);
- DVector<int> indices = a[ARRAY_INDEX];
- DVector<int>::Read ir = indices.read();
+ PoolVector<int> indices = a[ARRAY_INDEX];
+ PoolVector<int>::Read ir = indices.read();
- for(int i=0;i<ic;i++)
- facesw[widx++]=vr[ ir[i] ];
+ for(int i=0;i<ic;i++) {
+ int index = ir[i];
+ facesw[widx++]=vr[ index ];
+ }
} else {
@@ -730,7 +788,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
}
- facesw=DVector<Vector3>::Write();
+ facesw=PoolVector<Vector3>::Write();
triangle_mesh = Ref<TriangleMesh>( memnew( TriangleMesh ));
@@ -756,7 +814,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
if (i==0) {
arrays=a;
- DVector<Vector3> v=a[ARRAY_VERTEX];
+ PoolVector<Vector3> v=a[ARRAY_VERTEX];
index_accum+=v.size();
} else {
@@ -773,8 +831,8 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
case ARRAY_VERTEX:
case ARRAY_NORMAL: {
- DVector<Vector3> dst = arrays[j];
- DVector<Vector3> src = a[j];
+ PoolVector<Vector3> dst = arrays[j];
+ PoolVector<Vector3> src = a[j];
if (j==ARRAY_VERTEX)
vcount=src.size();
if (dst.size()==0 || src.size()==0) {
@@ -788,8 +846,8 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
case ARRAY_BONES:
case ARRAY_WEIGHTS: {
- DVector<real_t> dst = arrays[j];
- DVector<real_t> src = a[j];
+ PoolVector<real_t> dst = arrays[j];
+ PoolVector<real_t> src = a[j];
if (dst.size()==0 || src.size()==0) {
arrays[j]=Variant();
continue;
@@ -799,8 +857,8 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
} break;
case ARRAY_COLOR: {
- DVector<Color> dst = arrays[j];
- DVector<Color> src = a[j];
+ PoolVector<Color> dst = arrays[j];
+ PoolVector<Color> src = a[j];
if (dst.size()==0 || src.size()==0) {
arrays[j]=Variant();
continue;
@@ -811,8 +869,8 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
} break;
case ARRAY_TEX_UV:
case ARRAY_TEX_UV2: {
- DVector<Vector2> dst = arrays[j];
- DVector<Vector2> src = a[j];
+ PoolVector<Vector2> dst = arrays[j];
+ PoolVector<Vector2> src = a[j];
if (dst.size()==0 || src.size()==0) {
arrays[j]=Variant();
continue;
@@ -822,15 +880,15 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
} break;
case ARRAY_INDEX: {
- DVector<int> dst = arrays[j];
- DVector<int> src = a[j];
+ PoolVector<int> dst = arrays[j];
+ PoolVector<int> src = a[j];
if (dst.size()==0 || src.size()==0) {
arrays[j]=Variant();
continue;
}
{
int ss = src.size();
- DVector<int>::Write w = src.write();
+ PoolVector<int>::Write w = src.write();
for(int k=0;k<ss;k++) {
w[k]+=index_accum;
}
@@ -848,13 +906,13 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
}
{
- DVector<int>::Write ir;
- DVector<int> indices =arrays[ARRAY_INDEX];
+ PoolVector<int>::Write ir;
+ PoolVector<int> indices =arrays[ARRAY_INDEX];
bool has_indices=false;
- DVector<Vector3> vertices =arrays[ARRAY_VERTEX];
+ PoolVector<Vector3> vertices =arrays[ARRAY_VERTEX];
int vc = vertices.size();
ERR_FAIL_COND_V(!vc,Ref<Mesh>());
- DVector<Vector3>::Write r=vertices.write();
+ PoolVector<Vector3>::Write r=vertices.write();
if (indices.size()) {
@@ -919,14 +977,14 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
r[i]=t;
}
- r = DVector<Vector3>::Write();
+ r = PoolVector<Vector3>::Write();
arrays[ARRAY_VERTEX]=vertices;
if (!has_indices) {
- DVector<int> new_indices;
+ PoolVector<int> new_indices;
new_indices.resize(vertices.size());
- DVector<int>::Write iw = new_indices.write();
+ PoolVector<int>::Write iw = new_indices.write();
for(int j=0;j<vc2;j+=3) {
@@ -935,7 +993,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
iw[j+2]=j+1;
}
- iw=DVector<int>::Write();
+ iw=PoolVector<int>::Write();
arrays[ARRAY_INDEX]=new_indices;
} else {
@@ -944,7 +1002,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
SWAP(ir[j+1],ir[j+2]);
}
- ir=DVector<int>::Write();
+ ir=PoolVector<int>::Write();
arrays[ARRAY_INDEX]=indices;
}
@@ -954,38 +1012,38 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
Ref<Mesh> newmesh = memnew( Mesh );
- newmesh->add_surface(PRIMITIVE_TRIANGLES,arrays);
+ newmesh->add_surface_from_arrays(PRIMITIVE_TRIANGLES,arrays);
return newmesh;
}
void Mesh::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_morph_target","name"),&Mesh::add_morph_target);
- ObjectTypeDB::bind_method(_MD("get_morph_target_count"),&Mesh::get_morph_target_count);
- ObjectTypeDB::bind_method(_MD("get_morph_target_name","index"),&Mesh::get_morph_target_name);
- ObjectTypeDB::bind_method(_MD("clear_morph_targets"),&Mesh::clear_morph_targets);
- ObjectTypeDB::bind_method(_MD("set_morph_target_mode","mode"),&Mesh::set_morph_target_mode);
- ObjectTypeDB::bind_method(_MD("get_morph_target_mode"),&Mesh::get_morph_target_mode);
-
- ObjectTypeDB::bind_method(_MD("add_surface","primitive","arrays","morph_arrays","alphasort"),&Mesh::add_surface,DEFVAL(Array()),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
- ObjectTypeDB::bind_method(_MD("surface_remove","surf_idx"),&Mesh::surface_remove);
- ObjectTypeDB::bind_method(_MD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
- ObjectTypeDB::bind_method(_MD("surface_get_array_index_len","surf_idx"),&Mesh::surface_get_array_index_len);
- ObjectTypeDB::bind_method(_MD("surface_get_format","surf_idx"),&Mesh::surface_get_format);
- ObjectTypeDB::bind_method(_MD("surface_get_primitive_type","surf_idx"),&Mesh::surface_get_primitive_type);
- ObjectTypeDB::bind_method(_MD("surface_set_material","surf_idx","material:Material"),&Mesh::surface_set_material);
- ObjectTypeDB::bind_method(_MD("surface_get_material:Material","surf_idx"),&Mesh::surface_get_material);
- ObjectTypeDB::bind_method(_MD("surface_set_name","surf_idx","name"),&Mesh::surface_set_name);
- ObjectTypeDB::bind_method(_MD("surface_get_name","surf_idx"),&Mesh::surface_get_name);
- ObjectTypeDB::bind_method(_MD("center_geometry"),&Mesh::center_geometry);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("center_geometry"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("regen_normalmaps"),&Mesh::regen_normalmaps);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regen_normalmaps"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
-
- ObjectTypeDB::bind_method(_MD("set_custom_aabb","aabb"),&Mesh::set_custom_aabb);
- ObjectTypeDB::bind_method(_MD("get_custom_aabb"),&Mesh::get_custom_aabb);
+ ClassDB::bind_method(_MD("add_blend_shape","name"),&Mesh::add_blend_shape);
+ ClassDB::bind_method(_MD("get_blend_shape_count"),&Mesh::get_blend_shape_count);
+ ClassDB::bind_method(_MD("get_blend_shape_name","index"),&Mesh::get_blend_shape_name);
+ ClassDB::bind_method(_MD("clear_blend_shapes"),&Mesh::clear_blend_shapes);
+ ClassDB::bind_method(_MD("set_blend_shape_mode","mode"),&Mesh::set_blend_shape_mode);
+ ClassDB::bind_method(_MD("get_blend_shape_mode"),&Mesh::get_blend_shape_mode);
+
+ ClassDB::bind_method(_MD("add_surface_from_arrays","primitive","arrays","blend_shapes","compress_flags"),&Mesh::add_surface_from_arrays,DEFVAL(Array()),DEFVAL(ARRAY_COMPRESS_DEFAULT));
+ ClassDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
+ ClassDB::bind_method(_MD("surface_remove","surf_idx"),&Mesh::surface_remove);
+ ClassDB::bind_method(_MD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
+ ClassDB::bind_method(_MD("surface_get_array_index_len","surf_idx"),&Mesh::surface_get_array_index_len);
+ ClassDB::bind_method(_MD("surface_get_format","surf_idx"),&Mesh::surface_get_format);
+ ClassDB::bind_method(_MD("surface_get_primitive_type","surf_idx"),&Mesh::surface_get_primitive_type);
+ ClassDB::bind_method(_MD("surface_set_material","surf_idx","material:Material"),&Mesh::surface_set_material);
+ ClassDB::bind_method(_MD("surface_get_material:Material","surf_idx"),&Mesh::surface_get_material);
+ ClassDB::bind_method(_MD("surface_set_name","surf_idx","name"),&Mesh::surface_set_name);
+ ClassDB::bind_method(_MD("surface_get_name","surf_idx"),&Mesh::surface_get_name);
+ ClassDB::bind_method(_MD("center_geometry"),&Mesh::center_geometry);
+ ClassDB::set_method_flags(get_class_static(),_SCS("center_geometry"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(_MD("regen_normalmaps"),&Mesh::regen_normalmaps);
+ ClassDB::set_method_flags(get_class_static(),_SCS("regen_normalmaps"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ClassDB::bind_method(_MD("set_custom_aabb","aabb"),&Mesh::set_custom_aabb);
+ ClassDB::bind_method(_MD("get_custom_aabb"),&Mesh::get_custom_aabb);
BIND_CONSTANT( NO_INDEX_ARRAY );
@@ -1026,7 +1084,7 @@ void Mesh::_bind_methods() {
Mesh::Mesh() {
mesh=VisualServer::get_singleton()->mesh_create();
- morph_target_mode=MORPH_MODE_RELATIVE;
+ blend_shape_mode=BLEND_SHAPE_MODE_RELATIVE;
}
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index dc1d97a49e..1af33ad836 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@
*/
class Mesh : public Resource {
- OBJ_TYPE( Mesh, Resource );
+ GDCLASS( Mesh, Resource );
RES_BASE_EXTENSION("msh");
public:
@@ -77,6 +77,22 @@ public:
ARRAY_FORMAT_WEIGHTS=1<<ARRAY_WEIGHTS,
ARRAY_FORMAT_INDEX=1<<ARRAY_INDEX,
+ ARRAY_COMPRESS_BASE=(ARRAY_INDEX+1),
+ ARRAY_COMPRESS_VERTEX=1<<(ARRAY_VERTEX+ARRAY_COMPRESS_BASE), // mandatory
+ ARRAY_COMPRESS_NORMAL=1<<(ARRAY_NORMAL+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_TANGENT=1<<(ARRAY_TANGENT+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_COLOR=1<<(ARRAY_COLOR+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_TEX_UV=1<<(ARRAY_TEX_UV+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_TEX_UV2=1<<(ARRAY_TEX_UV2+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_BONES=1<<(ARRAY_BONES+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_WEIGHTS=1<<(ARRAY_WEIGHTS+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_INDEX=1<<(ARRAY_INDEX+ARRAY_COMPRESS_BASE),
+
+ ARRAY_FLAG_USE_2D_VERTICES=ARRAY_COMPRESS_INDEX<<1,
+ ARRAY_FLAG_USE_16_BIT_BONES=ARRAY_COMPRESS_INDEX<<2,
+
+ ARRAY_COMPRESS_DEFAULT=ARRAY_COMPRESS_VERTEX|ARRAY_COMPRESS_NORMAL|ARRAY_COMPRESS_TANGENT|ARRAY_COMPRESS_COLOR|ARRAY_COMPRESS_TEX_UV|ARRAY_COMPRESS_TEX_UV2|ARRAY_COMPRESS_WEIGHTS
+
};
enum PrimitiveType {
@@ -89,25 +105,24 @@ public:
PRIMITIVE_TRIANGLE_FAN=VisualServer::PRIMITIVE_TRIANGLE_FAN,
};
- enum MorphTargetMode {
+ enum BlendShapeMode {
- MORPH_MODE_NORMALIZED=VS::MORPH_MODE_NORMALIZED,
- MORPH_MODE_RELATIVE=VS::MORPH_MODE_RELATIVE,
+ BLEND_SHAPE_MODE_NORMALIZED=VS::BLEND_SHAPE_MODE_NORMALIZED,
+ BLEND_SHAPE_MODE_RELATIVE=VS::BLEND_SHAPE_MODE_RELATIVE,
};
private:
struct Surface {
String name;
- AABB aabb;
- bool alphasort;
+ Rect3 aabb;
Ref<Material> material;
};
Vector<Surface> surfaces;
RID mesh;
- AABB aabb;
- MorphTargetMode morph_target_mode;
- Vector<StringName> morph_targets;
- AABB custom_aabb;
+ Rect3 aabb;
+ BlendShapeMode blend_shape_mode;
+ Vector<StringName> blend_shapes;
+ Rect3 custom_aabb;
mutable Ref<TriangleMesh> triangle_mesh;
@@ -123,24 +138,24 @@ protected:
public:
- void add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),bool p_alphasort=false);
- Array surface_get_arrays(int p_surface) const;
- virtual Array surface_get_morph_arrays(int p_surface) const;
+ void add_surface_from_arrays(PrimitiveType p_primitive, const Array& p_arrays, const Array& p_blend_shapes=Array(), uint32_t p_flags=ARRAY_COMPRESS_DEFAULT);
+ void add_surface(uint32_t p_format,PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>());
- void add_custom_surface(const Variant& p_data); //only recognized by driver
+ Array surface_get_arrays(int p_surface) const;
+ virtual Array surface_get_blend_shape_arrays(int p_surface) const;
- void add_morph_target(const StringName& p_name);
- int get_morph_target_count() const;
- StringName get_morph_target_name(int p_index) const;
- void clear_morph_targets();
+ void add_blend_shape(const StringName& p_name);
+ int get_blend_shape_count() const;
+ StringName get_blend_shape_name(int p_index) const;
+ void clear_blend_shapes();
- void set_morph_target_mode(MorphTargetMode p_mode);
- MorphTargetMode get_morph_target_mode() const;
+ void set_blend_shape_mode(BlendShapeMode p_mode);
+ BlendShapeMode get_blend_shape_mode() const;
int get_surface_count() const;
void surface_remove(int p_idx);
- void surface_set_custom_aabb(int p_surface,const AABB& p_aabb); //only recognized by driver
+ void surface_set_custom_aabb(int p_surface,const Rect3& p_aabb); //only recognized by driver
int surface_get_array_len(int p_idx) const;
@@ -157,10 +172,10 @@ public:
void add_surface_from_mesh_data(const Geometry::MeshData& p_mesh_data);
- void set_custom_aabb(const AABB& p_custom);
- AABB get_custom_aabb() const;
+ void set_custom_aabb(const Rect3& p_custom);
+ Rect3 get_custom_aabb() const;
- AABB get_aabb() const;
+ Rect3 get_aabb() const;
virtual RID get_rid() const;
Ref<Shape> create_trimesh_shape() const;
@@ -171,7 +186,7 @@ public:
void center_geometry();
void regen_normalmaps();
- DVector<Face3> get_faces() const;
+ PoolVector<Face3> get_faces() const;
Ref<TriangleMesh> generate_triangle_mesh() const;
Mesh();
@@ -181,6 +196,6 @@ public:
VARIANT_ENUM_CAST( Mesh::ArrayType );
VARIANT_ENUM_CAST( Mesh::PrimitiveType );
-VARIANT_ENUM_CAST( Mesh::MorphTargetMode );
+VARIANT_ENUM_CAST( Mesh::BlendShapeMode );
#endif
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index fb0fc2a247..ec699ee8e3 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -51,7 +51,7 @@ Error MeshDataTool::create_from_surface(const Ref<Mesh>& p_mesh,int p_surface) {
Array arrays = p_mesh->surface_get_arrays(p_surface);
ERR_FAIL_COND_V( arrays.empty(), ERR_INVALID_PARAMETER );
- DVector<Vector3> varray = arrays[Mesh::ARRAY_VERTEX];
+ PoolVector<Vector3> varray = arrays[Mesh::ARRAY_VERTEX];
int vcount = varray.size();
ERR_FAIL_COND_V( vcount == 0, ERR_INVALID_PARAMETER);
@@ -60,34 +60,34 @@ Error MeshDataTool::create_from_surface(const Ref<Mesh>& p_mesh,int p_surface) {
format = p_mesh->surface_get_format(p_surface);
material=p_mesh->surface_get_material(p_surface);
- DVector<Vector3>::Read vr = varray.read();
+ PoolVector<Vector3>::Read vr = varray.read();
- DVector<Vector3>::Read nr;
+ PoolVector<Vector3>::Read nr;
if (arrays[Mesh::ARRAY_NORMAL].get_type()!=Variant::NIL)
- nr = arrays[Mesh::ARRAY_NORMAL].operator DVector<Vector3>().read();
+ nr = arrays[Mesh::ARRAY_NORMAL].operator PoolVector<Vector3>().read();
- DVector<real_t>::Read ta;
+ PoolVector<real_t>::Read ta;
if (arrays[Mesh::ARRAY_TANGENT].get_type()!=Variant::NIL)
- ta = arrays[Mesh::ARRAY_TANGENT].operator DVector<real_t>().read();
+ ta = arrays[Mesh::ARRAY_TANGENT].operator PoolVector<real_t>().read();
- DVector<Vector2>::Read uv;
+ PoolVector<Vector2>::Read uv;
if (arrays[Mesh::ARRAY_TEX_UV].get_type()!=Variant::NIL)
- uv = arrays[Mesh::ARRAY_TEX_UV].operator DVector<Vector2>().read();
- DVector<Vector2>::Read uv2;
+ uv = arrays[Mesh::ARRAY_TEX_UV].operator PoolVector<Vector2>().read();
+ PoolVector<Vector2>::Read uv2;
if (arrays[Mesh::ARRAY_TEX_UV2].get_type()!=Variant::NIL)
- uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator DVector<Vector2>().read();
+ uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator PoolVector<Vector2>().read();
- DVector<Color>::Read col;
+ PoolVector<Color>::Read col;
if (arrays[Mesh::ARRAY_COLOR].get_type()!=Variant::NIL)
- col = arrays[Mesh::ARRAY_COLOR].operator DVector<Color>().read();
+ col = arrays[Mesh::ARRAY_COLOR].operator PoolVector<Color>().read();
- DVector<real_t>::Read bo;
+ PoolVector<real_t>::Read bo;
if (arrays[Mesh::ARRAY_BONES].get_type()!=Variant::NIL)
- bo = arrays[Mesh::ARRAY_BONES].operator DVector<real_t>().read();
+ bo = arrays[Mesh::ARRAY_BONES].operator PoolVector<real_t>().read();
- DVector<real_t>::Read we;
+ PoolVector<real_t>::Read we;
if (arrays[Mesh::ARRAY_WEIGHTS].get_type()!=Variant::NIL)
- we = arrays[Mesh::ARRAY_WEIGHTS].operator DVector<real_t>().read();
+ we = arrays[Mesh::ARRAY_WEIGHTS].operator PoolVector<real_t>().read();
vertices.resize(vcount);
@@ -129,7 +129,7 @@ Error MeshDataTool::create_from_surface(const Ref<Mesh>& p_mesh,int p_surface) {
}
- DVector<int> indices;
+ PoolVector<int> indices;
if (arrays[Mesh::ARRAY_INDEX].get_type()!=Variant::NIL) {
@@ -137,14 +137,14 @@ Error MeshDataTool::create_from_surface(const Ref<Mesh>& p_mesh,int p_surface) {
} else {
//make code simpler
indices.resize(vcount);
- DVector<int>::Write iw=indices.write();
+ PoolVector<int>::Write iw=indices.write();
for(int i=0;i<vcount;i++)
iw[i]=i;
}
int icount=indices.size();
- DVector<int>::Read r = indices.read();
+ PoolVector<int>::Read r = indices.read();
Map<Point2i,int> edge_indices;
@@ -199,59 +199,59 @@ Error MeshDataTool::commit_to_surface(const Ref<Mesh>& p_mesh) {
int vcount=vertices.size();
- DVector<Vector3> v;
- DVector<Vector3> n;
- DVector<real_t> t;
- DVector<Vector2> u;
- DVector<Vector2> u2;
- DVector<Color> c;
- DVector<real_t> b;
- DVector<real_t> w;
- DVector<int> in;
+ PoolVector<Vector3> v;
+ PoolVector<Vector3> n;
+ PoolVector<real_t> t;
+ PoolVector<Vector2> u;
+ PoolVector<Vector2> u2;
+ PoolVector<Color> c;
+ PoolVector<real_t> b;
+ PoolVector<real_t> w;
+ PoolVector<int> in;
{
v.resize(vcount);
- DVector<Vector3>::Write vr=v.write();
+ PoolVector<Vector3>::Write vr=v.write();
- DVector<Vector3>::Write nr;
+ PoolVector<Vector3>::Write nr;
if (format&Mesh::ARRAY_FORMAT_NORMAL) {
n.resize(vcount);
nr = n.write();
}
- DVector<real_t>::Write ta;
+ PoolVector<real_t>::Write ta;
if (format&Mesh::ARRAY_FORMAT_TANGENT) {
t.resize(vcount*4);
ta = t.write();
}
- DVector<Vector2>::Write uv;
+ PoolVector<Vector2>::Write uv;
if (format&Mesh::ARRAY_FORMAT_TEX_UV) {
u.resize(vcount);
uv = u.write();
}
- DVector<Vector2>::Write uv2;
+ PoolVector<Vector2>::Write uv2;
if (format&Mesh::ARRAY_FORMAT_TEX_UV2) {
u2.resize(vcount);
uv2 = u2.write();
}
- DVector<Color>::Write col;
+ PoolVector<Color>::Write col;
if (format&Mesh::ARRAY_FORMAT_COLOR) {
c.resize(vcount);
col = c.write();
}
- DVector<real_t>::Write bo;
+ PoolVector<real_t>::Write bo;
if (format&Mesh::ARRAY_FORMAT_BONES) {
b.resize(vcount*4);
bo = b.write();
}
- DVector<real_t>::Write we;
+ PoolVector<real_t>::Write we;
if (format&Mesh::ARRAY_FORMAT_WEIGHTS) {
w.resize(vcount*4);
we = w.write();
@@ -299,7 +299,7 @@ Error MeshDataTool::commit_to_surface(const Ref<Mesh>& p_mesh) {
int fc = faces.size();
in.resize(fc*3);
- DVector<int>::Write iw=in.write();
+ PoolVector<int>::Write iw=in.write();
for(int i=0;i<fc;i++) {
iw[i*3+0]=faces[i].v[0];
@@ -328,7 +328,7 @@ Error MeshDataTool::commit_to_surface(const Ref<Mesh>& p_mesh) {
Ref<Mesh> ncmesh=p_mesh;
int sc = ncmesh->get_surface_count();
- ncmesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
+ ncmesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,arr);
ncmesh->surface_set_material(sc,material);
return OK;
@@ -565,62 +565,62 @@ void MeshDataTool::set_material(const Ref<Material> &p_material) {
void MeshDataTool::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("clear"),&MeshDataTool::clear);
- ObjectTypeDB::bind_method(_MD("create_from_surface","mesh","surface"),&MeshDataTool::create_from_surface);
- ObjectTypeDB::bind_method(_MD("commit_to_surface","mesh"),&MeshDataTool::commit_to_surface);
+ ClassDB::bind_method(_MD("clear"),&MeshDataTool::clear);
+ ClassDB::bind_method(_MD("create_from_surface","mesh","surface"),&MeshDataTool::create_from_surface);
+ ClassDB::bind_method(_MD("commit_to_surface","mesh"),&MeshDataTool::commit_to_surface);
- ObjectTypeDB::bind_method(_MD("get_format"),&MeshDataTool::get_format);
+ ClassDB::bind_method(_MD("get_format"),&MeshDataTool::get_format);
- ObjectTypeDB::bind_method(_MD("get_vertex_count"),&MeshDataTool::get_vertex_count);
- ObjectTypeDB::bind_method(_MD("get_edge_count"),&MeshDataTool::get_edge_count);
- ObjectTypeDB::bind_method(_MD("get_face_count"),&MeshDataTool::get_face_count);
+ ClassDB::bind_method(_MD("get_vertex_count"),&MeshDataTool::get_vertex_count);
+ ClassDB::bind_method(_MD("get_edge_count"),&MeshDataTool::get_edge_count);
+ ClassDB::bind_method(_MD("get_face_count"),&MeshDataTool::get_face_count);
- ObjectTypeDB::bind_method(_MD("set_vertex","idx","vertex"),&MeshDataTool::set_vertex);
- ObjectTypeDB::bind_method(_MD("get_vertex","idx"),&MeshDataTool::get_vertex);
+ ClassDB::bind_method(_MD("set_vertex","idx","vertex"),&MeshDataTool::set_vertex);
+ ClassDB::bind_method(_MD("get_vertex","idx"),&MeshDataTool::get_vertex);
- ObjectTypeDB::bind_method(_MD("set_vertex_normal","idx","normal"),&MeshDataTool::set_vertex_normal);
- ObjectTypeDB::bind_method(_MD("get_vertex_normal","idx"),&MeshDataTool::get_vertex_normal);
+ ClassDB::bind_method(_MD("set_vertex_normal","idx","normal"),&MeshDataTool::set_vertex_normal);
+ ClassDB::bind_method(_MD("get_vertex_normal","idx"),&MeshDataTool::get_vertex_normal);
- ObjectTypeDB::bind_method(_MD("set_vertex_tangent","idx","tangent"),&MeshDataTool::set_vertex_tangent);
- ObjectTypeDB::bind_method(_MD("get_vertex_tangent","idx"),&MeshDataTool::get_vertex_tangent);
+ ClassDB::bind_method(_MD("set_vertex_tangent","idx","tangent"),&MeshDataTool::set_vertex_tangent);
+ ClassDB::bind_method(_MD("get_vertex_tangent","idx"),&MeshDataTool::get_vertex_tangent);
- ObjectTypeDB::bind_method(_MD("set_vertex_uv","idx","uv"),&MeshDataTool::set_vertex_uv);
- ObjectTypeDB::bind_method(_MD("get_vertex_uv","idx"),&MeshDataTool::get_vertex_uv);
+ ClassDB::bind_method(_MD("set_vertex_uv","idx","uv"),&MeshDataTool::set_vertex_uv);
+ ClassDB::bind_method(_MD("get_vertex_uv","idx"),&MeshDataTool::get_vertex_uv);
- ObjectTypeDB::bind_method(_MD("set_vertex_uv2","idx","uv2"),&MeshDataTool::set_vertex_uv2);
- ObjectTypeDB::bind_method(_MD("get_vertex_uv2","idx"),&MeshDataTool::get_vertex_uv2);
+ ClassDB::bind_method(_MD("set_vertex_uv2","idx","uv2"),&MeshDataTool::set_vertex_uv2);
+ ClassDB::bind_method(_MD("get_vertex_uv2","idx"),&MeshDataTool::get_vertex_uv2);
- ObjectTypeDB::bind_method(_MD("set_vertex_color","idx","color"),&MeshDataTool::set_vertex_color);
- ObjectTypeDB::bind_method(_MD("get_vertex_color","idx"),&MeshDataTool::get_vertex_color);
+ ClassDB::bind_method(_MD("set_vertex_color","idx","color"),&MeshDataTool::set_vertex_color);
+ ClassDB::bind_method(_MD("get_vertex_color","idx"),&MeshDataTool::get_vertex_color);
- ObjectTypeDB::bind_method(_MD("set_vertex_bones","idx","bones"),&MeshDataTool::set_vertex_bones);
- ObjectTypeDB::bind_method(_MD("get_vertex_bones","idx"),&MeshDataTool::get_vertex_bones);
+ ClassDB::bind_method(_MD("set_vertex_bones","idx","bones"),&MeshDataTool::set_vertex_bones);
+ ClassDB::bind_method(_MD("get_vertex_bones","idx"),&MeshDataTool::get_vertex_bones);
- ObjectTypeDB::bind_method(_MD("set_vertex_weights","idx","weights"),&MeshDataTool::set_vertex_weights);
- ObjectTypeDB::bind_method(_MD("get_vertex_weights","idx"),&MeshDataTool::get_vertex_weights);
+ ClassDB::bind_method(_MD("set_vertex_weights","idx","weights"),&MeshDataTool::set_vertex_weights);
+ ClassDB::bind_method(_MD("get_vertex_weights","idx"),&MeshDataTool::get_vertex_weights);
- ObjectTypeDB::bind_method(_MD("set_vertex_meta","idx","meta"),&MeshDataTool::set_vertex_meta);
- ObjectTypeDB::bind_method(_MD("get_vertex_meta","idx"),&MeshDataTool::get_vertex_meta);
+ ClassDB::bind_method(_MD("set_vertex_meta","idx","meta"),&MeshDataTool::set_vertex_meta);
+ ClassDB::bind_method(_MD("get_vertex_meta","idx"),&MeshDataTool::get_vertex_meta);
- ObjectTypeDB::bind_method(_MD("get_vertex_edges","idx"),&MeshDataTool::get_vertex_edges);
- ObjectTypeDB::bind_method(_MD("get_vertex_faces","idx"),&MeshDataTool::get_vertex_faces);
+ ClassDB::bind_method(_MD("get_vertex_edges","idx"),&MeshDataTool::get_vertex_edges);
+ ClassDB::bind_method(_MD("get_vertex_faces","idx"),&MeshDataTool::get_vertex_faces);
- ObjectTypeDB::bind_method(_MD("get_edge_vertex","idx","vertex"),&MeshDataTool::get_edge_vertex);
- ObjectTypeDB::bind_method(_MD("get_edge_faces","idx","faces"),&MeshDataTool::get_edge_faces);
+ ClassDB::bind_method(_MD("get_edge_vertex","idx","vertex"),&MeshDataTool::get_edge_vertex);
+ ClassDB::bind_method(_MD("get_edge_faces","idx","faces"),&MeshDataTool::get_edge_faces);
- ObjectTypeDB::bind_method(_MD("set_edge_meta","idx","meta"),&MeshDataTool::set_edge_meta);
- ObjectTypeDB::bind_method(_MD("get_edge_meta","idx"),&MeshDataTool::get_edge_meta);
+ ClassDB::bind_method(_MD("set_edge_meta","idx","meta"),&MeshDataTool::set_edge_meta);
+ ClassDB::bind_method(_MD("get_edge_meta","idx"),&MeshDataTool::get_edge_meta);
- ObjectTypeDB::bind_method(_MD("get_face_vertex","idx","vertex"),&MeshDataTool::get_face_vertex);
- ObjectTypeDB::bind_method(_MD("get_face_edge","idx","edge"),&MeshDataTool::get_face_edge);
+ ClassDB::bind_method(_MD("get_face_vertex","idx","vertex"),&MeshDataTool::get_face_vertex);
+ ClassDB::bind_method(_MD("get_face_edge","idx","edge"),&MeshDataTool::get_face_edge);
- ObjectTypeDB::bind_method(_MD("set_face_meta","idx","meta"),&MeshDataTool::set_face_meta);
- ObjectTypeDB::bind_method(_MD("get_face_meta","idx"),&MeshDataTool::get_face_meta);
+ ClassDB::bind_method(_MD("set_face_meta","idx","meta"),&MeshDataTool::set_face_meta);
+ ClassDB::bind_method(_MD("get_face_meta","idx"),&MeshDataTool::get_face_meta);
- ObjectTypeDB::bind_method(_MD("get_face_normal","idx"),&MeshDataTool::get_face_normal);
+ ClassDB::bind_method(_MD("get_face_normal","idx"),&MeshDataTool::get_face_normal);
- ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&MeshDataTool::set_material);
- ObjectTypeDB::bind_method(_MD("get_material","material"),&MeshDataTool::get_material);
+ ClassDB::bind_method(_MD("set_material","material:Material"),&MeshDataTool::set_material);
+ ClassDB::bind_method(_MD("get_material","material"),&MeshDataTool::get_material);
}
MeshDataTool::MeshDataTool(){
diff --git a/scene/resources/mesh_data_tool.h b/scene/resources/mesh_data_tool.h
index 4a26fc2628..fa9c50d2ec 100644
--- a/scene/resources/mesh_data_tool.h
+++ b/scene/resources/mesh_data_tool.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class MeshDataTool : public Reference {
- OBJ_TYPE(MeshDataTool,Reference);
+ GDCLASS(MeshDataTool,Reference);
int format;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 2b1d022299..cc357c4d9b 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -244,19 +244,19 @@ int MeshLibrary::get_last_unused_item_id() const {
void MeshLibrary::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_item","id"),&MeshLibrary::create_item);
- ObjectTypeDB::bind_method(_MD("set_item_name","id","name"),&MeshLibrary::set_item_name);
- ObjectTypeDB::bind_method(_MD("set_item_mesh","id","mesh:Mesh"),&MeshLibrary::set_item_mesh);
- ObjectTypeDB::bind_method(_MD("set_item_navmesh","id","navmesh:NavigationMesh"),&MeshLibrary::set_item_navmesh);
- ObjectTypeDB::bind_method(_MD("set_item_shape","id","shape:Shape"),&MeshLibrary::set_item_shape);
- ObjectTypeDB::bind_method(_MD("get_item_name","id"),&MeshLibrary::get_item_name);
- ObjectTypeDB::bind_method(_MD("get_item_mesh:Mesh","id"),&MeshLibrary::get_item_mesh);
- ObjectTypeDB::bind_method(_MD("get_item_navmesh:NavigationMesh","id"),&MeshLibrary::get_item_navmesh);
- ObjectTypeDB::bind_method(_MD("get_item_shape:Shape","id"),&MeshLibrary::get_item_shape);
- ObjectTypeDB::bind_method(_MD("remove_item","id"),&MeshLibrary::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&MeshLibrary::clear);
- ObjectTypeDB::bind_method(_MD("get_item_list"),&MeshLibrary::get_item_list);
- ObjectTypeDB::bind_method(_MD("get_last_unused_item_id"),&MeshLibrary::get_last_unused_item_id);
+ ClassDB::bind_method(_MD("create_item","id"),&MeshLibrary::create_item);
+ ClassDB::bind_method(_MD("set_item_name","id","name"),&MeshLibrary::set_item_name);
+ ClassDB::bind_method(_MD("set_item_mesh","id","mesh:Mesh"),&MeshLibrary::set_item_mesh);
+ ClassDB::bind_method(_MD("set_item_navmesh","id","navmesh:NavigationMesh"),&MeshLibrary::set_item_navmesh);
+ ClassDB::bind_method(_MD("set_item_shape","id","shape:Shape"),&MeshLibrary::set_item_shape);
+ ClassDB::bind_method(_MD("get_item_name","id"),&MeshLibrary::get_item_name);
+ ClassDB::bind_method(_MD("get_item_mesh:Mesh","id"),&MeshLibrary::get_item_mesh);
+ ClassDB::bind_method(_MD("get_item_navmesh:NavigationMesh","id"),&MeshLibrary::get_item_navmesh);
+ ClassDB::bind_method(_MD("get_item_shape:Shape","id"),&MeshLibrary::get_item_shape);
+ ClassDB::bind_method(_MD("remove_item","id"),&MeshLibrary::remove_item);
+ ClassDB::bind_method(_MD("clear"),&MeshLibrary::clear);
+ ClassDB::bind_method(_MD("get_item_list"),&MeshLibrary::get_item_list);
+ ClassDB::bind_method(_MD("get_last_unused_item_id"),&MeshLibrary::get_last_unused_item_id);
}
MeshLibrary::MeshLibrary() {
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index e4dba193fc..bb8012d3ff 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
class MeshLibrary : public Resource {
- OBJ_TYPE(MeshLibrary,Resource);
+ GDCLASS(MeshLibrary,Resource);
RES_BASE_EXTENSION("gt");
struct Item {
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index c5ade63124..75df4a4e60 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,17 +31,17 @@
-void MultiMesh::_set_transform_array(const DVector<Vector3>& p_array) {
+void MultiMesh::_set_transform_array(const PoolVector<Vector3>& p_array) {
int instance_count = get_instance_count();
- DVector<Vector3> xforms = p_array;
+ PoolVector<Vector3> xforms = p_array;
int len=xforms.size();
ERR_FAIL_COND((len/4) != instance_count);
if (len==0)
return;
- DVector<Vector3>::Read r = xforms.read();
+ PoolVector<Vector3>::Read r = xforms.read();
for(int i=0;i<len/4;i++) {
@@ -56,17 +56,17 @@ void MultiMesh::_set_transform_array(const DVector<Vector3>& p_array) {
}
-DVector<Vector3> MultiMesh::_get_transform_array() const {
+PoolVector<Vector3> MultiMesh::_get_transform_array() const {
int instance_count = get_instance_count();
if (instance_count==0)
- return DVector<Vector3>();
+ return PoolVector<Vector3>();
- DVector<Vector3> xforms;
+ PoolVector<Vector3> xforms;
xforms.resize(instance_count*4);
- DVector<Vector3>::Write w = xforms.write();
+ PoolVector<Vector3>::Write w = xforms.write();
for(int i=0;i<instance_count;i++) {
@@ -82,17 +82,17 @@ DVector<Vector3> MultiMesh::_get_transform_array() const {
}
-void MultiMesh::_set_color_array(const DVector<Color>& p_array) {
+void MultiMesh::_set_color_array(const PoolVector<Color>& p_array) {
int instance_count = get_instance_count();
- DVector<Color> colors = p_array;
+ PoolVector<Color> colors = p_array;
int len=colors.size();
ERR_FAIL_COND(len != instance_count);
if (len==0)
return;
- DVector<Color>::Read r = colors.read();
+ PoolVector<Color>::Read r = colors.read();
for(int i=0;i<len;i++) {
@@ -101,14 +101,14 @@ void MultiMesh::_set_color_array(const DVector<Color>& p_array) {
}
-DVector<Color> MultiMesh::_get_color_array() const {
+PoolVector<Color> MultiMesh::_get_color_array() const {
int instance_count = get_instance_count();
if (instance_count==0)
- return DVector<Color>();
+ return PoolVector<Color>();
- DVector<Color> colors;
+ PoolVector<Color> colors;
colors.resize(instance_count);
for(int i=0;i<instance_count;i++) {
@@ -141,7 +141,7 @@ Ref<Mesh> MultiMesh::get_mesh() const {
void MultiMesh::set_instance_count(int p_count) {
- VisualServer::get_singleton()->multimesh_set_instance_count(multimesh,p_count);
+ VisualServer::get_singleton()->multimesh_allocate(multimesh,p_count,VS::MultimeshTransformFormat(transform_format),VS::MultimeshColorFormat(color_format));
}
int MultiMesh::get_instance_count() const {
@@ -174,84 +174,87 @@ Color MultiMesh::get_instance_color(int p_instance) const {
}
-void MultiMesh::set_aabb(const AABB& p_aabb) {
- aabb=p_aabb;
- VisualServer::get_singleton()->multimesh_set_aabb(multimesh,p_aabb);
+Rect3 MultiMesh::get_aabb() const {
+ return VisualServer::get_singleton()->multimesh_get_aabb(multimesh);
}
-AABB MultiMesh::get_aabb() const {
- return aabb;
-}
-
-void MultiMesh::generate_aabb() {
-
-
-
- ERR_EXPLAIN("Cannot generate AABB if mesh is null.");
- ERR_FAIL_COND(mesh.is_null());
-
- AABB base_aabb=mesh->get_aabb();
+RID MultiMesh::get_rid() const {
- aabb=AABB();
+ return multimesh;
- int instance_count = get_instance_count();
- for(int i=0;i<instance_count;i++) {
+}
- Transform xform = get_instance_transform(i);
- if(i==0)
- aabb=xform.xform(base_aabb);
- else
- aabb.merge_with(xform.xform(base_aabb));
+void MultiMesh::set_color_format(ColorFormat p_color_format) {
- }
+ color_format=p_color_format;
+}
- set_aabb(aabb);
+MultiMesh::ColorFormat MultiMesh::get_color_format() const{
+ return color_format;
}
-RID MultiMesh::get_rid() const {
+void MultiMesh::set_transform_format(TransformFormat p_transform_format){
- return multimesh;
+ transform_format=p_transform_format;
+}
+MultiMesh::TransformFormat MultiMesh::get_transform_format() const{
+ return transform_format;
}
+
void MultiMesh::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
- ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MultiMesh::get_mesh);
- ObjectTypeDB::bind_method(_MD("set_instance_count","count"),&MultiMesh::set_instance_count);
- ObjectTypeDB::bind_method(_MD("get_instance_count"),&MultiMesh::get_instance_count);
- ObjectTypeDB::bind_method(_MD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
- ObjectTypeDB::bind_method(_MD("get_instance_transform","instance"),&MultiMesh::get_instance_transform);
- ObjectTypeDB::bind_method(_MD("set_instance_color","instance","color"),&MultiMesh::set_instance_color);
- ObjectTypeDB::bind_method(_MD("get_instance_color","instance"),&MultiMesh::get_instance_color);
- ObjectTypeDB::bind_method(_MD("set_aabb","visibility_aabb"),&MultiMesh::set_aabb);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&MultiMesh::get_aabb);
+ ClassDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
+ ClassDB::bind_method(_MD("get_mesh:Mesh"),&MultiMesh::get_mesh);
+ ClassDB::bind_method(_MD("set_color_format","format"),&MultiMesh::set_color_format);
+ ClassDB::bind_method(_MD("get_color_format"),&MultiMesh::get_color_format);
+ ClassDB::bind_method(_MD("set_transform_format","format"),&MultiMesh::set_transform_format);
+ ClassDB::bind_method(_MD("get_transform_format"),&MultiMesh::get_transform_format);
+
+ ClassDB::bind_method(_MD("set_instance_count","count"),&MultiMesh::set_instance_count);
+ ClassDB::bind_method(_MD("get_instance_count"),&MultiMesh::get_instance_count);
+ ClassDB::bind_method(_MD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
+ ClassDB::bind_method(_MD("get_instance_transform","instance"),&MultiMesh::get_instance_transform);
+ ClassDB::bind_method(_MD("set_instance_color","instance","color"),&MultiMesh::set_instance_color);
+ ClassDB::bind_method(_MD("get_instance_color","instance"),&MultiMesh::get_instance_color);
+ ClassDB::bind_method(_MD("get_aabb"),&MultiMesh::get_aabb);
- ObjectTypeDB::bind_method(_MD("generate_aabb"),&MultiMesh::generate_aabb);
- ObjectTypeDB::bind_method(_MD("_set_transform_array"),&MultiMesh::_set_transform_array);
- ObjectTypeDB::bind_method(_MD("_get_transform_array"),&MultiMesh::_get_transform_array);
- ObjectTypeDB::bind_method(_MD("_set_color_array"),&MultiMesh::_set_color_array);
- ObjectTypeDB::bind_method(_MD("_get_color_array"),&MultiMesh::_get_color_array);
+ ClassDB::bind_method(_MD("_set_transform_array"),&MultiMesh::_set_transform_array);
+ ClassDB::bind_method(_MD("_get_transform_array"),&MultiMesh::_get_transform_array);
+ ClassDB::bind_method(_MD("_set_color_array"),&MultiMesh::_set_color_array);
+ ClassDB::bind_method(_MD("_get_color_array"),&MultiMesh::_get_color_array);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"color_format",PROPERTY_HINT_ENUM,"None,Byte,Float"), _SCS("set_color_format"), _SCS("get_color_format"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"transform_format",PROPERTY_HINT_ENUM,"2D,3D"), _SCS("set_transform_format"), _SCS("get_transform_format"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"instance_count",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_instance_count"), _SCS("get_instance_count"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY(PropertyInfo(Variant::_AABB,"aabb"), _SCS("set_aabb"), _SCS("get_aabb") );
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
- ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
+
+
+
+ BIND_CONSTANT( TRANSFORM_2D );
+ BIND_CONSTANT( TRANSFORM_3D );
+ BIND_CONSTANT( COLOR_NONE );
+ BIND_CONSTANT( COLOR_8BIT );
+ BIND_CONSTANT( COLOR_FLOAT );
}
MultiMesh::MultiMesh() {
multimesh = VisualServer::get_singleton()->multimesh_create();
+ color_format=COLOR_NONE;
+ transform_format=TRANSFORM_2D;
}
MultiMesh::~MultiMesh() {
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 0cf9e92def..c86b33adcf 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,31 +30,52 @@
#define MULTIMESH_H
#include "scene/resources/mesh.h"
-
+#include "servers/visual_server.h"
class MultiMesh : public Resource {
- OBJ_TYPE( MultiMesh, Resource );
+ GDCLASS( MultiMesh, Resource );
RES_BASE_EXTENSION("mmsh");
+public:
- AABB aabb;
+ enum TransformFormat {
+ TRANSFORM_2D = VS::MULTIMESH_TRANSFORM_2D,
+ TRANSFORM_3D = VS::MULTIMESH_TRANSFORM_3D
+ };
+
+ enum ColorFormat {
+ COLOR_NONE = VS::MULTIMESH_COLOR_NONE,
+ COLOR_8BIT = VS::MULTIMESH_COLOR_8BIT,
+ COLOR_FLOAT = VS::MULTIMESH_COLOR_FLOAT,
+ };
+private:
Ref<Mesh> mesh;
RID multimesh;
+ TransformFormat transform_format;
+ ColorFormat color_format;
+
+
protected:
static void _bind_methods();
- void _set_transform_array(const DVector<Vector3>& p_array);
- DVector<Vector3> _get_transform_array() const;
+ void _set_transform_array(const PoolVector<Vector3>& p_array);
+ PoolVector<Vector3> _get_transform_array() const;
- void _set_color_array(const DVector<Color>& p_array);
- DVector<Color> _get_color_array() const;
+ void _set_color_array(const PoolVector<Color>& p_array);
+ PoolVector<Color> _get_color_array() const;
public:
void set_mesh(const Ref<Mesh>& p_mesh);
Ref<Mesh> get_mesh() const;
+ void set_color_format(ColorFormat p_color_format);
+ ColorFormat get_color_format() const;
+
+ void set_transform_format(TransformFormat p_transform_format);
+ TransformFormat get_transform_format() const;
+
void set_instance_count(int p_count);
int get_instance_count() const;
@@ -64,10 +85,7 @@ public:
void set_instance_color(int p_instance, const Color& p_color);
Color get_instance_color(int p_instance) const;
- void set_aabb(const AABB& p_aabb);
- virtual AABB get_aabb() const;
-
- void generate_aabb();
+ virtual Rect3 get_aabb() const;
virtual RID get_rid() const;
@@ -76,4 +94,8 @@ public:
};
+
+VARIANT_ENUM_CAST( MultiMesh::TransformFormat );
+VARIANT_ENUM_CAST( MultiMesh::ColorFormat);
+
#endif // MULTI_MESH_H
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index f16d68a521..5cefca348b 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,7 +42,7 @@ bool SceneState::can_instance() const {
}
-Node *SceneState::instance(bool p_gen_edit_state) const {
+Node *SceneState::instance(GenEditState p_edit_state) const {
// nodes where instancing failed (because something is missing)
List<Node*> stray_instances;
@@ -76,7 +76,9 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
Node **ret_nodes=(Node**)alloca( sizeof(Node*)*nc );
- bool gen_node_path_cache=p_gen_edit_state && node_path_cache.empty();
+ bool gen_node_path_cache=p_edit_state!=GEN_EDIT_STATE_DISABLED && node_path_cache.empty();
+
+ Map<Ref<Resource>,Ref<Resource> > resources_local_to_scene;
for(int i=0;i<nc;i++) {
@@ -105,9 +107,9 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
//print_line("scene inherit");
Ref<PackedScene> sdata = props[ base_scene_idx ];
ERR_FAIL_COND_V( !sdata.is_valid(), NULL);
- node = sdata->instance(p_gen_edit_state);
+ node = sdata->instance(p_edit_state==GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); //only main gets main edit state
ERR_FAIL_COND_V(!node,NULL);
- if (p_gen_edit_state) {
+ if (p_edit_state!=GEN_EDIT_STATE_DISABLED) {
node->set_scene_inherited_state(sdata->get_state());
}
@@ -121,7 +123,7 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
Ref<PackedScene> sdata = ResourceLoader::load(path,"PackedScene");
ERR_FAIL_COND_V( !sdata.is_valid(), NULL);
- node = sdata->instance(p_gen_edit_state);
+ node = sdata->instance(p_edit_state==GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node,NULL);
} else {
InstancePlaceholder *ip = memnew( InstancePlaceholder );
@@ -132,7 +134,7 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
} else {
Ref<PackedScene> sdata = props[ n.instance&FLAG_MASK ];
ERR_FAIL_COND_V( !sdata.is_valid(), NULL);
- node = sdata->instance(p_gen_edit_state);
+ node = sdata->instance(p_edit_state==GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node,NULL);
}
@@ -148,10 +150,10 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
}
#endif
}
- } else if (ObjectTypeDB::is_type_enabled(snames[n.type])) {
+ } else if (ClassDB::is_class_enabled(snames[n.type])) {
//print_line("created");
//node belongs to this scene and must be created
- Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
+ Object * obj = ClassDB::instance(snames[ n.type ]);
if (!obj || !obj->cast_to<Node>()) {
if (obj) {
memdelete(obj);
@@ -166,8 +168,8 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
} else if (ret_nodes[n.parent]->cast_to<Node2D>()) {
obj = memnew( Node2D );
}
-
}
+
if (!obj) {
obj = memnew( Node );
}
@@ -212,7 +214,43 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
}
} else {
- node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
+ Variant value = props[ nprops[j].value ];
+
+ if (value.get_type()==Variant::OBJECT) {
+ //handle resources that are local to scene by duplicating them if needed
+ Ref<Resource> res = value;
+ if (res.is_valid()) {
+ if (res->is_local_to_scene()) {
+
+ Map<Ref<Resource>,Ref<Resource> >::Element *E=resources_local_to_scene.find(res);
+
+ if (E) {
+ value=E->get();
+ } else {
+
+ Node *base = i==0?node:ret_nodes[0];
+
+ if (p_edit_state==GEN_EDIT_STATE_MAIN) {
+
+ res->local_scene=base;
+ resources_local_to_scene[res]=res;
+
+ } else {
+ Node *base = i==0?node:ret_nodes[0];
+ Ref<Resource> local_dupe = res->duplicate_for_local_scene(base,resources_local_to_scene);
+ resources_local_to_scene[res]=local_dupe;
+ res=local_dupe;
+ value=local_dupe;
+ }
+
+ res->setup_local_to_scene();
+
+ }
+ //must make a copy, because this res is local to scene
+ }
+ }
+ }
+ node->set(snames[ nprops[j].name ],value,&valid);
}
}
}
@@ -491,9 +529,11 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
bool isdefault = ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one());
-// if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
-// continue;
-// }
+ /*
+ if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
+ continue;
+ }
+ */
@@ -576,8 +616,10 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
if (!gi.persistent)
continue;
-// if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
-// continue; //group was instanced, don't add here
+ /*
+ if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
+ continue; //group was instanced, don't add here
+ */
bool skip=false;
for (List<PackState>::Element *F=pack_state_stack.front();F;F=F->next()) {
@@ -639,7 +681,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
// then flag that the node should not be created but reused
if (pack_state_stack.empty()) {
//this node is not part of an instancing process, so save the type
- nd.type=_nm_get_string(p_node->get_type(),name_map);
+ nd.type=_nm_get_string(p_node->get_class(),name_map);
} else {
// this node is part of an instanced process, so do not save the type.
// instead, save that it was instanced
@@ -1128,7 +1170,7 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
ERR_FAIL_COND( !d.has("nodes"));
ERR_FAIL_COND( !d.has("conn_count"));
ERR_FAIL_COND( !d.has("conns"));
-// ERR_FAIL_COND( !d.has("path"));
+ //ERR_FAIL_COND( !d.has("path"));
int version=1;
if (d.has("version"))
@@ -1139,12 +1181,12 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
ERR_FAIL();
}
- DVector<String> snames = d["names"];
+ PoolVector<String> snames = d["names"];
if (snames.size()) {
int namecount = snames.size();
names.resize(namecount);
- DVector<String>::Read r =snames.read();
+ PoolVector<String>::Read r =snames.read();
for(int i=0;i<names.size();i++)
names[i]=r[i];
}
@@ -1166,8 +1208,8 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
nodes.resize(d["node_count"]);
int nc=nodes.size();
if (nc) {
- DVector<int> snodes = d["nodes"];
- DVector<int>::Read r = snodes.read();
+ PoolVector<int> snodes = d["nodes"];
+ PoolVector<int>::Read r = snodes.read();
int idx=0;
for(int i=0;i<nc;i++) {
NodeData &nd = nodes[i];
@@ -1196,8 +1238,8 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
if (cc) {
- DVector<int> sconns = d["conns"];
- DVector<int>::Read r = sconns.read();
+ PoolVector<int> sconns = d["conns"];
+ PoolVector<int>::Read r = sconns.read();
int idx=0;
for(int i=0;i<cc;i++) {
ConnectionData &cd = connections[i];
@@ -1239,18 +1281,18 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
editable_instances[i]=ei[i];
}
-// path=d["path"];
+ //path=d["path"];
}
Dictionary SceneState::get_bundled_scene() const {
- DVector<String> rnames;
+ PoolVector<String> rnames;
rnames.resize(names.size());
if (names.size()) {
- DVector<String>::Write r=rnames.write();
+ PoolVector<String>::Write r=rnames.write();
for(int i=0;i<names.size();i++)
r[i]=names[i];
@@ -1324,7 +1366,7 @@ Dictionary SceneState::get_bundled_scene() const {
d["version"]=PACK_VERSION;
-// d["path"]=path;
+ //d["path"]=path;
return d;
@@ -1659,10 +1701,10 @@ void SceneState::add_editable_instance(const NodePath& p_path){
editable_instances.push_back(p_path);
}
-DVector<String> SceneState::_get_node_groups(int p_idx) const {
+PoolVector<String> SceneState::_get_node_groups(int p_idx) const {
Vector<StringName> groups = get_node_groups(p_idx);
- DVector<String> ret;
+ PoolVector<String> ret;
for(int i=0;i<groups.size();i++)
ret.push_back(groups[i]);
@@ -1674,25 +1716,29 @@ void SceneState::_bind_methods() {
//unbuild API
- ObjectTypeDB::bind_method(_MD("get_node_count"),&SceneState::get_node_count);
- ObjectTypeDB::bind_method(_MD("get_node_type","idx"),&SceneState::get_node_type);
- ObjectTypeDB::bind_method(_MD("get_node_name","idx"),&SceneState::get_node_name);
- ObjectTypeDB::bind_method(_MD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_node_owner_path","idx"),&SceneState::get_node_owner_path);
- ObjectTypeDB::bind_method(_MD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder);
- ObjectTypeDB::bind_method(_MD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder);
- ObjectTypeDB::bind_method(_MD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance);
- ObjectTypeDB::bind_method(_MD("get_node_groups","idx"),&SceneState::_get_node_groups);
- ObjectTypeDB::bind_method(_MD("get_node_property_count","idx"),&SceneState::get_node_property_count);
- ObjectTypeDB::bind_method(_MD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name);
- ObjectTypeDB::bind_method(_MD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value);
- ObjectTypeDB::bind_method(_MD("get_connection_count"),&SceneState::get_connection_count);
- ObjectTypeDB::bind_method(_MD("get_connection_source","idx"),&SceneState::get_connection_source);
- ObjectTypeDB::bind_method(_MD("get_connection_signal","idx"),&SceneState::get_connection_signal);
- ObjectTypeDB::bind_method(_MD("get_connection_target","idx"),&SceneState::get_connection_target);
- ObjectTypeDB::bind_method(_MD("get_connection_method","idx"),&SceneState::get_connection_method);
- ObjectTypeDB::bind_method(_MD("get_connection_flags","idx"),&SceneState::get_connection_flags);
- ObjectTypeDB::bind_method(_MD("get_connection_binds","idx"),&SceneState::get_connection_binds);
+ ClassDB::bind_method(_MD("get_node_count"),&SceneState::get_node_count);
+ ClassDB::bind_method(_MD("get_node_type","idx"),&SceneState::get_node_type);
+ ClassDB::bind_method(_MD("get_node_name","idx"),&SceneState::get_node_name);
+ ClassDB::bind_method(_MD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_node_owner_path","idx"),&SceneState::get_node_owner_path);
+ ClassDB::bind_method(_MD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder);
+ ClassDB::bind_method(_MD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder);
+ ClassDB::bind_method(_MD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance);
+ ClassDB::bind_method(_MD("get_node_groups","idx"),&SceneState::_get_node_groups);
+ ClassDB::bind_method(_MD("get_node_property_count","idx"),&SceneState::get_node_property_count);
+ ClassDB::bind_method(_MD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name);
+ ClassDB::bind_method(_MD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value);
+ ClassDB::bind_method(_MD("get_connection_count"),&SceneState::get_connection_count);
+ ClassDB::bind_method(_MD("get_connection_source","idx"),&SceneState::get_connection_source);
+ ClassDB::bind_method(_MD("get_connection_signal","idx"),&SceneState::get_connection_signal);
+ ClassDB::bind_method(_MD("get_connection_target","idx"),&SceneState::get_connection_target);
+ ClassDB::bind_method(_MD("get_connection_method","idx"),&SceneState::get_connection_method);
+ ClassDB::bind_method(_MD("get_connection_flags","idx"),&SceneState::get_connection_flags);
+ ClassDB::bind_method(_MD("get_connection_binds","idx"),&SceneState::get_connection_binds);
+
+ BIND_CONSTANT( GEN_EDIT_STATE_DISABLED );
+ BIND_CONSTANT( GEN_EDIT_STATE_INSTANCE );
+ BIND_CONSTANT( GEN_EDIT_STATE_MAIN );
}
SceneState::SceneState() {
@@ -1732,20 +1778,20 @@ bool PackedScene::can_instance() const {
return state->can_instance();
}
-Node *PackedScene::instance(bool p_gen_edit_state) const {
+Node *PackedScene::instance(GenEditState p_edit_state) const {
#ifndef TOOLS_ENABLED
- if (p_gen_edit_state) {
+ if (p_edit_state!=GEN_EDIT_STATE_DISABLED) {
ERR_EXPLAIN("Edit state is only for editors, does not work without tools compiled");
- ERR_FAIL_COND_V(p_gen_edit_state,NULL);
+ ERR_FAIL_COND_V(p_edit_state!=GEN_EDIT_STATE_DISABLED,NULL);
}
#endif
- Node *s = state->instance(p_gen_edit_state);
+ Node *s = state->instance((SceneState::GenEditState)p_edit_state);
if (!s)
return NULL;
- if (p_gen_edit_state) {
+ if (p_edit_state!=GEN_EDIT_STATE_DISABLED) {
s->set_scene_instance_state(state);
}
@@ -1791,15 +1837,19 @@ void PackedScene::set_path(const String& p_path,bool p_take_over) {
void PackedScene::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("pack","path:Node"),&PackedScene::pack);
- ObjectTypeDB::bind_method(_MD("instance:Node","gen_edit_state"),&PackedScene::instance,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("can_instance"),&PackedScene::can_instance);
- ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&PackedScene::_set_bundled_scene);
- ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&PackedScene::_get_bundled_scene);
- ObjectTypeDB::bind_method(_MD("get_state:SceneState"),&PackedScene::get_state);
+ ClassDB::bind_method(_MD("pack","path:Node"),&PackedScene::pack);
+ ClassDB::bind_method(_MD("instance:Node","edit_state"),&PackedScene::instance,DEFVAL(false));
+ ClassDB::bind_method(_MD("can_instance"),&PackedScene::can_instance);
+ ClassDB::bind_method(_MD("_set_bundled_scene"),&PackedScene::_set_bundled_scene);
+ ClassDB::bind_method(_MD("_get_bundled_scene"),&PackedScene::_get_bundled_scene);
+ ClassDB::bind_method(_MD("get_state:SceneState"),&PackedScene::get_state);
ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
+ BIND_CONSTANT( GEN_EDIT_STATE_DISABLED );
+ BIND_CONSTANT( GEN_EDIT_STATE_INSTANCE );
+ BIND_CONSTANT( GEN_EDIT_STATE_MAIN );
+
}
PackedScene::PackedScene() {
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index f0e530f88a..381b356b1e 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SceneState : public Reference {
- OBJ_TYPE( SceneState, Reference );
+ GDCLASS( SceneState, Reference );
Vector<StringName> names;
@@ -102,7 +102,7 @@ class SceneState : public Reference {
static bool disable_placeholders;
- DVector<String> _get_node_groups(int p_idx) const;
+ PoolVector<String> _get_node_groups(int p_idx) const;
protected:
@@ -117,6 +117,12 @@ public:
FLAG_MASK=(1<<24)-1,
};
+ enum GenEditState {
+ GEN_EDIT_STATE_DISABLED,
+ GEN_EDIT_STATE_INSTANCE,
+ GEN_EDIT_STATE_MAIN,
+ };
+
static void set_disable_placeholders(bool p_disable);
int find_node_by_path(const NodePath& p_node) const;
@@ -136,7 +142,7 @@ public:
void clear();
bool can_instance() const;
- Node *instance(bool p_gen_edit_state=false) const;
+ Node *instance(GenEditState p_edit_state) const;
//unbuild API
@@ -187,9 +193,11 @@ public:
SceneState();
};
+VARIANT_ENUM_CAST(SceneState::GenEditState)
+
class PackedScene : public Resource {
- OBJ_TYPE(PackedScene, Resource );
+ GDCLASS(PackedScene, Resource );
RES_BASE_EXTENSION("scn");
Ref<SceneState> state;
@@ -203,13 +211,18 @@ protected:
static void _bind_methods();
public:
+ enum GenEditState {
+ GEN_EDIT_STATE_DISABLED,
+ GEN_EDIT_STATE_INSTANCE,
+ GEN_EDIT_STATE_MAIN,
+ };
Error pack(Node *p_scene);
void clear();
bool can_instance() const;
- Node *instance(bool p_gen_edit_state=false) const;
+ Node *instance(GenEditState p_edit_state=GEN_EDIT_STATE_DISABLED) const;
void recreate_state();
void replace_state(Ref<SceneState> p_by);
@@ -225,4 +238,6 @@ public:
};
+VARIANT_ENUM_CAST(PackedScene::GenEditState)
+
#endif // SCENE_PRELOADER_H
diff --git a/scene/resources/plane_shape.cpp b/scene/resources/plane_shape.cpp
index f551414f61..1814eea66c 100644
--- a/scene/resources/plane_shape.cpp
+++ b/scene/resources/plane_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -80,8 +80,8 @@ Plane PlaneShape::get_plane() const {
void PlaneShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_plane","plane"),&PlaneShape::set_plane);
- ObjectTypeDB::bind_method(_MD("get_plane"),&PlaneShape::get_plane);
+ ClassDB::bind_method(_MD("set_plane","plane"),&PlaneShape::set_plane);
+ ClassDB::bind_method(_MD("get_plane"),&PlaneShape::get_plane);
ADD_PROPERTY( PropertyInfo(Variant::PLANE,"plane"), _SCS("set_plane"), _SCS("get_plane") );
diff --git a/scene/resources/plane_shape.h b/scene/resources/plane_shape.h
index 543c433965..88f3a04f05 100644
--- a/scene/resources/plane_shape.h
+++ b/scene/resources/plane_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class PlaneShape : public Shape {
- OBJ_TYPE(PlaneShape,Shape);
+ GDCLASS(PlaneShape,Shape);
Plane plane;
protected:
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index d6d9cbc091..2156487407 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -448,7 +448,7 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) {
ERR_FAIL_COND(!p_data.has("segments"));
ERR_FAIL_COND(!p_data.has("bounds"));
- DVector<Vector2> p=p_data["points"];
+ PoolVector<Vector2> p=p_data["points"];
Array c=p_data["connections"];
ERR_FAIL_COND(c.size()!=p.size());
@@ -458,11 +458,11 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) {
int pc = p.size();
points.resize(pc+2);
- DVector<Vector2>::Read pr=p.read();
+ PoolVector<Vector2>::Read pr=p.read();
for(int i=0;i<pc;i++) {
points[i].pos=pr[i];
- DVector<int> con=c[i];
- DVector<int>::Read cr=con.read();
+ PoolVector<int> con=c[i];
+ PoolVector<int>::Read cr=con.read();
int cc=con.size();
for(int j=0;j<cc;j++) {
@@ -473,19 +473,19 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) {
if (p_data.has("penalties")) {
- DVector<float> penalties=p_data["penalties"];
+ PoolVector<float> penalties=p_data["penalties"];
if (penalties.size()==pc) {
- DVector<float>::Read pr = penalties.read();
+ PoolVector<float>::Read pr = penalties.read();
for(int i=0;i<pc;i++) {
points[i].penalty=pr[i];
}
}
}
- DVector<int> segs=p_data["segments"];
+ PoolVector<int> segs=p_data["segments"];
int sc=segs.size();
ERR_FAIL_COND(sc&1);
- DVector<int>::Read sr = segs.read();
+ PoolVector<int>::Read sr = segs.read();
for(int i=0;i<sc;i+=2) {
Edge e(sr[i],sr[i+1]);
@@ -498,25 +498,25 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) {
Dictionary PolygonPathFinder::_get_data() const{
Dictionary d;
- DVector<Vector2> p;
- DVector<int> ind;
+ PoolVector<Vector2> p;
+ PoolVector<int> ind;
Array connections;
p.resize(points.size()-2);
connections.resize(points.size()-2);
ind.resize(edges.size()*2);
- DVector<float> penalties;
+ PoolVector<float> penalties;
penalties.resize(points.size()-2);
{
- DVector<Vector2>::Write wp=p.write();
- DVector<float>::Write pw=penalties.write();
+ PoolVector<Vector2>::Write wp=p.write();
+ PoolVector<float>::Write pw=penalties.write();
for(int i=0;i<points.size()-2;i++) {
wp[i]=points[i].pos;
pw[i]=points[i].penalty;
- DVector<int> c;
+ PoolVector<int> c;
c.resize(points[i].connections.size());
{
- DVector<int>::Write cw=c.write();
+ PoolVector<int>::Write cw=c.write();
int idx=0;
for (Set<int>::Element *E=points[i].connections.front();E;E=E->next()) {
cw[idx++]=E->get();
@@ -527,7 +527,7 @@ Dictionary PolygonPathFinder::_get_data() const{
}
{
- DVector<int>::Write iw=ind.write();
+ PoolVector<int>::Write iw=ind.write();
int idx=0;
for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
iw[idx++]=E->get().points[0];
@@ -618,17 +618,17 @@ float PolygonPathFinder::get_point_penalty(int p_point) const {
void PolygonPathFinder::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("setup","points","connections"),&PolygonPathFinder::setup);
- ObjectTypeDB::bind_method(_MD("find_path","from","to"),&PolygonPathFinder::find_path);
- ObjectTypeDB::bind_method(_MD("get_intersections","from","to"),&PolygonPathFinder::get_intersections);
- ObjectTypeDB::bind_method(_MD("get_closest_point","point"),&PolygonPathFinder::get_closest_point);
- ObjectTypeDB::bind_method(_MD("is_point_inside","point"),&PolygonPathFinder::is_point_inside);
- ObjectTypeDB::bind_method(_MD("set_point_penalty","idx","penalty"),&PolygonPathFinder::set_point_penalty);
- ObjectTypeDB::bind_method(_MD("get_point_penalty","idx"),&PolygonPathFinder::get_point_penalty);
-
- ObjectTypeDB::bind_method(_MD("get_bounds"),&PolygonPathFinder::get_bounds);
- ObjectTypeDB::bind_method(_MD("_set_data"),&PolygonPathFinder::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&PolygonPathFinder::_get_data);
+ ClassDB::bind_method(_MD("setup","points","connections"),&PolygonPathFinder::setup);
+ ClassDB::bind_method(_MD("find_path","from","to"),&PolygonPathFinder::find_path);
+ ClassDB::bind_method(_MD("get_intersections","from","to"),&PolygonPathFinder::get_intersections);
+ ClassDB::bind_method(_MD("get_closest_point","point"),&PolygonPathFinder::get_closest_point);
+ ClassDB::bind_method(_MD("is_point_inside","point"),&PolygonPathFinder::is_point_inside);
+ ClassDB::bind_method(_MD("set_point_penalty","idx","penalty"),&PolygonPathFinder::set_point_penalty);
+ ClassDB::bind_method(_MD("get_point_penalty","idx"),&PolygonPathFinder::get_point_penalty);
+
+ ClassDB::bind_method(_MD("get_bounds"),&PolygonPathFinder::get_bounds);
+ ClassDB::bind_method(_MD("_set_data"),&PolygonPathFinder::_set_data);
+ ClassDB::bind_method(_MD("_get_data"),&PolygonPathFinder::_get_data);
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h
index dcc38bfb9d..58b8023843 100644
--- a/scene/resources/polygon_path_finder.h
+++ b/scene/resources/polygon_path_finder.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class PolygonPathFinder : public Resource {
- OBJ_TYPE(PolygonPathFinder,Resource);
+ GDCLASS(PolygonPathFinder,Resource);
struct Point {
Vector2 pos;
diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape.cpp
index 73ce4de976..226062bed3 100644
--- a/scene/resources/ray_shape.cpp
+++ b/scene/resources/ray_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -60,8 +60,8 @@ float RayShape::get_length() const {
void RayShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_length","length"),&RayShape::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&RayShape::get_length);
+ ClassDB::bind_method(_MD("set_length","length"),&RayShape::set_length);
+ ClassDB::bind_method(_MD("get_length"),&RayShape::get_length);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"length",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_length"), _SCS("get_length") );
diff --git a/scene/resources/ray_shape.h b/scene/resources/ray_shape.h
index 0218045247..9ee59d5f91 100644
--- a/scene/resources/ray_shape.h
+++ b/scene/resources/ray_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
class RayShape : public Shape {
- OBJ_TYPE(RayShape,Shape);
+ GDCLASS(RayShape,Shape);
float length;
protected:
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp
index bc0f86f0a7..3272125b33 100644
--- a/scene/resources/rectangle_shape_2d.cpp
+++ b/scene/resources/rectangle_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -64,8 +64,8 @@ Rect2 RectangleShape2D::get_rect() const {
void RectangleShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_extents","extents"),&RectangleShape2D::set_extents);
- ObjectTypeDB::bind_method(_MD("get_extents"),&RectangleShape2D::get_extents);
+ ClassDB::bind_method(_MD("set_extents","extents"),&RectangleShape2D::set_extents);
+ ClassDB::bind_method(_MD("get_extents"),&RectangleShape2D::get_extents);
diff --git a/scene/resources/rectangle_shape_2d.h b/scene/resources/rectangle_shape_2d.h
index 1ffbe1e356..6682b67de0 100644
--- a/scene/resources/rectangle_shape_2d.h
+++ b/scene/resources/rectangle_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/resources/shape_2d.h"
class RectangleShape2D : public Shape2D {
- OBJ_TYPE( RectangleShape2D, Shape2D );
+ GDCLASS( RectangleShape2D, Shape2D );
Vector2 extents;
void _update_shape();
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index f28220531b..069127f291 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,63 +36,27 @@ RID RoomBounds::get_rid() const {
return area;
}
-void RoomBounds::set_bounds( const BSP_Tree& p_bounds ) {
- VisualServer::get_singleton()->room_set_bounds(area,p_bounds);
- emit_signal("changed");
-}
-
-BSP_Tree RoomBounds::get_bounds() const {
-
- return VisualServer::get_singleton()->room_get_bounds(area);
-}
-
-void RoomBounds::set_geometry_hint(const DVector<Face3>& p_geometry_hint) {
+void RoomBounds::set_geometry_hint(const PoolVector<Face3>& p_geometry_hint) {
geometry_hint=p_geometry_hint;
}
-DVector<Face3> RoomBounds::get_geometry_hint() const {
+PoolVector<Face3> RoomBounds::get_geometry_hint() const {
return geometry_hint;
}
-void RoomBounds::_regenerate_bsp_cubic() {
-
- if (geometry_hint.size()) {
-
- float err=0;
- geometry_hint= Geometry::wrap_geometry( geometry_hint, &err ); ///< create a "wrap" that encloses the given geometry
- BSP_Tree new_bounds(geometry_hint,err);
- set_bounds(new_bounds);
- }
-
-}
-
-void RoomBounds::_regenerate_bsp() {
-
- if (geometry_hint.size()) {
-
- BSP_Tree new_bounds(geometry_hint,0);
- set_bounds(new_bounds);
- }
-}
void RoomBounds::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_bounds","bsp_tree"),&RoomBounds::set_bounds);
- ObjectTypeDB::bind_method(_MD("get_bounds"),&RoomBounds::get_bounds);
- ObjectTypeDB::bind_method(_MD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
- ObjectTypeDB::bind_method(_MD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp"),&RoomBounds::_regenerate_bsp);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp_cubic"),&RoomBounds::_regenerate_bsp_cubic);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp_cubic"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(_MD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
+ ClassDB::bind_method(_MD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
- ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "geometry_hint"),_SCS("set_geometry_hint"),_SCS("get_geometry_hint") );
+ //ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
+ ADD_PROPERTY( PropertyInfo( Variant::POOL_VECTOR3_ARRAY, "geometry_hint"),_SCS("set_geometry_hint"),_SCS("get_geometry_hint") );
}
diff --git a/scene/resources/room.h b/scene/resources/room.h
index dc5e284838..84d68e5718 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,16 +34,16 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
class RoomBounds : public Resource {
- OBJ_TYPE( RoomBounds, Resource );
+ GDCLASS( RoomBounds, Resource );
RES_BASE_EXTENSION("room");
RID area;
- DVector<Face3> geometry_hint;
+ PoolVector<Face3> geometry_hint;
+
- void _regenerate_bsp();
- void _regenerate_bsp_cubic();
protected:
static void _bind_methods();
@@ -52,15 +52,15 @@ public:
virtual RID get_rid() const;
- void set_bounds( const BSP_Tree& p_bounds );
- BSP_Tree get_bounds() const;
- void set_geometry_hint(const DVector<Face3>& geometry_hint);
- DVector<Face3> get_geometry_hint() const;
+ void set_geometry_hint(const PoolVector<Face3>& geometry_hint);
+ PoolVector<Face3> get_geometry_hint() const;
RoomBounds();
~RoomBounds();
};
+
+
#endif // ROOM_H
diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp
index aae4e85a27..e07e4d3767 100644
--- a/scene/resources/sample.cpp
+++ b/scene/resources/sample.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -119,18 +119,18 @@ int Sample::get_length() const {
return length;
}
-void Sample::set_data(const DVector<uint8_t>& p_buffer) {
+void Sample::set_data(const PoolVector<uint8_t>& p_buffer) {
if (sample.is_valid())
AudioServer::get_singleton()->sample_set_data(sample,p_buffer);
}
-DVector<uint8_t> Sample::get_data() const {
+PoolVector<uint8_t> Sample::get_data() const {
if (sample.is_valid())
return AudioServer::get_singleton()->sample_get_data(sample);
- return DVector<uint8_t>();
+ return PoolVector<uint8_t>();
}
@@ -192,23 +192,23 @@ RID Sample::get_rid() const {
void Sample::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("create","format","stereo","length"),&Sample::create);
- ObjectTypeDB::bind_method(_MD("get_format"),&Sample::get_format);
- ObjectTypeDB::bind_method(_MD("is_stereo"),&Sample::is_stereo);
- ObjectTypeDB::bind_method(_MD("get_length"),&Sample::get_length);
- ObjectTypeDB::bind_method(_MD("set_data","data"),&Sample::set_data);
- ObjectTypeDB::bind_method(_MD("get_data"),&Sample::get_data);
- ObjectTypeDB::bind_method(_MD("set_mix_rate","hz"),&Sample::set_mix_rate);
- ObjectTypeDB::bind_method(_MD("get_mix_rate"),&Sample::get_mix_rate);
- ObjectTypeDB::bind_method(_MD("set_loop_format","format"),&Sample::set_loop_format);
- ObjectTypeDB::bind_method(_MD("get_loop_format"),&Sample::get_loop_format);
- ObjectTypeDB::bind_method(_MD("set_loop_begin","pos"),&Sample::set_loop_begin);
- ObjectTypeDB::bind_method(_MD("get_loop_begin"),&Sample::get_loop_begin);
- ObjectTypeDB::bind_method(_MD("set_loop_end","pos"),&Sample::set_loop_end);
- ObjectTypeDB::bind_method(_MD("get_loop_end"),&Sample::get_loop_end);
-
- ObjectTypeDB::bind_method(_MD("_set_data"),&Sample::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&Sample::_get_data);
+ ClassDB::bind_method(_MD("create","format","stereo","length"),&Sample::create);
+ ClassDB::bind_method(_MD("get_format"),&Sample::get_format);
+ ClassDB::bind_method(_MD("is_stereo"),&Sample::is_stereo);
+ ClassDB::bind_method(_MD("get_length"),&Sample::get_length);
+ ClassDB::bind_method(_MD("set_data","data"),&Sample::set_data);
+ ClassDB::bind_method(_MD("get_data"),&Sample::get_data);
+ ClassDB::bind_method(_MD("set_mix_rate","hz"),&Sample::set_mix_rate);
+ ClassDB::bind_method(_MD("get_mix_rate"),&Sample::get_mix_rate);
+ ClassDB::bind_method(_MD("set_loop_format","format"),&Sample::set_loop_format);
+ ClassDB::bind_method(_MD("get_loop_format"),&Sample::get_loop_format);
+ ClassDB::bind_method(_MD("set_loop_begin","pos"),&Sample::set_loop_begin);
+ ClassDB::bind_method(_MD("get_loop_begin"),&Sample::get_loop_begin);
+ ClassDB::bind_method(_MD("set_loop_end","pos"),&Sample::set_loop_end);
+ ClassDB::bind_method(_MD("get_loop_end"),&Sample::get_loop_end);
+
+ ClassDB::bind_method(_MD("_set_data"),&Sample::_set_data);
+ ClassDB::bind_method(_MD("_get_data"),&Sample::_get_data);
ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "stereo"), _SCS(""), _SCS("is_stereo") );
diff --git a/scene/resources/sample.h b/scene/resources/sample.h
index 18672e41c0..be2cf67954 100644
--- a/scene/resources/sample.h
+++ b/scene/resources/sample.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class Sample : public Resource {
- OBJ_TYPE(Sample, Resource );
+ GDCLASS(Sample, Resource );
RES_BASE_EXTENSION("smp");
public:
@@ -82,8 +82,8 @@ public:
bool is_stereo() const;
int get_length() const;
- void set_data(const DVector<uint8_t>& p_buffer);
- DVector<uint8_t> get_data() const;
+ void set_data(const PoolVector<uint8_t>& p_buffer);
+ PoolVector<uint8_t> get_data() const;
void set_mix_rate(int p_rate);
int get_mix_rate() const;
diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp
index 67481f267d..44895df8fa 100644
--- a/scene/resources/sample_library.cpp
+++ b/scene/resources/sample_library.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -194,18 +194,18 @@ Array SampleLibrary::_get_sample_list() const {
void SampleLibrary::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_sample","name","sample:Sample"),&SampleLibrary::add_sample );
- ObjectTypeDB::bind_method(_MD("get_sample:Sample","name"),&SampleLibrary::get_sample );
- ObjectTypeDB::bind_method(_MD("has_sample","name"),&SampleLibrary::has_sample );
- ObjectTypeDB::bind_method(_MD("remove_sample","name"),&SampleLibrary::remove_sample );
+ ClassDB::bind_method(_MD("add_sample","name","sample:Sample"),&SampleLibrary::add_sample );
+ ClassDB::bind_method(_MD("get_sample:Sample","name"),&SampleLibrary::get_sample );
+ ClassDB::bind_method(_MD("has_sample","name"),&SampleLibrary::has_sample );
+ ClassDB::bind_method(_MD("remove_sample","name"),&SampleLibrary::remove_sample );
- ObjectTypeDB::bind_method(_MD("get_sample_list"),&SampleLibrary::_get_sample_list );
+ ClassDB::bind_method(_MD("get_sample_list"),&SampleLibrary::_get_sample_list );
- ObjectTypeDB::bind_method(_MD("sample_set_volume_db","name","db"),&SampleLibrary::sample_set_volume_db );
- ObjectTypeDB::bind_method(_MD("sample_get_volume_db","name"),&SampleLibrary::sample_get_volume_db );
+ ClassDB::bind_method(_MD("sample_set_volume_db","name","db"),&SampleLibrary::sample_set_volume_db );
+ ClassDB::bind_method(_MD("sample_get_volume_db","name"),&SampleLibrary::sample_get_volume_db );
- ObjectTypeDB::bind_method(_MD("sample_set_pitch_scale","name","pitch"),&SampleLibrary::sample_set_pitch_scale );
- ObjectTypeDB::bind_method(_MD("sample_get_pitch_scale","name"),&SampleLibrary::sample_get_pitch_scale );
+ ClassDB::bind_method(_MD("sample_set_pitch_scale","name","pitch"),&SampleLibrary::sample_set_pitch_scale );
+ ClassDB::bind_method(_MD("sample_get_pitch_scale","name"),&SampleLibrary::sample_get_pitch_scale );
}
diff --git a/scene/resources/sample_library.h b/scene/resources/sample_library.h
index e572aa215a..d09eea64c5 100644
--- a/scene/resources/sample_library.h
+++ b/scene/resources/sample_library.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SampleLibrary : public Resource {
- OBJ_TYPE(SampleLibrary,Resource);
+ GDCLASS(SampleLibrary,Resource);
struct SampleData {
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index 615c092dad..a913687e7f 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -112,7 +112,7 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream*
if (path.find("://")==-1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path=GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
@@ -172,7 +172,7 @@ Error ResourceInteractiveLoaderText::poll() {
if (path.find("://")==-1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
+ path=GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
}
if (remaps.has(path)) {
@@ -240,7 +240,7 @@ Error ResourceInteractiveLoaderText::poll() {
if ( !ResourceCache::has(path)) { //only if it doesn't exist
- Object *obj = ObjectTypeDB::instance(type);
+ Object *obj = ClassDB::instance(type);
if (!obj) {
error_text+="Can't create sub resource of type: "+type;
@@ -310,7 +310,7 @@ Error ResourceInteractiveLoaderText::poll() {
return error;
}
- Object *obj = ObjectTypeDB::instance(res_type);
+ Object *obj = ClassDB::instance(res_type);
if (!obj) {
error_text+="Can't create sub resource of type: "+res_type;
@@ -397,7 +397,7 @@ Error ResourceInteractiveLoaderText::poll() {
int type=-1;
int name=-1;
int instance=-1;
-// int base_scene=-1;
+ //int base_scene=-1;
if (next_tag.fields.has("name")) {
name=packed_scene->get_state()->add_name(next_tag.fields["name"]);
@@ -661,7 +661,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String>
if (path.find("://")==-1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
+ path=GlobalConfig::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
}
@@ -948,9 +948,9 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const
}
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
+ ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
ria->open(f);
return ria;
@@ -984,7 +984,7 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const{
- String ext=p_path.extension().to_lower();
+ String ext=p_path.get_extension().to_lower();
if (ext=="tscn")
return "PackedScene";
else if (ext!="tres")
@@ -999,9 +999,9 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const{
}
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
+ ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
return r;
}
@@ -1016,9 +1016,9 @@ void ResourceFormatLoaderText::get_dependencies(const String& p_path,List<String
}
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
+ ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f,p_dependencies,p_add_types);
@@ -1033,9 +1033,9 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path,const M
}
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
+ ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
return ria->rename_dependencies(f,p_path,p_map);
}
@@ -1115,7 +1115,7 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b
PropertyInfo pi=I->get();
- if (pi.usage&PROPERTY_USAGE_STORAGE || (bundle_resources && pi.usage&PROPERTY_USAGE_BUNDLE)) {
+ if (pi.usage&PROPERTY_USAGE_STORAGE) {
Variant v=res->get(I->get().name);
_find_resources(v);
@@ -1173,7 +1173,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
ERR_FAIL_COND_V( err, ERR_CANT_OPEN );
FileAccessRef _fref(f);
- local_path = Globals::get_singleton()->localize_path(p_path);
+ local_path = GlobalConfig::get_singleton()->localize_path(p_path);
relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
@@ -1206,12 +1206,14 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
{
String title=packed_scene.is_valid()?"[gd_scene ":"[gd_resource ";
if (packed_scene.is_null())
- title+="type=\""+p_resource->get_type()+"\" ";
+ title+="type=\""+p_resource->get_class()+"\" ";
int load_steps=saved_resources.size()+external_resources.size();
- //if (packed_scene.is_valid()) {
- // load_steps+=packed_scene->get_node_count();
- //}
+ /*
+ if (packed_scene.is_valid()) {
+ load_steps+=packed_scene->get_node_count();
+ }
//no, better to not use load steps from nodes, no point to that
+ */
if (load_steps>1) {
title+="load_steps="+itos(load_steps)+" ";
@@ -1235,7 +1237,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
for(int i=0;i<sorted_er.size();i++) {
String p = sorted_er[i]->get_path();
- f->store_string("[ext_resource path=\""+p+"\" type=\""+sorted_er[i]->get_save_type()+"\" id="+itos(i+1)+"]\n"); //bundled
+ f->store_string("[ext_resource path=\""+p+"\" type=\""+sorted_er[i]->get_save_class()+"\" id="+itos(i+1)+"]\n"); //bundled
}
if (external_resources.size())
@@ -1282,7 +1284,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
}
int idx = res->get_subindex();
- line+="type=\""+res->get_type()+"\" id="+itos(idx);
+ line+="type=\""+res->get_class()+"\" id="+itos(idx);
f->store_line(line+"]\n");
if (takeover_paths) {
res->set_path(p_path+"::"+itos(idx),true);
@@ -1299,14 +1301,14 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
List<PropertyInfo> property_list;
res->get_property_list(&property_list);
-// property_list.sort();
+ //property_list.sort();
for(List<PropertyInfo>::Element *PE = property_list.front();PE;PE=PE->next()) {
if (skip_editor && PE->get().name.begins_with("__editor"))
continue;
- if (PE->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && PE->get().usage&PROPERTY_USAGE_BUNDLE)) {
+ if (PE->get().usage&PROPERTY_USAGE_STORAGE) {
String name = PE->get().name;
Variant value = res->get(name);
@@ -1451,7 +1453,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
Error ResourceFormatSaverText::save(const String &p_path,const RES& p_resource,uint32_t p_flags) {
- if (p_path.ends_with(".sct") && p_resource->get_type()!="PackedScene") {
+ if (p_path.ends_with(".sct") && p_resource->get_class()!="PackedScene") {
return ERR_FILE_UNRECOGNIZED;
}
@@ -1467,7 +1469,7 @@ bool ResourceFormatSaverText::recognize(const RES& p_resource) const {
}
void ResourceFormatSaverText::get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const {
- if (p_resource->get_type()=="PackedScene")
+ if (p_resource->get_class()=="PackedScene")
p_extensions->push_back("tscn"); //text scene
else
p_extensions->push_back("tres"); //text resource
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index 6122a1f9d8..ce18f6a702 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -58,7 +58,7 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
bool ignore_resource_parsing;
-// Map<String,String> remaps;
+ //Map<String,String> remaps;
Map<int,ExtResource> ext_resources;
diff --git a/scene/resources/scene_preloader.cpp b/scene/resources/scene_preloader.cpp
deleted file mode 100644
index c031f3c721..0000000000
--- a/scene/resources/scene_preloader.cpp
+++ /dev/null
@@ -1,454 +0,0 @@
-/*************************************************************************/
-/* scene_preloader.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "scene_preloader.h"
-#include "globals.h"
-
-bool ScenePreloader::can_instance() const {
-
- return nodes.size()>0;
-}
-
-Node *ScenePreloader::instance() const {
-
- int nc = nodes.size();
- ERR_FAIL_COND_V(nc==0,NULL);
-
- const StringName*snames=NULL;
- int sname_count=names.size();
- if (sname_count)
- snames=&names[0];
-
- const Variant*props=NULL;
- int prop_count=variants.size();
- if (prop_count)
- props=&variants[0];
-
- Vector<Variant> properties;
-
- const NodeData *nd = &nodes[0];
-
- Node **ret_nodes=(Node**)alloca( sizeof(Node*)*nc );
-
- for(int i=0;i<nc;i++) {
-
- const NodeData &n=nd[i];
-
-
- if (!ObjectTypeDB::is_type_enabled(snames[n.type])) {
- ret_nodes[i]=NULL;
- continue;
- }
-
- Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
- ERR_FAIL_COND_V(!obj,NULL);
- Node *node = obj->cast_to<Node>();
- ERR_FAIL_COND_V(!node,NULL);
-
- int nprop_count=n.properties.size();
- if (nprop_count) {
-
- const NodeData::Property* nprops=&n.properties[0];
-
- for(int j=0;j<nprop_count;j++) {
-
- bool valid;
- node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
- }
-
-
- }
-
- node->set_name( snames[ n.name ] );
- ret_nodes[i]=node;
- if (i>0) {
- ERR_FAIL_INDEX_V(n.parent,i,NULL);
- ERR_FAIL_COND_V(!ret_nodes[n.parent],NULL);
- ret_nodes[n.parent]->add_child(node);
- }
- }
-
-
- //do connections
-
- int cc = connections.size();
- const ConnectionData *cdata = connections.ptr();
-
- for(int i=0;i<cc;i++) {
-
- const ConnectionData &c=cdata[i];
- ERR_FAIL_INDEX_V( c.from, nc, NULL );
- ERR_FAIL_INDEX_V( c.to, nc, NULL );
-
- Vector<Variant> binds;
- if (c.binds.size()) {
- binds.resize(c.binds.size());
- for(int j=0;j<c.binds.size();j++)
- binds[j]=props[ c.binds[j] ];
- }
-
- if (!ret_nodes[c.from] || !ret_nodes[c.to])
- continue;
- ret_nodes[c.from]->connect( snames[ c.signal], ret_nodes[ c.to ], snames[ c.method], binds,CONNECT_PERSIST );
- }
-
- return ret_nodes[0];
-
-}
-
-
-static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) {
-
- if (name_map.has(p_string))
- return name_map[p_string];
-
- int idx = name_map.size();
- name_map[p_string]=idx;
- return idx;
-}
-
-static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) {
-
- if (variant_map.has(p_variant))
- return variant_map[p_variant];
-
- int idx = variant_map.size();
- variant_map[p_variant]=idx;
- return idx;
-}
-
-void ScenePreloader::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map) {
-
- if (p_node!=p_owner && !p_node->get_owner())
- return;
-
- NodeData nd;
- nd.name=_nm_get_string(p_node->get_name(),name_map);
- nd.type=_nm_get_string(p_node->get_type(),name_map);
- nd.parent=p_parent_idx;
-
- List<PropertyInfo> plist;
- p_node->get_property_list(&plist);
- for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
- continue;
-
- NodeData::Property prop;
- prop.name=_nm_get_string(E->get().name,name_map);
- prop.value=_vm_get_variant( p_node->get( E->get().name ), variant_map);
- nd.properties.push_back(prop);
- }
-
- int idx = nodes.size();
- node_map[p_node]=idx;
- nodes.push_back(nd);
-
- for(int i=0;i<p_node->get_child_count();i++) {
-
- Node *c=p_node->get_child(i);
- _parse_node(p_owner,c,idx,name_map,variant_map,node_map);
- }
-
-
-
-}
-
-void ScenePreloader::_parse_connections(Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,bool p_instance) {
-
-
- List<MethodInfo> signals;
- p_node->get_signal_list(&signals);
-
- for(List<MethodInfo>::Element *E=signals.front();E;E=E->next()) {
-
- List<Node::Connection> conns;
- p_node->get_signal_connection_list(E->get().name,&conns);
- for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
-
- const Node::Connection &c = F->get();
- if (!(c.flags&CONNECT_PERSIST))
- continue;
- Node *n=c.target->cast_to<Node>();
- if (!n)
- continue;
-
- if (!node_map.has(n))
- continue;
-
- ConnectionData cd;
- cd.from=node_map[p_node];
- cd.to=node_map[n];
- cd.method=_nm_get_string(c.method,name_map);
- cd.signal=_nm_get_string(c.signal,name_map);
- for(int i=0;i<c.binds.size();i++) {
-
- cd.binds.push_back( _vm_get_variant(c.binds[i],variant_map));
- }
- connections.push_back(cd);
- }
- }
-
-}
-
-
-Error ScenePreloader::load_scene(const String& p_path) {
-
- return ERR_CANT_OPEN;
-#if 0
- if (path==p_path)
- return OK;
-
- String p=Globals::get_singleton()->localize_path(p_path);
- clear();
-
- Node *scene = SceneLoader::load(p);
-
- ERR_FAIL_COND_V(!scene,ERR_CANT_OPEN);
-
- path=p;
-
- Map<StringName,int> name_map;
- HashMap<Variant,int,VariantHasher> variant_map;
- Map<Node*,int> node_map;
-
- _parse_node(scene,scene,-1,name_map,variant_map,node_map);
-
-
- names.resize(name_map.size());
-
- for(Map<StringName,int>::Element *E=name_map.front();E;E=E->next()) {
-
- names[E->get()]=E->key();
- }
-
- variants.resize(variant_map.size());
- const Variant *K=NULL;
- while((K=variant_map.next(K))) {
-
- int idx = variant_map[*K];
- variants[idx]=*K;
- }
-
-
- memdelete(scene); // <- me falto esto :(
- return OK;
-#endif
-}
-
-String ScenePreloader::get_scene_path() const {
-
- return path;
-}
-
-void ScenePreloader::clear() {
-
- names.clear();
- variants.clear();
- nodes.clear();
- connections.clear();
-
-}
-
-void ScenePreloader::_set_bundled_scene(const Dictionary& d) {
-
-
- 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"));
-
- DVector<String> snames = d["names"];
- if (snames.size()) {
-
- int namecount = snames.size();
- names.resize(namecount);
- DVector<String>::Read r =snames.read();
- for(int i=0;i<names.size();i++)
- names[i]=r[i];
- }
-
- Array svariants = d["variants"];
-
- if (svariants.size()) {
- int varcount=svariants.size();
- variants.resize(varcount);
- for(int i=0;i<varcount;i++) {
-
- variants[i]=svariants[i];
- }
-
- } else {
- variants.clear();
- }
-
- nodes.resize(d["node_count"]);
- int nc=nodes.size();
- if (nc) {
- DVector<int> snodes = d["nodes"];
- DVector<int>::Read r = snodes.read();
- int idx=0;
- for(int i=0;i<nc;i++) {
- NodeData &nd = nodes[i];
- nd.parent=r[idx++];
- nd.type=r[idx++];
- nd.name=r[idx++];
- nd.properties.resize(r[idx++]);
- for(int j=0;j<nd.properties.size();j++) {
-
- nd.properties[j].name=r[idx++];
- nd.properties[j].value=r[idx++];
- }
- }
-
- }
-
- connections.resize(d["conn_count"]);
- int cc=connections.size();
-
- if (cc) {
-
- DVector<int> sconns = d["conns"];
- DVector<int>::Read r = sconns.read();
- int idx=0;
- for(int i=0;i<nc;i++) {
- ConnectionData &cd = connections[nc];
- cd.from=r[idx++];
- cd.to=r[idx++];
- cd.signal=r[idx++];
- cd.method=r[idx++];
- cd.binds.resize(r[idx++]);
- for(int j=0;j<cd.binds.size();j++) {
-
- cd.binds[j]=r[idx++];
- }
- }
-
- }
-
-
-
- path=d["path"];
-
-}
-
-Dictionary ScenePreloader::_get_bundled_scene() const {
-
- DVector<String> rnames;
- rnames.resize(names.size());
-
- if (names.size()) {
-
- DVector<String>::Write r=rnames.write();
-
- for(int i=0;i<names.size();i++)
- r[i]=names[i];
- }
-
- Dictionary d;
- d["names"]=rnames;
- d["variants"]=variants;
-
- Vector<int> rnodes;
- d["node_count"]=nodes.size();
-
- for(int i=0;i<nodes.size();i++) {
-
- const NodeData &nd=nodes[i];
- rnodes.push_back(nd.parent);
- rnodes.push_back(nd.type);
- rnodes.push_back(nd.name);
- rnodes.push_back(nd.properties.size());
- for(int j=0;j<nd.properties.size();j++) {
-
- rnodes.push_back(nd.properties[j].name);
- rnodes.push_back(nd.properties[j].value);
- }
- }
-
- d["nodes"]=rnodes;
-
- Vector<int> rconns;
- d["conn_count"]=connections.size();
-
- for(int i=0;i<connections.size();i++) {
-
- const ConnectionData &cd=connections[i];
- rconns.push_back(cd.from);
- rconns.push_back(cd.to);
- rconns.push_back(cd.signal);
- rconns.push_back(cd.method);
- rconns.push_back(cd.binds.size());
- for(int j=0;j<cd.binds.size();j++)
- rconns.push_back(cd.binds[j]);
-
- }
-
- d["conns"]=rconns;
-
- d["path"]=path;
-
- return d;
-
-
-}
-
-void ScenePreloader::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("load_scene","path"),&ScenePreloader::load_scene);
- ObjectTypeDB::bind_method(_MD("get_scene_path"),&ScenePreloader::get_scene_path);
- ObjectTypeDB::bind_method(_MD("instance:Node"),&ScenePreloader::instance);
- ObjectTypeDB::bind_method(_MD("can_instance"),&ScenePreloader::can_instance);
- ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&ScenePreloader::_set_bundled_scene);
- ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&ScenePreloader::_get_bundled_scene);
-
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_BUNDLE),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
-#if 0
- List<String> extensions;
- SceneLoader::get_recognized_extensions(&extensions);
- String exthint;
- for (List<String>::Element*E=extensions.front();E;E=E->next()) {
-
- if (exthint!="")
- exthint+=",";
- exthint+="*."+E->get();
- }
-
- exthint+="; Scenes";
-
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"scene",PROPERTY_HINT_FILE,exthint),_SCS("load_scene"),_SCS("get_scene_path"));
-#endif
-}
-
-ScenePreloader::ScenePreloader() {
-
-
-}
diff --git a/scene/resources/scene_preloader.h b/scene/resources/scene_preloader.h
deleted file mode 100644
index 2317c9e0bd..0000000000
--- a/scene/resources/scene_preloader.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*************************************************************************/
-/* scene_preloader.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SCENE_PRELOADER_H
-#define SCENE_PRELOADER_H
-
-#include "resource.h"
-#include "scene/main/node.h"
-
-class ScenePreloader : public Resource {
-
- OBJ_TYPE( ScenePreloader, Resource );
-
- Vector<StringName> names;
- Vector<Variant> variants;
-
- //missing - instances
- //missing groups
- //missing - owner
- //missing - override names and values
-
- struct NodeData {
-
- int parent;
- int type;
- int name;
-
- struct Property {
-
- int name;
- int value;
- };
-
- Vector<Property> properties;
- };
-
-
- Vector<NodeData> nodes;
-
- struct ConnectionData {
-
- int from;
- int to;
- int signal;
- int method;
- Vector<int> binds;
- };
-
- Vector<ConnectionData> connections;
-
- void _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map);
- void _parse_connections(Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,bool p_instance);
-
- String path;
-
- void _set_bundled_scene(const Dictionary& p_scene);
- Dictionary _get_bundled_scene() const;
-
-protected:
-
-
- static void _bind_methods();
-public:
-
-
- Error load_scene(const String& p_path);
- String get_scene_path() const;
- void clear();
-
- bool can_instance() const;
- Node *instance() const;
-
- ScenePreloader();
-};
-
-#endif // SCENE_PRELOADER_H
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index b8b14fd6fc..71d5a8efa8 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -82,11 +82,11 @@ Rect2 SegmentShape2D::get_rect() const{
void SegmentShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_a","a"),&SegmentShape2D::set_a);
- ObjectTypeDB::bind_method(_MD("get_a"),&SegmentShape2D::get_a);
+ ClassDB::bind_method(_MD("set_a","a"),&SegmentShape2D::set_a);
+ ClassDB::bind_method(_MD("get_a"),&SegmentShape2D::get_a);
- ObjectTypeDB::bind_method(_MD("set_b","b"),&SegmentShape2D::set_b);
- ObjectTypeDB::bind_method(_MD("get_b"),&SegmentShape2D::get_b);
+ ClassDB::bind_method(_MD("set_b","b"),&SegmentShape2D::set_b);
+ ClassDB::bind_method(_MD("get_b"),&SegmentShape2D::get_b);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"a"),_SCS("set_a"),_SCS("get_a") );
@@ -145,8 +145,8 @@ Rect2 RayShape2D::get_rect() const {
void RayShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_length","length"),&RayShape2D::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&RayShape2D::get_length);
+ ClassDB::bind_method(_MD("set_length","length"),&RayShape2D::set_length);
+ ClassDB::bind_method(_MD("get_length"),&RayShape2D::get_length);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"length"),_SCS("set_length"),_SCS("get_length") );
diff --git a/scene/resources/segment_shape_2d.h b/scene/resources/segment_shape_2d.h
index 6f7b2f2d38..775bdabe9d 100644
--- a/scene/resources/segment_shape_2d.h
+++ b/scene/resources/segment_shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/resources/shape_2d.h"
class SegmentShape2D : public Shape2D {
- OBJ_TYPE( SegmentShape2D, Shape2D );
+ GDCLASS( SegmentShape2D, Shape2D );
Vector2 a;
Vector2 b;
@@ -57,7 +57,7 @@ public:
class RayShape2D : public Shape2D {
- OBJ_TYPE( RayShape2D, Shape2D );
+ GDCLASS( RayShape2D, Shape2D );
real_t length;
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index ee9f23dd2a..6afbf32c35 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,37 +39,17 @@ Shader::Mode Shader::get_mode() const {
return mode;
}
-void Shader::set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs,int p_light_ofs) {
+void Shader::set_code(const String& p_code) {
- VisualServer::get_singleton()->shader_set_code(shader,p_vertex,p_fragment,p_light,0,p_fragment_ofs,p_light_ofs);
+ VisualServer::get_singleton()->shader_set_code(shader,p_code);
params_cache_dirty=true;
emit_signal(SceneStringNames::get_singleton()->changed);
}
-String Shader::get_vertex_code() const {
+String Shader::get_code() const {
- return VisualServer::get_singleton()->shader_get_vertex_code(shader);
-}
-
-String Shader::get_fragment_code() const {
-
- return VisualServer::get_singleton()->shader_get_fragment_code(shader);
-
-}
-
-String Shader::get_light_code() const {
-
- return VisualServer::get_singleton()->shader_get_light_code(shader);
-
-}
-
-bool Shader::has_param(const StringName& p_param) const {
-
- if (params_cache_dirty)
- get_param_list(NULL);
-
- return (params_cache.has(p_param));
+ return VisualServer::get_singleton()->shader_get_code(shader);
}
@@ -101,48 +81,6 @@ RID Shader::get_rid() const {
return shader;
}
-Dictionary Shader::_get_code() {
-
- String fs = VisualServer::get_singleton()->shader_get_fragment_code(shader);
- String vs = VisualServer::get_singleton()->shader_get_vertex_code(shader);
- String ls = VisualServer::get_singleton()->shader_get_light_code(shader);
-
- Dictionary c;
- c["fragment"]=fs;
- c["fragment_ofs"]=0;
- c["vertex"]=vs;
- c["vertex_ofs"]=0;
- c["light"]=ls;
- c["light_ofs"]=0;
- Array arr;
- for(const Map<StringName,Ref<Texture> >::Element *E=default_textures.front();E;E=E->next()) {
- arr.push_back(E->key());
- arr.push_back(E->get());
- }
- if (arr.size())
- c["default_tex"]=arr;
- return c;
-}
-
-void Shader::_set_code(const Dictionary& p_string) {
-
- ERR_FAIL_COND(!p_string.has("fragment"));
- ERR_FAIL_COND(!p_string.has("vertex"));
- String light;
- if (p_string.has("light"))
- light=p_string["light"];
-
- set_code(p_string["vertex"],p_string["fragment"],light);
- if (p_string.has("default_tex")) {
- Array arr=p_string["default_tex"];
- if ((arr.size()&1)==0) {
- for(int i=0;i<arr.size();i+=2) {
-
- set_default_texture_param(arr[i],arr[i+1]);
- }
- }
- }
-}
void Shader::set_default_texture_param(const StringName& p_param,const Ref<Texture>& p_texture) {
@@ -171,33 +109,31 @@ void Shader::get_default_texture_param_list(List<StringName>* r_textures) const{
}
}
+bool Shader::has_param(const StringName& p_param) const {
+ return params_cache.has(p_param);
+}
void Shader::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_mode"),&Shader::get_mode);
-
- ObjectTypeDB::bind_method(_MD("set_code","vcode","fcode","lcode","fofs","lofs"),&Shader::set_code,DEFVAL(0),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("get_vertex_code"),&Shader::get_vertex_code);
- ObjectTypeDB::bind_method(_MD("get_fragment_code"),&Shader::get_fragment_code);
- ObjectTypeDB::bind_method(_MD("get_light_code"),&Shader::get_light_code);
+ ClassDB::bind_method(_MD("get_mode"),&Shader::get_mode);
- ObjectTypeDB::bind_method(_MD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
- ObjectTypeDB::bind_method(_MD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
+ ClassDB::bind_method(_MD("set_code","code"),&Shader::set_code);
+ ClassDB::bind_method(_MD("get_code"),&Shader::get_code);
- ObjectTypeDB::bind_method(_MD("has_param","name"),&Shader::has_param);
+ ClassDB::bind_method(_MD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
+ ClassDB::bind_method(_MD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
- ObjectTypeDB::bind_method(_MD("_set_code","code"),&Shader::_set_code);
- ObjectTypeDB::bind_method(_MD("_get_code"),&Shader::_get_code);
+ ClassDB::bind_method(_MD("has_param","name"),&Shader::has_param);
- //ObjectTypeDB::bind_method(_MD("get_param_list"),&Shader::get_fragment_code);
+ //ClassDB::bind_method(_MD("get_param_list"),&Shader::get_fragment_code);
- ADD_PROPERTY( PropertyInfo(Variant::STRING, "_code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_code"), _SCS("_get_code") );
+ ADD_PROPERTY( PropertyInfo(Variant::STRING, "code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("set_code"), _SCS("get_code") );
- BIND_CONSTANT( MODE_MATERIAL );
+ BIND_CONSTANT( MODE_SPATIAL);
BIND_CONSTANT( MODE_CANVAS_ITEM );
- BIND_CONSTANT( MODE_POST_PROCESS );
+ BIND_CONSTANT( MODE_PARTICLES );
}
@@ -214,253 +150,3 @@ Shader::~Shader() {
}
-
-/************ Loader from text ***************/
-
-
-
-RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_original_path, Error *r_error) {
-
- if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
-
- String fragment_code;
- String vertex_code;
- String light_code;
-
- int mode=-1;
-
- Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
-
-
- ERR_EXPLAIN("Unable to open shader file: "+p_path);
- ERR_FAIL_COND_V(err,RES());
- String base_path = p_path.get_base_dir();
-
- if (r_error)
- *r_error=ERR_FILE_CORRUPT;
-
- Ref<Shader> shader;//( memnew( Shader ) );
-
- int line=0;
-
- while(!f->eof_reached()) {
-
- String l = f->get_line();
- line++;
-
- if (mode<=0) {
- l = l.strip_edges();
- int comment = l.find(";");
- if (comment!=-1)
- l=l.substr(0,comment);
- }
-
- if (mode<1)
- vertex_code+="\n";
- if (mode<2)
- fragment_code+="\n";
-
- if (mode < 1 && l=="")
- continue;
-
- if (l.begins_with("[")) {
- l=l.strip_edges();
- if (l=="[params]") {
- if (mode>=0) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [params] section.");
- ERR_FAIL_V(RES());
- }
- mode=0;
- } else if (l=="[vertex]") {
- if (mode>=1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [vertex] section.");
- ERR_FAIL_V(RES());
- }
- mode=1;
- } else if (l=="[fragment]") {
- if (mode>=2) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [fragment] section.");
- ERR_FAIL_V(RES());
- }
- mode=1;
- } else {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Unknown section type: '"+l+"'.");
- ERR_FAIL_V(RES());
- }
- continue;
- }
-
- if (mode==0) {
-
- int eqpos = l.find("=");
- if (eqpos==-1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected '='.");
- ERR_FAIL_V(RES());
- }
-
-
- String right=l.substr(eqpos+1,l.length()).strip_edges();
- if (right=="") {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected value after '='.");
- ERR_FAIL_V(RES());
- }
-
- Variant value;
-
- if (right=="true") {
- value = true;
- } else if (right=="false") {
- value = false;
- } else if (right.is_valid_float()) {
- //is number
- value = right.to_double();
- } else if (right.is_valid_html_color()) {
- //is html color
- value = Color::html(right);
- } else {
- //attempt to parse a constructor
- int popenpos = right.find("(");
-
- if (popenpos==-1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor syntax: "+right);
- ERR_FAIL_V(RES());
- }
-
- int pclosepos = right.find_last(")");
-
- if (pclosepos==-1) {
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor parameter syntax: "+right);
- ERR_FAIL_V(RES());
-
- }
-
- String type = right.substr(0,popenpos);
- String param = right.substr(popenpos+1,pclosepos-popenpos-1).strip_edges();
-
-
- if (type=="tex") {
-
- if (param=="") {
-
- value=RID();
- } else {
-
- String path;
-
- if (param.is_abs_path())
- path=param;
- else
- path=base_path+"/"+param;
-
- Ref<Texture> texture = ResourceLoader::load(path);
- if (!texture.is_valid()) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't find icon at path: "+path);
- ERR_FAIL_V(RES());
- }
-
- value=texture;
- }
-
- } else if (type=="vec3") {
-
- if (param=="") {
- value=Vector3();
- } else {
- Vector<String> params = param.split(",");
- if (params.size()!=3) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for vec3(): '"+right+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- Vector3 v;
- for(int i=0;i<3;i++)
- v[i]=params[i].to_double();
- value=v;
- }
-
-
- } else if (type=="xform") {
-
- if (param=="") {
- value=Transform();
- } else {
-
- Vector<String> params = param.split(",");
- if (params.size()!=12) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for xform(): '"+right+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- Transform t;
- for(int i=0;i<9;i++)
- t.basis[i%3][i/3]=params[i].to_double();
- for(int i=0;i<3;i++)
- t.origin[i]=params[i-9].to_double();
-
- value=t;
- }
-
- } else {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor type: '"+type+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- }
-
- String left= l.substr(0,eqpos);
-
-// shader->set_param(left,value);
- } else if (mode==1) {
-
- vertex_code+=l;
-
- } else if (mode==2) {
-
- fragment_code+=l;
- }
- }
-
- shader->set_code(vertex_code,fragment_code,light_code);
-
- f->close();
- memdelete(f);
- if (r_error)
- *r_error=OK;
-
- return shader;
-}
-
-void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const {
-
- ObjectTypeDB::get_extensions_for_type("Shader", p_extensions);
-}
-
-bool ResourceFormatLoaderShader::handles_type(const String& p_type) const {
-
- return ObjectTypeDB::is_type(p_type, "Shader");
-}
-
-
-String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
-
- if (p_path.extension().to_lower()=="shd")
- return "Shader";
- return "";
-}
-
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 6ee8d4e793..59d7601d98 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,26 +32,24 @@
#include "resource.h"
#include "io/resource_loader.h"
#include "scene/resources/texture.h"
+
class Shader : public Resource {
- OBJ_TYPE(Shader,Resource);
+ GDCLASS(Shader,Resource);
OBJ_SAVE_TYPE( Shader );
RES_BASE_EXTENSION("shd");
public:
enum Mode {
- MODE_MATERIAL,
+ MODE_SPATIAL,
MODE_CANVAS_ITEM,
- MODE_POST_PROCESS,
+ MODE_PARTICLES,
MODE_MAX
};
private:
RID shader;
Mode mode;
- Dictionary _get_code();
- void _set_code(const Dictionary& p_string);
-
// hack the name of performance
// shaders keep a list of ShaderMaterial -> VisualServer name translations, to make
@@ -73,10 +71,8 @@ public:
//void set_mode(Mode p_mode);
Mode get_mode() const;
- void set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs=0,int p_light_ofs=0);
- String get_vertex_code() const;
- String get_fragment_code() const;
- String get_light_code() const;
+ void set_code( const String& p_code);
+ String get_code() const;
void get_param_list(List<PropertyInfo> *p_params) const;
bool has_param(const StringName& p_param) const;
@@ -104,18 +100,18 @@ public:
VARIANT_ENUM_CAST( Shader::Mode );
-class MaterialShader : public Shader {
+class SpatialShader : public Shader {
- OBJ_TYPE(MaterialShader,Shader);
+ GDCLASS(SpatialShader,Shader);
public:
- MaterialShader() : Shader(MODE_MATERIAL) {};
+ SpatialShader() : Shader(MODE_SPATIAL) {};
};
class CanvasItemShader : public Shader {
- OBJ_TYPE(CanvasItemShader,Shader);
+ GDCLASS(CanvasItemShader,Shader);
public:
@@ -123,15 +119,14 @@ public:
};
+class ParticlesShader : public Shader {
+
+ GDCLASS(ParticlesShader,Shader);
-class ResourceFormatLoaderShader : 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;
-};
+ ParticlesShader() : Shader(MODE_PARTICLES) {};
+};
#endif // SHADER_H
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 02faa9425d..10f852f17c 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,6 +29,7 @@
#include "shader_graph.h"
#include "scene/scene_string_names.h"
+#if 0
Array ShaderGraph::_get_node_list(ShaderType p_type) const {
List<int> nodes;
@@ -164,106 +165,106 @@ int ShaderGraph::node_count(ShaderType p_which, int p_type)
void ShaderGraph::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
+ ClassDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
- ObjectTypeDB::bind_method(_MD("node_add","shader_type","node_type","id"),&ShaderGraph::node_add);
- ObjectTypeDB::bind_method(_MD("node_remove","shader_type","id"),&ShaderGraph::node_remove);
- ObjectTypeDB::bind_method(_MD("node_set_pos","shader_type","id","pos"),&ShaderGraph::node_set_pos);
- ObjectTypeDB::bind_method(_MD("node_get_pos","shader_type","id"),&ShaderGraph::node_get_pos);
+ ClassDB::bind_method(_MD("node_add","shader_type","node_type","id"),&ShaderGraph::node_add);
+ ClassDB::bind_method(_MD("node_remove","shader_type","id"),&ShaderGraph::node_remove);
+ ClassDB::bind_method(_MD("node_set_pos","shader_type","id","pos"),&ShaderGraph::node_set_pos);
+ ClassDB::bind_method(_MD("node_get_pos","shader_type","id"),&ShaderGraph::node_get_pos);
- ObjectTypeDB::bind_method(_MD("node_get_type","shader_type","id"),&ShaderGraph::node_get_type);
+ ClassDB::bind_method(_MD("node_get_type","shader_type","id"),&ShaderGraph::node_get_type);
- ObjectTypeDB::bind_method(_MD("get_node_list","shader_type"),&ShaderGraph::_get_node_list);
+ ClassDB::bind_method(_MD("get_node_list","shader_type"),&ShaderGraph::_get_node_list);
- ObjectTypeDB::bind_method(_MD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value);
- ObjectTypeDB::bind_method(_MD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value);
+ ClassDB::bind_method(_MD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value);
+ ClassDB::bind_method(_MD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value);
- ObjectTypeDB::bind_method(_MD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_get_value);
+ ClassDB::bind_method(_MD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value);
+ ClassDB::bind_method(_MD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_get_value);
- ObjectTypeDB::bind_method(_MD("vec_const_node_set_value","shader_type","id","value"),&ShaderGraph::vec_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("vec_const_node_get_value","shader_type","id"),&ShaderGraph::vec_const_node_get_value);
+ ClassDB::bind_method(_MD("vec_const_node_set_value","shader_type","id","value"),&ShaderGraph::vec_const_node_set_value);
+ ClassDB::bind_method(_MD("vec_const_node_get_value","shader_type","id"),&ShaderGraph::vec_const_node_get_value);
- ObjectTypeDB::bind_method(_MD("rgb_const_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("rgb_const_node_get_value","shader_type","id"),&ShaderGraph::rgb_const_node_get_value);
+ ClassDB::bind_method(_MD("rgb_const_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_const_node_set_value);
+ ClassDB::bind_method(_MD("rgb_const_node_get_value","shader_type","id"),&ShaderGraph::rgb_const_node_get_value);
- ObjectTypeDB::bind_method(_MD("xform_const_node_set_value","shader_type","id","value"),&ShaderGraph::xform_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("xform_const_node_get_value","shader_type","id"),&ShaderGraph::xform_const_node_get_value);
+ ClassDB::bind_method(_MD("xform_const_node_set_value","shader_type","id","value"),&ShaderGraph::xform_const_node_set_value);
+ ClassDB::bind_method(_MD("xform_const_node_get_value","shader_type","id"),&ShaderGraph::xform_const_node_get_value);
-// void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
+ //void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
- ObjectTypeDB::bind_method(_MD("texture_node_set_filter_size","shader_type","id","filter_size"),&ShaderGraph::texture_node_set_filter_size);
- ObjectTypeDB::bind_method(_MD("texture_node_get_filter_size","shader_type","id"),&ShaderGraph::texture_node_get_filter_size);
+ ClassDB::bind_method(_MD("texture_node_set_filter_size","shader_type","id","filter_size"),&ShaderGraph::texture_node_set_filter_size);
+ ClassDB::bind_method(_MD("texture_node_get_filter_size","shader_type","id"),&ShaderGraph::texture_node_get_filter_size);
- ObjectTypeDB::bind_method(_MD("texture_node_set_filter_strength","shader_type","id","filter_strength"),&ShaderGraph::texture_node_set_filter_strength);
- ObjectTypeDB::bind_method(_MD("texture_node_get_filter_strength","shader_type","id"),&ShaderGraph::texture_node_get_filter_strength);
+ ClassDB::bind_method(_MD("texture_node_set_filter_strength","shader_type","id","filter_strength"),&ShaderGraph::texture_node_set_filter_strength);
+ ClassDB::bind_method(_MD("texture_node_get_filter_strength","shader_type","id"),&ShaderGraph::texture_node_get_filter_strength);
- ObjectTypeDB::bind_method(_MD("scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::scalar_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("scalar_op_node_get_op","shader_type","id"),&ShaderGraph::scalar_op_node_get_op);
+ ClassDB::bind_method(_MD("scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::scalar_op_node_set_op);
+ ClassDB::bind_method(_MD("scalar_op_node_get_op","shader_type","id"),&ShaderGraph::scalar_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("vec_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("vec_op_node_get_op","shader_type","id"),&ShaderGraph::vec_op_node_get_op);
+ ClassDB::bind_method(_MD("vec_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_op_node_set_op);
+ ClassDB::bind_method(_MD("vec_op_node_get_op","shader_type","id"),&ShaderGraph::vec_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("vec_scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_scalar_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("vec_scalar_op_node_get_op","shader_type","id"),&ShaderGraph::vec_scalar_op_node_get_op);
+ ClassDB::bind_method(_MD("vec_scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_scalar_op_node_set_op);
+ ClassDB::bind_method(_MD("vec_scalar_op_node_get_op","shader_type","id"),&ShaderGraph::vec_scalar_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("rgb_op_node_set_op","shader_type","id","op"),&ShaderGraph::rgb_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("rgb_op_node_get_op","shader_type","id"),&ShaderGraph::rgb_op_node_get_op);
+ ClassDB::bind_method(_MD("rgb_op_node_set_op","shader_type","id","op"),&ShaderGraph::rgb_op_node_set_op);
+ ClassDB::bind_method(_MD("rgb_op_node_get_op","shader_type","id"),&ShaderGraph::rgb_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("xform_vec_mult_node_set_no_translation","shader_type","id","disable"),&ShaderGraph::xform_vec_mult_node_set_no_translation);
- ObjectTypeDB::bind_method(_MD("xform_vec_mult_node_get_no_translation","shader_type","id"),&ShaderGraph::xform_vec_mult_node_get_no_translation);
+ ClassDB::bind_method(_MD("xform_vec_mult_node_set_no_translation","shader_type","id","disable"),&ShaderGraph::xform_vec_mult_node_set_no_translation);
+ ClassDB::bind_method(_MD("xform_vec_mult_node_get_no_translation","shader_type","id"),&ShaderGraph::xform_vec_mult_node_get_no_translation);
- ObjectTypeDB::bind_method(_MD("scalar_func_node_set_function","shader_type","id","func"),&ShaderGraph::scalar_func_node_set_function);
- ObjectTypeDB::bind_method(_MD("scalar_func_node_get_function","shader_type","id"),&ShaderGraph::scalar_func_node_get_function);
+ ClassDB::bind_method(_MD("scalar_func_node_set_function","shader_type","id","func"),&ShaderGraph::scalar_func_node_set_function);
+ ClassDB::bind_method(_MD("scalar_func_node_get_function","shader_type","id"),&ShaderGraph::scalar_func_node_get_function);
- ObjectTypeDB::bind_method(_MD("vec_func_node_set_function","shader_type","id","func"),&ShaderGraph::vec_func_node_set_function);
- ObjectTypeDB::bind_method(_MD("vec_func_node_get_function","shader_type","id"),&ShaderGraph::vec_func_node_get_function);
+ ClassDB::bind_method(_MD("vec_func_node_set_function","shader_type","id","func"),&ShaderGraph::vec_func_node_set_function);
+ ClassDB::bind_method(_MD("vec_func_node_get_function","shader_type","id"),&ShaderGraph::vec_func_node_get_function);
- ObjectTypeDB::bind_method(_MD("input_node_set_name","shader_type","id","name"),&ShaderGraph::input_node_set_name);
- ObjectTypeDB::bind_method(_MD("input_node_get_name","shader_type","id"),&ShaderGraph::input_node_get_name);
+ ClassDB::bind_method(_MD("input_node_set_name","shader_type","id","name"),&ShaderGraph::input_node_set_name);
+ ClassDB::bind_method(_MD("input_node_get_name","shader_type","id"),&ShaderGraph::input_node_get_name);
- ObjectTypeDB::bind_method(_MD("scalar_input_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("scalar_input_node_get_value","shader_type","id"),&ShaderGraph::scalar_input_node_get_value);
+ ClassDB::bind_method(_MD("scalar_input_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_input_node_set_value);
+ ClassDB::bind_method(_MD("scalar_input_node_get_value","shader_type","id"),&ShaderGraph::scalar_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("vec_input_node_set_value","shader_type","id","value"),&ShaderGraph::vec_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("vec_input_node_get_value","shader_type","id"),&ShaderGraph::vec_input_node_get_value);
+ ClassDB::bind_method(_MD("vec_input_node_set_value","shader_type","id","value"),&ShaderGraph::vec_input_node_set_value);
+ ClassDB::bind_method(_MD("vec_input_node_get_value","shader_type","id"),&ShaderGraph::vec_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("rgb_input_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("rgb_input_node_get_value","shader_type","id"),&ShaderGraph::rgb_input_node_get_value);
+ ClassDB::bind_method(_MD("rgb_input_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_input_node_set_value);
+ ClassDB::bind_method(_MD("rgb_input_node_get_value","shader_type","id"),&ShaderGraph::rgb_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("xform_input_node_set_value","shader_type","id","value"),&ShaderGraph::xform_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("xform_input_node_get_value","shader_type","id"),&ShaderGraph::xform_input_node_get_value);
+ ClassDB::bind_method(_MD("xform_input_node_set_value","shader_type","id","value"),&ShaderGraph::xform_input_node_set_value);
+ ClassDB::bind_method(_MD("xform_input_node_get_value","shader_type","id"),&ShaderGraph::xform_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("texture_input_node_set_value","shader_type","id","value:Texture"),&ShaderGraph::texture_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("texture_input_node_get_value:Texture","shader_type","id"),&ShaderGraph::texture_input_node_get_value);
+ ClassDB::bind_method(_MD("texture_input_node_set_value","shader_type","id","value:Texture"),&ShaderGraph::texture_input_node_set_value);
+ ClassDB::bind_method(_MD("texture_input_node_get_value:Texture","shader_type","id"),&ShaderGraph::texture_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("cubemap_input_node_set_value","shader_type","id","value:CubeMap"),&ShaderGraph::cubemap_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("cubemap_input_node_get_value:CubeMap","shader_type","id"),&ShaderGraph::cubemap_input_node_get_value);
+ ClassDB::bind_method(_MD("cubemap_input_node_set_value","shader_type","id","value:CubeMap"),&ShaderGraph::cubemap_input_node_set_value);
+ ClassDB::bind_method(_MD("cubemap_input_node_get_value:CubeMap","shader_type","id"),&ShaderGraph::cubemap_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("comment_node_set_text","shader_type","id","text"),&ShaderGraph::comment_node_set_text);
- ObjectTypeDB::bind_method(_MD("comment_node_get_text","shader_type","id"),&ShaderGraph::comment_node_get_text);
+ ClassDB::bind_method(_MD("comment_node_set_text","shader_type","id","text"),&ShaderGraph::comment_node_set_text);
+ ClassDB::bind_method(_MD("comment_node_get_text","shader_type","id"),&ShaderGraph::comment_node_get_text);
- ObjectTypeDB::bind_method(_MD("color_ramp_node_set_ramp","shader_type","id","colors","offsets"),&ShaderGraph::color_ramp_node_set_ramp);
- ObjectTypeDB::bind_method(_MD("color_ramp_node_get_colors","shader_type","id"),&ShaderGraph::color_ramp_node_get_colors);
- ObjectTypeDB::bind_method(_MD("color_ramp_node_get_offsets","shader_type","id"),&ShaderGraph::color_ramp_node_get_offsets);
+ ClassDB::bind_method(_MD("color_ramp_node_set_ramp","shader_type","id","colors","offsets"),&ShaderGraph::color_ramp_node_set_ramp);
+ ClassDB::bind_method(_MD("color_ramp_node_get_colors","shader_type","id"),&ShaderGraph::color_ramp_node_get_colors);
+ ClassDB::bind_method(_MD("color_ramp_node_get_offsets","shader_type","id"),&ShaderGraph::color_ramp_node_get_offsets);
- ObjectTypeDB::bind_method(_MD("curve_map_node_set_points","shader_type","id","points"),&ShaderGraph::curve_map_node_set_points);
- ObjectTypeDB::bind_method(_MD("curve_map_node_get_points","shader_type","id"),&ShaderGraph::curve_map_node_get_points);
+ ClassDB::bind_method(_MD("curve_map_node_set_points","shader_type","id","points"),&ShaderGraph::curve_map_node_set_points);
+ ClassDB::bind_method(_MD("curve_map_node_get_points","shader_type","id"),&ShaderGraph::curve_map_node_get_points);
- ObjectTypeDB::bind_method(_MD("connect_node:Error","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::connect_node);
- ObjectTypeDB::bind_method(_MD("is_node_connected","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::is_node_connected);
- ObjectTypeDB::bind_method(_MD("disconnect_node","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::disconnect_node);
- ObjectTypeDB::bind_method(_MD("get_node_connections","shader_type"),&ShaderGraph::_get_connections);
+ ClassDB::bind_method(_MD("connect_node:Error","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::connect_node);
+ ClassDB::bind_method(_MD("is_node_connected","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::is_node_connected);
+ ClassDB::bind_method(_MD("disconnect_node","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::disconnect_node);
+ ClassDB::bind_method(_MD("get_node_connections","shader_type"),&ShaderGraph::_get_connections);
- ObjectTypeDB::bind_method(_MD("clear","shader_type"),&ShaderGraph::clear);
+ ClassDB::bind_method(_MD("clear","shader_type"),&ShaderGraph::clear);
- ObjectTypeDB::bind_method(_MD("node_set_state","shader_type","id","state"),&ShaderGraph::node_set_state);
- ObjectTypeDB::bind_method(_MD("node_get_state:Variant","shader_type","id"),&ShaderGraph::node_get_state);
+ ClassDB::bind_method(_MD("node_set_state","shader_type","id","state"),&ShaderGraph::node_set_state);
+ ClassDB::bind_method(_MD("node_get_state:Variant","shader_type","id"),&ShaderGraph::node_get_state);
- ObjectTypeDB::bind_method(_MD("_set_data"),&ShaderGraph::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&ShaderGraph::_get_data);
+ ClassDB::bind_method(_MD("_set_data"),&ShaderGraph::_set_data);
+ ClassDB::bind_method(_MD("_get_data"),&ShaderGraph::_get_data);
ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
@@ -398,21 +399,21 @@ void ShaderGraph::_bind_methods() {
#if 0
- ObjectTypeDB::bind_method(_MD("node_add"),&ShaderGraph::node_add );
- ObjectTypeDB::bind_method(_MD("node_remove"),&ShaderGraph::node_remove );
- ObjectTypeDB::bind_method(_MD("node_set_param"),&ShaderGraph::node_set_param );
- ObjectTypeDB::bind_method(_MD("node_set_pos"),&ShaderGraph::node_set_pos );
+ ClassDB::bind_method(_MD("node_add"),&ShaderGraph::node_add );
+ ClassDB::bind_method(_MD("node_remove"),&ShaderGraph::node_remove );
+ ClassDB::bind_method(_MD("node_set_param"),&ShaderGraph::node_set_param );
+ ClassDB::bind_method(_MD("node_set_pos"),&ShaderGraph::node_set_pos );
- ObjectTypeDB::bind_method(_MD("node_get_pos"),&ShaderGraph::node_get_pos );
- ObjectTypeDB::bind_method(_MD("node_get_param"),&ShaderGraph::node_get_param);
- ObjectTypeDB::bind_method(_MD("node_get_type"),&ShaderGraph::node_get_type);
+ ClassDB::bind_method(_MD("node_get_pos"),&ShaderGraph::node_get_pos );
+ ClassDB::bind_method(_MD("node_get_param"),&ShaderGraph::node_get_param);
+ ClassDB::bind_method(_MD("node_get_type"),&ShaderGraph::node_get_type);
- ObjectTypeDB::bind_method(_MD("connect"),&ShaderGraph::connect );
- ObjectTypeDB::bind_method(_MD("disconnect"),&ShaderGraph::disconnect );
+ ClassDB::bind_method(_MD("connect"),&ShaderGraph::connect );
+ ClassDB::bind_method(_MD("disconnect"),&ShaderGraph::disconnect );
- ObjectTypeDB::bind_method(_MD("get_connections"),&ShaderGraph::_get_connections_helper );
+ ClassDB::bind_method(_MD("get_connections"),&ShaderGraph::_get_connections_helper );
- ObjectTypeDB::bind_method(_MD("clear"),&ShaderGraph::clear );
+ ClassDB::bind_method(_MD("clear"),&ShaderGraph::clear );
BIND_CONSTANT( NODE_IN ); ///< param 0: name
BIND_CONSTANT( NODE_OUT ); ///< param 0: name
@@ -553,8 +554,8 @@ void ShaderGraph::node_add(ShaderType p_type, NodeType p_node_type,int p_id) {
case NODE_XFORM_TO_VEC: {} break; // 3 scalar input: {} break; 1 vec3 output
case NODE_SCALAR_INTERP: {} break; // scalar interpolation (with optional curve)
case NODE_VEC_INTERP: {} break; // vec3 interpolation (with optional curve)
- case NODE_COLOR_RAMP: { node.param1=DVector<Color>(); node.param2=DVector<real_t>();} break; // vec3 interpolation (with optional curve)
- case NODE_CURVE_MAP: { node.param1=DVector<Vector2>();} break; // vec3 interpolation (with optional curve)
+ case NODE_COLOR_RAMP: { node.param1=PoolVector<Color>(); node.param2=PoolVector<real_t>();} break; // vec3 interpolation (with optional curve)
+ case NODE_CURVE_MAP: { node.param1=PoolVector<Vector2>();} break; // vec3 interpolation (with optional curve)
case NODE_SCALAR_INPUT: {node.param1=_find_unique_name("Scalar"); node.param2=0;} break; // scalar uniform (assignable in material)
case NODE_VEC_INPUT: {node.param1=_find_unique_name("Vec3");node.param2=Vector3();} break; // vec3 uniform (assignable in material)
case NODE_RGB_INPUT: {node.param1=_find_unique_name("Color");node.param2=Color();} break; // color uniform (assignable in material)
@@ -1081,7 +1082,7 @@ ShaderGraph::VecFunc ShaderGraph::vec_func_node_get_function(ShaderType p_type,
return VecFunc(func);
}
-void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const DVector<Color>& p_colors, const DVector<real_t>& p_offsets){
+void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const PoolVector<Color>& p_colors, const PoolVector<real_t>& p_offsets){
ERR_FAIL_INDEX(p_type,3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
@@ -1093,27 +1094,27 @@ void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const DVec
}
-DVector<Color> ShaderGraph::color_ramp_node_get_colors(ShaderType p_type,int p_id) const{
+PoolVector<Color> ShaderGraph::color_ramp_node_get_colors(ShaderType p_type,int p_id) const{
- ERR_FAIL_INDEX_V(p_type,3,DVector<Color>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector<Color>());
+ ERR_FAIL_INDEX_V(p_type,3,PoolVector<Color>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),PoolVector<Color>());
const Node& n = shader[p_type].node_map[p_id];
return n.param1;
}
-DVector<real_t> ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type,int p_id) const{
+PoolVector<real_t> ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type,int p_id) const{
- ERR_FAIL_INDEX_V(p_type,3,DVector<real_t>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector<real_t>());
+ ERR_FAIL_INDEX_V(p_type,3,PoolVector<real_t>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),PoolVector<real_t>());
const Node& n = shader[p_type].node_map[p_id];
return n.param2;
}
-void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const DVector<Vector2>& p_points) {
+void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const PoolVector<Vector2>& p_points) {
ERR_FAIL_INDEX(p_type,3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
@@ -1123,10 +1124,10 @@ void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const DVe
}
-DVector<Vector2> ShaderGraph::curve_map_node_get_points(ShaderType p_type,int p_id) const{
+PoolVector<Vector2> ShaderGraph::curve_map_node_get_points(ShaderType p_type,int p_id) const{
- ERR_FAIL_INDEX_V(p_type,3,DVector<Vector2>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector<Vector2>());
+ ERR_FAIL_INDEX_V(p_type,3,PoolVector<Vector2>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),PoolVector<Vector2>());
const Node& n = shader[p_type].node_map[p_id];
return n.param1;
@@ -2449,16 +2450,16 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
DEF_SCALAR(0);
static const int color_ramp_len=512;
- DVector<uint8_t> cramp;
+ PoolVector<uint8_t> cramp;
cramp.resize(color_ramp_len*4);
{
- DVector<Color> colors=p_node->param1;
- DVector<real_t> offsets=p_node->param2;
+ PoolVector<Color> colors=p_node->param1;
+ PoolVector<real_t> offsets=p_node->param2;
int cc =colors.size();
- DVector<uint8_t>::Write crw = cramp.write();
- DVector<Color>::Read cr = colors.read();
- DVector<real_t>::Read ofr = offsets.read();
+ PoolVector<uint8_t>::Write crw = cramp.write();
+ PoolVector<Color>::Read cr = colors.read();
+ PoolVector<real_t>::Read ofr = offsets.read();
int at=0;
Color color_at(0,0,0,1);
@@ -2489,7 +2490,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
}
}
- Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA,cramp);
+ Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA8,cramp);
Ref<ImageTexture> it = memnew( ImageTexture );
it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
@@ -2507,14 +2508,14 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
static const int curve_map_len=256;
bool mapped[256];
zeromem(mapped,sizeof(mapped));
- DVector<uint8_t> cmap;
+ PoolVector<uint8_t> cmap;
cmap.resize(curve_map_len);
{
- DVector<Point2> points=p_node->param1;
+ PoolVector<Point2> points=p_node->param1;
int pc =points.size();
- DVector<uint8_t>::Write cmw = cmap.write();
- DVector<Point2>::Read pr = points.read();
+ PoolVector<uint8_t>::Write cmw = cmap.write();
+ PoolVector<Point2>::Read pr = points.read();
Vector2 prev=Vector2(0,0);
Vector2 prev2=Vector2(0,0);
@@ -2559,7 +2560,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
- Image gradient(curve_map_len,1,0,Image::FORMAT_GRAYSCALE,cmap);
+ Image gradient(curve_map_len,1,0,Image::FORMAT_L8,cmap);
Ref<ImageTexture> it = memnew( ImageTexture );
it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
@@ -2660,3 +2661,5 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
#undef DEF_MATRIX
#undef DEF_VEC
}
+
+#endif
diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h
index 1e6fc3507c..f4e24dbe78 100644
--- a/scene/resources/shader_graph.h
+++ b/scene/resources/shader_graph.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,13 +30,13 @@
#define SHADER_GRAPH_H
-
+#if 0
#include "map.h"
#include "scene/resources/shader.h"
class ShaderGraph : public Shader {
- OBJ_TYPE( ShaderGraph, Shader );
+ GDCLASS( ShaderGraph, Shader );
RES_BASE_EXTENSION("sgp");
public:
@@ -326,12 +326,12 @@ public:
void vec_func_node_set_function(ShaderType p_which,int p_id,VecFunc p_func);
VecFunc vec_func_node_get_function(ShaderType p_which,int p_id) const;
- void color_ramp_node_set_ramp(ShaderType p_which,int p_id,const DVector<Color>& p_colors, const DVector<real_t>& p_offsets);
- DVector<Color> color_ramp_node_get_colors(ShaderType p_which,int p_id) const;
- DVector<real_t> color_ramp_node_get_offsets(ShaderType p_which,int p_id) const;
+ void color_ramp_node_set_ramp(ShaderType p_which,int p_id,const PoolVector<Color>& p_colors, const PoolVector<real_t>& p_offsets);
+ PoolVector<Color> color_ramp_node_get_colors(ShaderType p_which,int p_id) const;
+ PoolVector<real_t> color_ramp_node_get_offsets(ShaderType p_which,int p_id) const;
- void curve_map_node_set_points(ShaderType p_which, int p_id, const DVector<Vector2>& p_points);
- DVector<Vector2> curve_map_node_get_points(ShaderType p_which,int p_id) const;
+ void curve_map_node_set_points(ShaderType p_which, int p_id, const PoolVector<Vector2>& p_points);
+ PoolVector<Vector2> curve_map_node_get_points(ShaderType p_which,int p_id) const;
void input_node_set_name(ShaderType p_which,int p_id,const String& p_name);
String input_node_get_name(ShaderType p_which,int p_id);
@@ -418,7 +418,7 @@ VARIANT_ENUM_CAST( ShaderGraph::GraphError );
class MaterialShaderGraph : public ShaderGraph {
- OBJ_TYPE( MaterialShaderGraph, ShaderGraph );
+ GDCLASS( MaterialShaderGraph, ShaderGraph );
public:
@@ -430,7 +430,7 @@ public:
class CanvasItemShaderGraph : public ShaderGraph {
- OBJ_TYPE( CanvasItemShaderGraph, ShaderGraph );
+ GDCLASS( CanvasItemShaderGraph, ShaderGraph );
public:
@@ -440,5 +440,5 @@ public:
}
};
-
+#endif
#endif // SHADER_GRAPH_H
diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp
index a71e414f61..a90c3b47a9 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#include "scene/main/scene_main_loop.h"
-void Shape::add_vertices_to_array(DVector<Vector3> &array, const Transform& p_xform) {
+void Shape::add_vertices_to_array(PoolVector<Vector3> &array, const Transform& p_xform) {
Vector<Vector3> toadd = _gen_debug_mesh_lines();
@@ -42,7 +42,7 @@ void Shape::add_vertices_to_array(DVector<Vector3> &array, const Transform& p_xf
int base=array.size();
array.resize(base+toadd.size());
- DVector<Vector3>::Write w = array.write();
+ PoolVector<Vector3>::Write w = array.write();
for(int i=0;i<toadd.size();i++) {
w[i+base]=p_xform.xform(toadd[i]);
}
@@ -61,11 +61,11 @@ Ref<Mesh> Shape::get_debug_mesh() {
if (!lines.empty()) {
//make mesh
- DVector<Vector3> array;
+ PoolVector<Vector3> array;
array.resize(lines.size());
{
- DVector<Vector3>::Write w=array.write();
+ PoolVector<Vector3>::Write w=array.write();
for(int i=0;i<lines.size();i++) {
w[i]=lines[i];
}
@@ -77,7 +77,7 @@ Ref<Mesh> Shape::get_debug_mesh() {
SceneTree *st=OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
- debug_mesh_cache->add_surface(Mesh::PRIMITIVE_LINES,arr);
+ debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,arr);
if (st) {
debug_mesh_cache->surface_set_material(0,st->get_debug_collision_material());
diff --git a/scene/resources/shape.h b/scene/resources/shape.h
index bfd423a300..29a93b642c 100644
--- a/scene/resources/shape.h
+++ b/scene/resources/shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@ class Mesh;
class Shape : public Resource {
- OBJ_TYPE( Shape, Resource );
+ GDCLASS( Shape, Resource );
OBJ_SAVE_TYPE( Shape );
RES_BASE_EXTENSION("shp");
RID shape;
@@ -53,7 +53,7 @@ public:
Ref<Mesh> get_debug_mesh();
- void add_vertices_to_array(DVector<Vector3> &array, const Transform& p_xform);
+ void add_vertices_to_array(PoolVector<Vector3> &array, const Transform& p_xform);
Shape();
~Shape();
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index 6a9773bf14..b5a886b4b9 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,14 +47,14 @@ real_t Shape2D::get_custom_solver_bias() const{
}
-bool Shape2D::collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion) {
+bool Shape2D::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) {
ERR_FAIL_COND_V(p_shape.is_null(),false);
int r;
return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,NULL,0,r);
}
-bool Shape2D::collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform){
+bool Shape2D::collide(const Transform2D& p_local_xform, const Ref<Shape2D>& p_shape, const Transform2D& p_shape_xform){
ERR_FAIL_COND_V(p_shape.is_null(),false);
int r;
return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),NULL,0,r);
@@ -62,7 +62,7 @@ bool Shape2D::collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shap
}
-Variant Shape2D::collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion){
+Variant Shape2D::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){
ERR_FAIL_COND_V(p_shape.is_null(),Variant());
const int max_contacts = 16;
@@ -81,7 +81,7 @@ Variant Shape2D::collide_with_motion_and_get_contacts(const Matrix32& p_local_xf
return results;
}
-Variant Shape2D::collide_and_get_contacts(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform){
+Variant Shape2D::collide_and_get_contacts(const Transform2D& p_local_xform, const Ref<Shape2D>& p_shape, const Transform2D& p_shape_xform){
ERR_FAIL_COND_V(p_shape.is_null(),Variant());
const int max_contacts = 16;
@@ -104,12 +104,12 @@ Variant Shape2D::collide_and_get_contacts(const Matrix32& p_local_xform, const
void Shape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_custom_solver_bias","bias"),&Shape2D::set_custom_solver_bias);
- ObjectTypeDB::bind_method(_MD("get_custom_solver_bias"),&Shape2D::get_custom_solver_bias);
- ObjectTypeDB::bind_method(_MD("collide","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide);
- ObjectTypeDB::bind_method(_MD("collide_with_motion","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion);
- ObjectTypeDB::bind_method(_MD("collide_and_get_contacts:Variant","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide_and_get_contacts);
- ObjectTypeDB::bind_method(_MD("collide_with_motion_and_get_contacts:Variant","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion_and_get_contacts);
+ ClassDB::bind_method(_MD("set_custom_solver_bias","bias"),&Shape2D::set_custom_solver_bias);
+ ClassDB::bind_method(_MD("get_custom_solver_bias"),&Shape2D::get_custom_solver_bias);
+ ClassDB::bind_method(_MD("collide","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide);
+ ClassDB::bind_method(_MD("collide_with_motion","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion);
+ ClassDB::bind_method(_MD("collide_and_get_contacts:Variant","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide_and_get_contacts);
+ ClassDB::bind_method(_MD("collide_with_motion_and_get_contacts:Variant","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion_and_get_contacts);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_solver_bias",PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_custom_solver_bias"),_SCS("get_custom_solver_bias"));
}
diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h
index 4059af62c6..6a7ec03a9a 100644
--- a/scene/resources/shape_2d.h
+++ b/scene/resources/shape_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "resource.h"
class Shape2D : public Resource {
- OBJ_TYPE( Shape2D, Resource );
+ GDCLASS( Shape2D, Resource );
OBJ_SAVE_TYPE( Shape2D );
RID shape;
@@ -47,11 +47,11 @@ public:
void set_custom_solver_bias(real_t p_bias);
real_t get_custom_solver_bias() const;
- bool collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_p_shape_motion);
- bool collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform);
+ 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(const Transform2D& p_local_xform, const Ref<Shape2D>& p_shape, const Transform2D& p_shape_xform);
- Variant collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_p_shape_motion);
- Variant collide_and_get_contacts(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& 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_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) {}
virtual Rect2 get_rect() const { return Rect2(); }
diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp
index 4133d2218f..b2270d00c0 100644
--- a/scene/resources/shape_line_2d.cpp
+++ b/scene/resources/shape_line_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -90,11 +90,11 @@ Rect2 LineShape2D::get_rect() const{
void LineShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_normal","normal"),&LineShape2D::set_normal);
- ObjectTypeDB::bind_method(_MD("get_normal"),&LineShape2D::get_normal);
+ ClassDB::bind_method(_MD("set_normal","normal"),&LineShape2D::set_normal);
+ ClassDB::bind_method(_MD("get_normal"),&LineShape2D::get_normal);
- ObjectTypeDB::bind_method(_MD("set_d","d"),&LineShape2D::set_d);
- ObjectTypeDB::bind_method(_MD("get_d"),&LineShape2D::get_d);
+ ClassDB::bind_method(_MD("set_d","d"),&LineShape2D::set_d);
+ ClassDB::bind_method(_MD("get_d"),&LineShape2D::get_d);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"normal"),_SCS("set_normal"),_SCS("get_normal") );
ADD_PROPERTY( PropertyInfo(Variant::REAL,"d"),_SCS("set_d"),_SCS("get_d") );
diff --git a/scene/resources/shape_line_2d.h b/scene/resources/shape_line_2d.h
index f6f75e7a95..abad5f6a24 100644
--- a/scene/resources/shape_line_2d.h
+++ b/scene/resources/shape_line_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/resources/shape_2d.h"
class LineShape2D : public Shape2D {
- OBJ_TYPE( LineShape2D, Shape2D );
+ GDCLASS( LineShape2D, Shape2D );
Vector2 normal;
real_t d;
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
new file mode 100644
index 0000000000..2a4fbfa8d4
--- /dev/null
+++ b/scene/resources/sky_box.cpp
@@ -0,0 +1,159 @@
+#include "sky_box.h"
+#include "io/image_loader.h"
+
+
+void SkyBox::set_radiance_size(RadianceSize p_size) {
+ ERR_FAIL_INDEX(p_size,RADIANCE_SIZE_MAX);
+
+ radiance_size=p_size;
+ _radiance_changed();
+}
+
+SkyBox::RadianceSize SkyBox::get_radiance_size() const {
+
+ return radiance_size;
+}
+
+void SkyBox::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_radiance_size","size"),&SkyBox::set_radiance_size);
+ ClassDB::bind_method(_MD("get_radiance_size"),&SkyBox::get_radiance_size);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"radiance_size",PROPERTY_HINT_ENUM,"256,512,1024,2048"),_SCS("set_radiance_size"),_SCS("get_radiance_size"));
+
+
+ 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 );
+}
+
+SkyBox::SkyBox()
+{
+ radiance_size=RADIANCE_SIZE_512;
+}
+
+/////////////////////////////////////////
+
+
+
+void ImageSkyBox::_radiance_changed() {
+
+ if (cube_map_valid) {
+ static const int size[RADIANCE_SIZE_MAX]={
+ 256,512,1024,2048
+ };
+ VS::get_singleton()->skybox_set_texture(sky_box,cube_map,size[get_radiance_size()]);
+ }
+}
+
+void ImageSkyBox::set_image_path(ImagePath p_image,const String &p_path) {
+
+ ERR_FAIL_INDEX(p_image,IMAGE_PATH_MAX);
+ image_path[p_image]=p_path;
+
+ bool all_ok=true;
+ for(int i=0;i<IMAGE_PATH_MAX;i++) {
+ if (image_path[i]==String()) {
+ all_ok=false;
+ }
+ }
+
+ cube_map_valid=false;
+
+ if (all_ok) {
+
+ Image images[IMAGE_PATH_MAX];
+ int w=0,h=0;
+ Image::Format format;
+
+ for(int i=0;i<IMAGE_PATH_MAX;i++) {
+ Error err = ImageLoader::load_image(image_path[i],&images[i]);
+ if (err) {
+ ERR_PRINTS("Error loading image for skybox: "+image_path[i]);
+ return;
+ }
+
+ if (i==0) {
+ w=images[0].get_width();
+ h=images[0].get_height();
+ format=images[0].get_format();
+ } else {
+ if (images[i].get_width()!=w || images[i].get_height()!=h || images[i].get_format()!=format) {
+ ERR_PRINTS("Image size mismatch ("+itos(images[i].get_width())+","+itos(images[i].get_height())+":"+Image::get_format_name(images[i].get_format())+" when it should be "+itos(w)+","+itos(h)+":"+Image::get_format_name(format)+"): "+image_path[i]);
+ return;
+ }
+ }
+ }
+
+ VS::get_singleton()->texture_allocate(cube_map,w,h,format,VS::TEXTURE_FLAG_FILTER|VS::TEXTURE_FLAG_CUBEMAP|VS::TEXTURE_FLAG_MIPMAPS);
+ for(int i=0;i<IMAGE_PATH_MAX;i++) {
+ VS::get_singleton()->texture_set_data(cube_map,images[i],VS::CubeMapSide(i));
+ }
+
+ cube_map_valid=true;
+ _radiance_changed();
+ }
+
+
+}
+
+String ImageSkyBox::get_image_path(ImagePath p_image) const {
+
+ ERR_FAIL_INDEX_V(p_image,IMAGE_PATH_MAX,String());
+ return image_path[p_image];
+
+}
+
+RID ImageSkyBox::get_rid() const {
+
+ return sky_box;
+}
+
+void ImageSkyBox::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_image_path","image","path"),&ImageSkyBox::set_image_path);
+ ClassDB::bind_method(_MD("get_image_path","image"),&ImageSkyBox::get_image_path);
+
+ List<String> extensions;
+ ImageLoader::get_recognized_extensions(&extensions);
+ String hints;
+ for(List<String>::Element *E=extensions.front();E;E=E->next()) {
+ if (hints!=String()) {
+ hints+=",";
+ }
+ hints+="*."+E->get();
+ }
+
+ ADD_GROUP("Image Path","image_path_");
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_x",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_x",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_y",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_y",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_z",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_z",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_Z);
+
+ BIND_CONSTANT( IMAGE_PATH_NEGATIVE_X );
+ BIND_CONSTANT( IMAGE_PATH_POSITIVE_X );
+ BIND_CONSTANT( IMAGE_PATH_NEGATIVE_Y );
+ BIND_CONSTANT( IMAGE_PATH_POSITIVE_Y );
+ BIND_CONSTANT( IMAGE_PATH_NEGATIVE_Z );
+ BIND_CONSTANT( IMAGE_PATH_POSITIVE_Z );
+ BIND_CONSTANT( IMAGE_PATH_MAX );
+
+}
+
+ImageSkyBox::ImageSkyBox() {
+
+ cube_map=VS::get_singleton()->texture_create();
+ sky_box=VS::get_singleton()->skybox_create();
+ cube_map_valid=false;
+}
+
+ImageSkyBox::~ImageSkyBox() {
+
+ VS::get_singleton()->free(cube_map);
+ VS::get_singleton()->free(sky_box);
+}
+
diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h
new file mode 100644
index 0000000000..a3caf15aa7
--- /dev/null
+++ b/scene/resources/sky_box.h
@@ -0,0 +1,71 @@
+#ifndef SKYBOX_H
+#define SKYBOX_H
+
+#include "scene/resources/texture.h"
+
+class SkyBox : public Resource {
+ GDCLASS(SkyBox,Resource);
+
+public:
+
+ enum RadianceSize {
+ RADIANCE_SIZE_256,
+ RADIANCE_SIZE_512,
+ RADIANCE_SIZE_1024,
+ RADIANCE_SIZE_2048,
+ RADIANCE_SIZE_MAX
+ };
+private:
+
+ RadianceSize radiance_size;
+protected:
+ static void _bind_methods();
+ virtual void _radiance_changed()=0;
+public:
+
+ void set_radiance_size(RadianceSize p_size);
+ RadianceSize get_radiance_size() const;
+ SkyBox();
+};
+
+VARIANT_ENUM_CAST(SkyBox::RadianceSize)
+
+
+class ImageSkyBox : public SkyBox {
+ GDCLASS(ImageSkyBox,SkyBox);
+
+public:
+
+ enum ImagePath {
+ IMAGE_PATH_NEGATIVE_X,
+ IMAGE_PATH_POSITIVE_X,
+ IMAGE_PATH_NEGATIVE_Y,
+ IMAGE_PATH_POSITIVE_Y,
+ IMAGE_PATH_NEGATIVE_Z,
+ IMAGE_PATH_POSITIVE_Z,
+ IMAGE_PATH_MAX
+ };
+private:
+ RID cube_map;
+ RID sky_box;
+ bool cube_map_valid;
+
+ String image_path[IMAGE_PATH_MAX];
+protected:
+ static void _bind_methods();
+ virtual void _radiance_changed();
+public:
+
+ void set_image_path(ImagePath p_image, const String &p_path);
+ String get_image_path(ImagePath p_image) const;
+
+ virtual RID get_rid() const;
+
+ ImageSkyBox();
+ ~ImageSkyBox();
+};
+
+VARIANT_ENUM_CAST(ImageSkyBox::ImagePath)
+
+
+#endif // SKYBOX_H
diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp
index d328ee3de4..3f0d2824ce 100644
--- a/scene/resources/space_2d.cpp
+++ b/scene/resources/space_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -48,8 +48,8 @@ bool Space2D::is_active() const {
void Space2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_active","active"),&Space2D::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&Space2D::is_active);
+ ClassDB::bind_method(_MD("set_active","active"),&Space2D::set_active);
+ ClassDB::bind_method(_MD("is_active"),&Space2D::is_active);
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"active"),_SCS("set_active"),_SCS("is_active") );
diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h
index 270f8de3ea..82aef89c07 100644
--- a/scene/resources/space_2d.h
+++ b/scene/resources/space_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class Space2D : public Resource {
- OBJ_TYPE(Space2D,Resource);
+ GDCLASS(Space2D,Resource);
bool active;
RID space;
protected:
diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp
index 4764937371..bcfb164b4c 100644
--- a/scene/resources/sphere_shape.cpp
+++ b/scene/resources/sphere_shape.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -75,8 +75,8 @@ float SphereShape::get_radius() const {
void SphereShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&SphereShape::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&SphereShape::get_radius);
+ ClassDB::bind_method(_MD("set_radius","radius"),&SphereShape::set_radius);
+ ClassDB::bind_method(_MD("get_radius"),&SphereShape::get_radius);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_radius"), _SCS("get_radius"));
diff --git a/scene/resources/sphere_shape.h b/scene/resources/sphere_shape.h
index 50682f38bb..990564be80 100644
--- a/scene/resources/sphere_shape.h
+++ b/scene/resources/sphere_shape.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class SphereShape : public Shape {
- OBJ_TYPE(SphereShape,Shape);
+ GDCLASS(SphereShape,Shape);
float radius;
protected:
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 59246dfabe..e5e32ba4e9 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -70,25 +70,26 @@ Size2 StyleBox::get_center_size() const {
void StyleBox::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("test_mask","point","rect"),&StyleBox::test_mask);
+ ClassDB::bind_method(_MD("test_mask","point","rect"),&StyleBox::test_mask);
- ObjectTypeDB::bind_method(_MD("set_default_margin","margin","offset"),&StyleBox::set_default_margin);
- ObjectTypeDB::bind_method(_MD("get_default_margin","margin"),&StyleBox::get_default_margin);
+ ClassDB::bind_method(_MD("set_default_margin","margin","offset"),&StyleBox::set_default_margin);
+ ClassDB::bind_method(_MD("get_default_margin","margin"),&StyleBox::get_default_margin);
-// ObjectTypeDB::bind_method(_MD("set_default_margin"),&StyleBox::set_default_margin);
-// ObjectTypeDB::bind_method(_MD("get_default_margin"),&StyleBox::get_default_margin);
+ //ClassDB::bind_method(_MD("set_default_margin"),&StyleBox::set_default_margin);
+ //ClassDB::bind_method(_MD("get_default_margin"),&StyleBox::get_default_margin);
- ObjectTypeDB::bind_method(_MD("get_margin","margin"),&StyleBox::get_margin);
- ObjectTypeDB::bind_method(_MD("get_minimum_size"),&StyleBox::get_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_center_size"),&StyleBox::get_center_size);
- ObjectTypeDB::bind_method(_MD("get_offset"),&StyleBox::get_offset);
+ ClassDB::bind_method(_MD("get_margin","margin"),&StyleBox::get_margin);
+ ClassDB::bind_method(_MD("get_minimum_size"),&StyleBox::get_minimum_size);
+ ClassDB::bind_method(_MD("get_center_size"),&StyleBox::get_center_size);
+ ClassDB::bind_method(_MD("get_offset"),&StyleBox::get_offset);
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","rect"),&StyleBox::draw);
+ ClassDB::bind_method(_MD("draw","canvas_item","rect"),&StyleBox::draw);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/left", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/right", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/top", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/bottom", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_BOTTOM );
+ ADD_GROUP("Content Margin","content_margin_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_left", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_LEFT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_right", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_RIGHT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_top", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_bottom", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_BOTTOM );
}
@@ -141,7 +142,7 @@ void StyleBoxTexture::draw(RID p_canvas_item,const Rect2& p_rect) const {
r.pos.y-=expand_margin[MARGIN_TOP];
r.size.x+=expand_margin[MARGIN_LEFT]+expand_margin[MARGIN_RIGHT];
r.size.y+=expand_margin[MARGIN_TOP]+expand_margin[MARGIN_BOTTOM];
- VisualServer::get_singleton()->canvas_item_add_style_box( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
+ VisualServer::get_singleton()->canvas_item_add_nine_patch( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center,modulate);
}
void StyleBoxTexture::set_draw_center(bool p_draw) {
@@ -208,38 +209,41 @@ Color StyleBoxTexture::get_modulate() const {
void StyleBoxTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&StyleBoxTexture::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&StyleBoxTexture::get_texture);
+ ClassDB::bind_method(_MD("set_texture","texture:Texture"),&StyleBoxTexture::set_texture);
+ ClassDB::bind_method(_MD("get_texture:Texture"),&StyleBoxTexture::get_texture);
- ObjectTypeDB::bind_method(_MD("set_margin_size","margin","size"),&StyleBoxTexture::set_margin_size);
- ObjectTypeDB::bind_method(_MD("get_margin_size","margin"),&StyleBoxTexture::get_margin_size);
+ ClassDB::bind_method(_MD("set_margin_size","margin","size"),&StyleBoxTexture::set_margin_size);
+ ClassDB::bind_method(_MD("get_margin_size","margin"),&StyleBoxTexture::get_margin_size);
- ObjectTypeDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxTexture::set_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxTexture::get_expand_margin_size);
+ ClassDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxTexture::set_expand_margin_size);
+ ClassDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxTexture::get_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("set_region_rect","region"),&StyleBoxTexture::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&StyleBoxTexture::get_region_rect);
+ ClassDB::bind_method(_MD("set_region_rect","region"),&StyleBoxTexture::set_region_rect);
+ ClassDB::bind_method(_MD("get_region_rect"),&StyleBoxTexture::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_draw_center","enable"),&StyleBoxTexture::set_draw_center);
- ObjectTypeDB::bind_method(_MD("get_draw_center"),&StyleBoxTexture::get_draw_center);
+ ClassDB::bind_method(_MD("set_draw_center","enable"),&StyleBoxTexture::set_draw_center);
+ ClassDB::bind_method(_MD("get_draw_center"),&StyleBoxTexture::get_draw_center);
- ObjectTypeDB::bind_method(_MD("set_modulate","color"),&StyleBoxTexture::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&StyleBoxTexture::get_modulate);
+ ClassDB::bind_method(_MD("set_modulate","color"),&StyleBoxTexture::set_modulate);
+ ClassDB::bind_method(_MD("get_modulate"),&StyleBoxTexture::get_modulate);
ADD_SIGNAL(MethodInfo("texture_changed"));
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_texture"),_SCS("get_texture") );
ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_BOTTOM );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate/color" ), _SCS("set_modulate"),_SCS("get_modulate"));
+ ADD_GROUP("Margin","margin_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_LEFT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_RIGHT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_BOTTOM );
+ ADD_GROUP("Expand Margin","expand_margin_");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
+ ADD_GROUP("Modulate","modulate_");
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate_color" ), _SCS("set_modulate"),_SCS("get_modulate"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_center" ) , _SCS("set_draw_center"),_SCS("get_draw_center"));
}
@@ -386,18 +390,18 @@ float StyleBoxFlat::get_style_margin(Margin p_margin) const {
}
void StyleBoxFlat::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_bg_color","color"),&StyleBoxFlat::set_bg_color);
- ObjectTypeDB::bind_method(_MD("get_bg_color"),&StyleBoxFlat::get_bg_color);
- ObjectTypeDB::bind_method(_MD("set_light_color","color"),&StyleBoxFlat::set_light_color);
- ObjectTypeDB::bind_method(_MD("get_light_color"),&StyleBoxFlat::get_light_color);
- ObjectTypeDB::bind_method(_MD("set_dark_color","color"),&StyleBoxFlat::set_dark_color);
- ObjectTypeDB::bind_method(_MD("get_dark_color"),&StyleBoxFlat::get_dark_color);
- ObjectTypeDB::bind_method(_MD("set_border_size","size"),&StyleBoxFlat::set_border_size);
- ObjectTypeDB::bind_method(_MD("get_border_size"),&StyleBoxFlat::get_border_size);
- ObjectTypeDB::bind_method(_MD("set_border_blend","blend"),&StyleBoxFlat::set_border_blend);
- ObjectTypeDB::bind_method(_MD("get_border_blend"),&StyleBoxFlat::get_border_blend);
- ObjectTypeDB::bind_method(_MD("set_draw_center","size"),&StyleBoxFlat::set_draw_center);
- ObjectTypeDB::bind_method(_MD("get_draw_center"),&StyleBoxFlat::get_draw_center);
+ ClassDB::bind_method(_MD("set_bg_color","color"),&StyleBoxFlat::set_bg_color);
+ ClassDB::bind_method(_MD("get_bg_color"),&StyleBoxFlat::get_bg_color);
+ ClassDB::bind_method(_MD("set_light_color","color"),&StyleBoxFlat::set_light_color);
+ ClassDB::bind_method(_MD("get_light_color"),&StyleBoxFlat::get_light_color);
+ ClassDB::bind_method(_MD("set_dark_color","color"),&StyleBoxFlat::set_dark_color);
+ ClassDB::bind_method(_MD("get_dark_color"),&StyleBoxFlat::get_dark_color);
+ ClassDB::bind_method(_MD("set_border_size","size"),&StyleBoxFlat::set_border_size);
+ ClassDB::bind_method(_MD("get_border_size"),&StyleBoxFlat::get_border_size);
+ ClassDB::bind_method(_MD("set_border_blend","blend"),&StyleBoxFlat::set_border_blend);
+ ClassDB::bind_method(_MD("get_border_blend"),&StyleBoxFlat::get_border_blend);
+ ClassDB::bind_method(_MD("set_draw_center","size"),&StyleBoxFlat::set_draw_center);
+ ClassDB::bind_method(_MD("get_draw_center"),&StyleBoxFlat::get_draw_center);
ADD_PROPERTY( PropertyInfo( Variant::COLOR, "bg_color"), _SCS("set_bg_color"),_SCS("get_bg_color") );
ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color"),_SCS("set_light_color"),_SCS("get_light_color"));
@@ -423,127 +427,3 @@ StyleBoxFlat::~StyleBoxFlat() {
}
-////////////////
-
-
-
-void StyleBoxImageMask::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_image","image"),&StyleBoxImageMask::set_image);
- ObjectTypeDB::bind_method(_MD("get_image"),&StyleBoxImageMask::get_image);
- ObjectTypeDB::bind_method(_MD("set_expand","expand"),&StyleBoxImageMask::set_expand);
- ObjectTypeDB::bind_method(_MD("get_expand"),&StyleBoxImageMask::get_expand);
- ObjectTypeDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxImageMask::set_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxImageMask::get_expand_margin_size);
-
- ADD_PROPERTY( PropertyInfo(Variant::IMAGE, "image"), _SCS("set_image"), _SCS("get_image"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("get_expand"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
-
-}
-
-
-bool StyleBoxImageMask::test_mask(const Point2& p_point, const Rect2& p_rect) const {
-
- if (image.empty())
- return false;
- if (p_rect.size.x<1)
- return false;
- if (p_rect.size.y<1)
- return false;
-
- Size2i imgsize(image.get_width(),image.get_height());
- if (imgsize.x<=0 || imgsize.y<=0)
- return false;
-
- Point2i img_expand_size( imgsize.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], imgsize.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- Point2i rect_expand_size( p_rect.size.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], p_rect.size.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- if (rect_expand_size.x<1)
- rect_expand_size.x=1;
- if (rect_expand_size.y<1)
- rect_expand_size.y=1;
-
-
- Point2i click_pos;
-
-
- //treat x
-
- if (p_point.x<p_rect.pos.x)
- click_pos.x=0;
- else if (expand) {
-
- if (p_point.x>=p_rect.pos.x+p_rect.size.x)
- click_pos.x=imgsize.x-1;
- else if ((p_point.x-p_rect.pos.x)<expand_margin[MARGIN_LEFT])
- click_pos.x=p_point.x;
- else if ((p_point.x-(p_rect.pos.x+p_rect.size.x))<expand_margin[MARGIN_RIGHT])
- click_pos.x=imgsize.x-(p_point.x-(p_rect.pos.x+p_rect.size.x));
- else //expand
- click_pos.x=(p_point.x-p_rect.pos.x-expand_margin[MARGIN_LEFT])*img_expand_size.x/rect_expand_size.x;
- } else if ((p_point.x-p_rect.pos.x) > imgsize.x)
- click_pos.x=imgsize.x;
-
- //treat y
-
- if (p_point.y<p_rect.pos.y)
- click_pos.y=0;
- else if (expand) {
-
- if (p_point.y>=p_rect.pos.y+p_rect.size.y)
- click_pos.y=imgsize.y-1;
- else if ((p_point.y-p_rect.pos.y)<expand_margin[MARGIN_TOP])
- click_pos.y=p_point.y;
- else if ((p_point.y-(p_rect.pos.y+p_rect.size.y))<expand_margin[MARGIN_BOTTOM])
- click_pos.y=imgsize.y-(p_point.y-(p_rect.pos.y+p_rect.size.y));
- else //expand
- click_pos.y=(p_point.y-p_rect.pos.y-expand_margin[MARGIN_TOP])*img_expand_size.y/rect_expand_size.y;
- } else if ((p_point.y-p_rect.pos.y) > imgsize.y)
- click_pos.y=imgsize.y;
-
- return image.get_pixel(click_pos.x,click_pos.y).gray()>0.5;
-
-}
-
-
-void StyleBoxImageMask::set_image(const Image& p_image) {
-
- image=p_image;
-}
-Image StyleBoxImageMask::get_image() const {
-
- return image;
-}
-
-
-void StyleBoxImageMask::set_expand(bool p_expand) {
-
- expand=p_expand;
-}
-bool StyleBoxImageMask::get_expand() const {
-
- return expand;
-}
-void StyleBoxImageMask::set_expand_margin_size(Margin p_expand_margin,float p_size) {
-
- ERR_FAIL_INDEX(p_expand_margin,4);
- expand_margin[p_expand_margin]=p_size;
-}
-
-
-float StyleBoxImageMask::get_expand_margin_size(Margin p_expand_margin) const {
-
- ERR_FAIL_INDEX_V(p_expand_margin,4,0);
- return expand_margin[p_expand_margin];
-}
-
-StyleBoxImageMask::StyleBoxImageMask() {
-
- for (int i=0;i<4;i++) {
- expand_margin[i]=0;
- }
- expand=true;
-}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index f667318e24..f8b02724ee 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class StyleBox : public Resource {
- OBJ_TYPE( StyleBox, Resource );
+ GDCLASS( StyleBox, Resource );
RES_BASE_EXTENSION("sbx");
OBJ_SAVE_TYPE( StyleBox );
float margin[4];
@@ -65,7 +65,7 @@ public:
class StyleBoxEmpty : public StyleBox {
- OBJ_TYPE( StyleBoxEmpty, StyleBox );
+ GDCLASS( StyleBoxEmpty, StyleBox );
virtual float get_style_margin(Margin p_margin) const { return 0; }
public:
@@ -76,7 +76,7 @@ public:
class StyleBoxTexture : public StyleBox {
- OBJ_TYPE( StyleBoxTexture, StyleBox );
+ GDCLASS( StyleBoxTexture, StyleBox );
float expand_margin[4];
@@ -123,7 +123,7 @@ public:
class StyleBoxFlat : public StyleBox {
- OBJ_TYPE( StyleBoxFlat, StyleBox );
+ GDCLASS( StyleBoxFlat, StyleBox );
Color bg_color;
Color light_color;
@@ -167,35 +167,5 @@ public:
};
-class StyleBoxImageMask : public StyleBox {
-
- OBJ_TYPE( StyleBoxImageMask, StyleBox );
- virtual float get_style_margin(Margin p_margin) const { return 0; }
-
- Image image;
- float expand_margin[4];
- bool expand;
-
-protected:
-
- static void _bind_methods();
-
-public:
-
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const {}
- virtual bool test_mask(const Point2& p_point, const Rect2& p_rect) const;
-
- void set_image(const Image& p_image);
- Image get_image() const;
-
- void set_expand(bool p_expand);
- bool get_expand() const;
- void set_expand_margin_size(Margin p_expand_margin,float p_size);
- float get_expand_margin_size(Margin p_expand_margin) const;
-
- StyleBoxImageMask();
-
-};
-
#endif
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index e1769d099b..27cc7e131b 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -262,9 +262,9 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
case Mesh::ARRAY_FORMAT_VERTEX:
case Mesh::ARRAY_FORMAT_NORMAL: {
- DVector<Vector3> array;
+ PoolVector<Vector3> array;
array.resize(varr_len);
- DVector<Vector3>::Write w = array.write();
+ PoolVector<Vector3>::Write w = array.write();
int idx=0;
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) {
@@ -282,7 +282,7 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
}
- w=DVector<Vector3>::Write();
+ w=PoolVector<Vector3>::Write();
a[i]=array;
} break;
@@ -290,9 +290,9 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
case Mesh::ARRAY_FORMAT_TEX_UV:
case Mesh::ARRAY_FORMAT_TEX_UV2: {
- DVector<Vector2> array;
+ PoolVector<Vector2> array;
array.resize(varr_len);
- DVector<Vector2>::Write w = array.write();
+ PoolVector<Vector2>::Write w = array.write();
int idx=0;
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) {
@@ -311,15 +311,15 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
}
- w=DVector<Vector2>::Write();
+ w=PoolVector<Vector2>::Write();
a[i]=array;
} break;
case Mesh::ARRAY_FORMAT_TANGENT: {
- DVector<float> array;
+ PoolVector<float> array;
array.resize(varr_len*4);
- DVector<float>::Write w = array.write();
+ PoolVector<float>::Write w = array.write();
int idx=0;
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
@@ -335,15 +335,15 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
w[idx+3]=d<0 ? -1 : 1;
}
- w=DVector<float>::Write();
+ w=PoolVector<float>::Write();
a[i]=array;
} break;
case Mesh::ARRAY_FORMAT_COLOR: {
- DVector<Color> array;
+ PoolVector<Color> array;
array.resize(varr_len);
- DVector<Color>::Write w = array.write();
+ PoolVector<Color>::Write w = array.write();
int idx=0;
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) {
@@ -352,38 +352,54 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
w[idx]=v.color;
}
- w=DVector<Color>::Write();
+ w=PoolVector<Color>::Write();
a[i]=array;
} break;
- case Mesh::ARRAY_FORMAT_BONES:
+ case Mesh::ARRAY_FORMAT_BONES: {
+
+
+ PoolVector<int> array;
+ array.resize(varr_len*4);
+ PoolVector<int>::Write w = array.write();
+
+ int idx=0;
+ for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
+
+ const Vertex &v=E->get();
+
+ ERR_CONTINUE( v.bones.size()!=4 );
+
+ for(int j=0;j<4;j++) {
+ w[idx+j]=v.bones[j];
+ }
+
+ }
+
+ w=PoolVector<int>::Write();
+ a[i]=array;
+
+ } break;
case Mesh::ARRAY_FORMAT_WEIGHTS: {
- DVector<float> array;
+ PoolVector<float> array;
array.resize(varr_len*4);
- DVector<float>::Write w = array.write();
+ PoolVector<float>::Write w = array.write();
int idx=0;
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
const Vertex &v=E->get();
+ ERR_CONTINUE( v.weights.size()!=4 );
for(int j=0;j<4;j++) {
- switch(i) {
- case Mesh::ARRAY_WEIGHTS: {
- ERR_CONTINUE( v.weights.size()!=4 );
- w[idx+j]=v.weights[j];
- } break;
- case Mesh::ARRAY_BONES: {
- ERR_CONTINUE( v.bones.size()!=4 );
- w[idx+j]=v.bones[j];
- } break;
- }
+
+ w[idx+j]=v.weights[j];
}
}
- w=DVector<float>::Write();
+ w=PoolVector<float>::Write();
a[i]=array;
} break;
@@ -391,9 +407,9 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
ERR_CONTINUE( index_array.size() ==0 );
- DVector<int> array;
+ PoolVector<int> array;
array.resize(index_array.size());
- DVector<int>::Write w = array.write();
+ PoolVector<int>::Write w = array.write();
int idx=0;
for(List< int>::Element *E=index_array.front();E;E=E->next(),idx++) {
@@ -401,7 +417,7 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
w[idx]=E->get();
}
- w=DVector<int>::Write();
+ w=PoolVector<int>::Write();
a[i]=array;
} break;
@@ -410,7 +426,7 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
}
- mesh->add_surface(primitive,a);
+ mesh->add_surface_from_arrays(primitive,a);
if (material.is_valid())
mesh->surface_set_material(surface,material);
@@ -474,14 +490,14 @@ void SurfaceTool::_create_list(const Ref<Mesh>& p_existing, int p_surface, List<
Array arr = p_existing->surface_get_arrays(p_surface);
ERR_FAIL_COND( arr.size() !=VS::ARRAY_MAX );
- DVector<Vector3> varr = arr[VS::ARRAY_VERTEX];
- DVector<Vector3> narr = arr[VS::ARRAY_NORMAL];
- DVector<float> tarr = arr[VS::ARRAY_TANGENT];
- DVector<Color> carr = arr[VS::ARRAY_COLOR];
- DVector<Vector2> uvarr = arr[VS::ARRAY_TEX_UV];
- DVector<Vector2> uv2arr = arr[VS::ARRAY_TEX_UV2];
- DVector<int> barr = arr[VS::ARRAY_BONES];
- DVector<float> warr = arr[VS::ARRAY_WEIGHTS];
+ PoolVector<Vector3> varr = arr[VS::ARRAY_VERTEX];
+ PoolVector<Vector3> narr = arr[VS::ARRAY_NORMAL];
+ PoolVector<float> tarr = arr[VS::ARRAY_TANGENT];
+ PoolVector<Color> carr = arr[VS::ARRAY_COLOR];
+ PoolVector<Vector2> uvarr = arr[VS::ARRAY_TEX_UV];
+ PoolVector<Vector2> uv2arr = arr[VS::ARRAY_TEX_UV2];
+ PoolVector<int> barr = arr[VS::ARRAY_BONES];
+ PoolVector<float> warr = arr[VS::ARRAY_WEIGHTS];
int vc = varr.size();
@@ -489,46 +505,46 @@ void SurfaceTool::_create_list(const Ref<Mesh>& p_existing, int p_surface, List<
return;
lformat=0;
- DVector<Vector3>::Read rv;
+ PoolVector<Vector3>::Read rv;
if (varr.size()) {
lformat|=VS::ARRAY_FORMAT_VERTEX;
rv=varr.read();
}
- DVector<Vector3>::Read rn;
+ PoolVector<Vector3>::Read rn;
if (narr.size()) {
lformat|=VS::ARRAY_FORMAT_NORMAL;
rn=narr.read();
}
- DVector<float>::Read rt;
+ PoolVector<float>::Read rt;
if (tarr.size()) {
lformat|=VS::ARRAY_FORMAT_TANGENT;
rt=tarr.read();
}
- DVector<Color>::Read rc;
+ PoolVector<Color>::Read rc;
if (carr.size()) {
lformat|=VS::ARRAY_FORMAT_COLOR;
rc=carr.read();
}
- DVector<Vector2>::Read ruv;
+ PoolVector<Vector2>::Read ruv;
if (uvarr.size()) {
lformat|=VS::ARRAY_FORMAT_TEX_UV;
ruv=uvarr.read();
}
- DVector<Vector2>::Read ruv2;
+ PoolVector<Vector2>::Read ruv2;
if (uv2arr.size()) {
lformat|=VS::ARRAY_FORMAT_TEX_UV2;
ruv2=uv2arr.read();
}
- DVector<int>::Read rb;
+ PoolVector<int>::Read rb;
if (barr.size()) {
lformat|=VS::ARRAY_FORMAT_BONES;
rb=barr.read();
}
- DVector<float>::Read rw;
+ PoolVector<float>::Read rw;
if (warr.size()) {
lformat|=VS::ARRAY_FORMAT_WEIGHTS;
rw=warr.read();
@@ -576,12 +592,12 @@ void SurfaceTool::_create_list(const Ref<Mesh>& p_existing, int p_surface, List<
//indices
- DVector<int> idx= arr[VS::ARRAY_INDEX];
+ PoolVector<int> idx= arr[VS::ARRAY_INDEX];
int is = idx.size();
if (is) {
lformat|=VS::ARRAY_FORMAT_INDEX;
- DVector<int>::Read iarr=idx.read();
+ PoolVector<int>::Read iarr=idx.read();
for(int i=0;i<is;i++) {
r_index->push_back(iarr[i]);
}
@@ -634,9 +650,11 @@ void SurfaceTool::append_from(const Ref<Mesh>& p_existing, int p_surface,const T
for(List<int>::Element *E=nindices.front();E;E=E->next()) {
int dst_index = E->get()+vfrom;
- //if (dst_index <0 || dst_index>=vertex_array.size()) {
- // print_line("invalid index!");
- //}
+ /*
+ if (dst_index <0 || dst_index>=vertex_array.size()) {
+ print_line("invalid index!");
+ }
+ */
index_array.push_back(dst_index);
}
if (index_array.size()%3)
@@ -844,25 +862,25 @@ void SurfaceTool::clear() {
void SurfaceTool::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("begin","primitive"),&SurfaceTool::begin);
- ObjectTypeDB::bind_method(_MD("add_vertex","vertex"),&SurfaceTool::add_vertex);
- ObjectTypeDB::bind_method(_MD("add_color","color"),&SurfaceTool::add_color);
- ObjectTypeDB::bind_method(_MD("add_normal","normal"),&SurfaceTool::add_normal);
- ObjectTypeDB::bind_method(_MD("add_tangent","tangent"),&SurfaceTool::add_tangent);
- ObjectTypeDB::bind_method(_MD("add_uv","uv"),&SurfaceTool::add_uv);
- ObjectTypeDB::bind_method(_MD("add_uv2","uv2"),&SurfaceTool::add_uv2);
- ObjectTypeDB::bind_method(_MD("add_bones","bones"),&SurfaceTool::add_bones);
- ObjectTypeDB::bind_method(_MD("add_weights","weights"),&SurfaceTool::add_weights);
- ObjectTypeDB::bind_method(_MD("add_smooth_group","smooth"),&SurfaceTool::add_smooth_group);
- ObjectTypeDB::bind_method(_MD("add_triangle_fan", "vertexes", "uvs", "colors", "uv2s", "normals", "tangents"),&SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()),DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>()));
- ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&SurfaceTool::set_material);
- ObjectTypeDB::bind_method(_MD("index"),&SurfaceTool::index);
- ObjectTypeDB::bind_method(_MD("deindex"),&SurfaceTool::deindex);
- ///ObjectTypeDB::bind_method(_MD("generate_flat_normals"),&SurfaceTool::generate_flat_normals);
- ObjectTypeDB::bind_method(_MD("generate_normals"),&SurfaceTool::generate_normals);
- ObjectTypeDB::bind_method(_MD("add_index", "index"), &SurfaceTool::add_index);
- ObjectTypeDB::bind_method(_MD("commit:Mesh","existing:Mesh"),&SurfaceTool::commit,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("clear"),&SurfaceTool::clear);
+ ClassDB::bind_method(_MD("begin","primitive"),&SurfaceTool::begin);
+ ClassDB::bind_method(_MD("add_vertex","vertex"),&SurfaceTool::add_vertex);
+ ClassDB::bind_method(_MD("add_color","color"),&SurfaceTool::add_color);
+ ClassDB::bind_method(_MD("add_normal","normal"),&SurfaceTool::add_normal);
+ ClassDB::bind_method(_MD("add_tangent","tangent"),&SurfaceTool::add_tangent);
+ ClassDB::bind_method(_MD("add_uv","uv"),&SurfaceTool::add_uv);
+ ClassDB::bind_method(_MD("add_uv2","uv2"),&SurfaceTool::add_uv2);
+ ClassDB::bind_method(_MD("add_bones","bones"),&SurfaceTool::add_bones);
+ ClassDB::bind_method(_MD("add_weights","weights"),&SurfaceTool::add_weights);
+ ClassDB::bind_method(_MD("add_smooth_group","smooth"),&SurfaceTool::add_smooth_group);
+ ClassDB::bind_method(_MD("add_triangle_fan", "vertexes", "uvs", "colors", "uv2s", "normals", "tangents"),&SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()),DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>()));
+ ClassDB::bind_method(_MD("set_material","material:Material"),&SurfaceTool::set_material);
+ ClassDB::bind_method(_MD("index"),&SurfaceTool::index);
+ ClassDB::bind_method(_MD("deindex"),&SurfaceTool::deindex);
+ ///ClassDB::bind_method(_MD("generate_flat_normals"),&SurfaceTool::generate_flat_normals);
+ ClassDB::bind_method(_MD("generate_normals"),&SurfaceTool::generate_normals);
+ ClassDB::bind_method(_MD("add_index", "index"), &SurfaceTool::add_index);
+ ClassDB::bind_method(_MD("commit:Mesh","existing:Mesh"),&SurfaceTool::commit,DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("clear"),&SurfaceTool::clear);
}
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index fa9724b142..f859efbfe5 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SurfaceTool : public Reference {
- OBJ_TYPE(SurfaceTool, Reference );
+ GDCLASS(SurfaceTool, Reference );
public:
struct Vertex {
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 726b1938c4..a1ad5d8237 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -63,16 +63,15 @@ bool Texture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2
void Texture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_width"),&Texture::get_width);
- ObjectTypeDB::bind_method(_MD("get_height"),&Texture::get_height);
- ObjectTypeDB::bind_method(_MD("get_size"),&Texture::get_size);
- ObjectTypeDB::bind_method(_MD("get_rid"),&Texture::get_rid);
- ObjectTypeDB::bind_method(_MD("has_alpha"),&Texture::has_alpha);
- ObjectTypeDB::bind_method(_MD("set_flags","flags"),&Texture::set_flags);
- ObjectTypeDB::bind_method(_MD("get_flags"),&Texture::get_flags);
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","modulate","transpose"),&Texture::draw,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_rect","canvas_item","rect","tile","modulate","transpose"),&Texture::draw_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_rect_region","canvas_item","rect","src_rect","modulate","transpose"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(_MD("get_width"),&Texture::get_width);
+ ClassDB::bind_method(_MD("get_height"),&Texture::get_height);
+ ClassDB::bind_method(_MD("get_size"),&Texture::get_size);
+ ClassDB::bind_method(_MD("has_alpha"),&Texture::has_alpha);
+ ClassDB::bind_method(_MD("set_flags","flags"),&Texture::set_flags);
+ ClassDB::bind_method(_MD("get_flags"),&Texture::get_flags);
+ ClassDB::bind_method(_MD("draw","canvas_item","pos","modulate","transpose"),&Texture::draw,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(_MD("draw_rect","canvas_item","rect","tile","modulate","transpose"),&Texture::draw_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(_MD("draw_rect_region","canvas_item","rect","src_rect","modulate","transpose"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
BIND_CONSTANT( FLAG_MIPMAPS );
BIND_CONSTANT( FLAG_REPEAT );
@@ -258,23 +257,13 @@ void ImageTexture::load(const String& p_path) {
void ImageTexture::set_data(const Image& p_image) {
VisualServer::get_singleton()->texture_set_data(texture,p_image);
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName()); //hook is erased if data is changed
+
_change_notify();
}
void ImageTexture::_resource_path_changed() {
String path=get_path();
- if (VS::get_singleton()->has_feature(VS::FEATURE_NEEDS_RELOAD_HOOK)) {
- //this needs to be done much better, but probably will end up being deprecated as technology advances
- if (path.is_resource_file() && ImageLoader::recognize(path.extension())) {
-
- //hook is set only if path is hookable
- VisualServer::get_singleton()->texture_set_reload_hook(texture,get_instance_ID(),"_reload_hook");
- } else {
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName());
- }
- }
}
Image ImageTexture::get_data() const {
@@ -300,7 +289,7 @@ RID ImageTexture::get_rid() const {
void ImageTexture::fix_alpha_edges() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format==Image::FORMAT_RGBA8 /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.fix_alpha_edges();
@@ -310,7 +299,7 @@ void ImageTexture::fix_alpha_edges() {
void ImageTexture::premultiply_alpha() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format==Image::FORMAT_RGBA8 /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.premultiply_alpha();
@@ -337,7 +326,7 @@ void ImageTexture::shrink_x2_and_keep_size() {
bool ImageTexture::has_alpha() const {
- return ( format==Image::FORMAT_GRAYSCALE_ALPHA || format==Image::FORMAT_INDEXED_ALPHA || format==Image::FORMAT_RGBA );
+ return ( format==Image::FORMAT_LA8 || format==Image::FORMAT_RGBA8 );
}
@@ -417,27 +406,27 @@ void ImageTexture::_set_data(Dictionary p_data) {
void ImageTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create","width","height","format","flags"),&ImageTexture::create,DEFVAL(FLAGS_DEFAULT));
- ObjectTypeDB::bind_method(_MD("create_from_image","image","flags"),&ImageTexture::create_from_image,DEFVAL(FLAGS_DEFAULT));
- ObjectTypeDB::bind_method(_MD("get_format"),&ImageTexture::get_format);
- ObjectTypeDB::bind_method(_MD("load","path"),&ImageTexture::load);
- ObjectTypeDB::bind_method(_MD("set_data","image"),&ImageTexture::set_data);
- ObjectTypeDB::bind_method(_MD("get_data","cube_side"),&ImageTexture::get_data);
- ObjectTypeDB::bind_method(_MD("set_storage","mode"),&ImageTexture::set_storage);
- ObjectTypeDB::bind_method(_MD("get_storage"),&ImageTexture::get_storage);
- ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality","quality"),&ImageTexture::set_lossy_storage_quality);
- ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
- ObjectTypeDB::bind_method(_MD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
- ObjectTypeDB::bind_method(_MD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
- ObjectTypeDB::bind_method(_MD("normal_to_xy"),&ImageTexture::normal_to_xy);
- ObjectTypeDB::bind_method(_MD("shrink_x2_and_keep_size"),&ImageTexture::shrink_x2_and_keep_size);
-
- ObjectTypeDB::bind_method(_MD("set_size_override","size"),&ImageTexture::set_size_override);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("normal_to_xy"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("shrink_x2_and_keep_size"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("_reload_hook","rid"),&ImageTexture::_reload_hook);
+ ClassDB::bind_method(_MD("create","width","height","format","flags"),&ImageTexture::create,DEFVAL(FLAGS_DEFAULT));
+ ClassDB::bind_method(_MD("create_from_image","image","flags"),&ImageTexture::create_from_image,DEFVAL(FLAGS_DEFAULT));
+ ClassDB::bind_method(_MD("get_format"),&ImageTexture::get_format);
+ ClassDB::bind_method(_MD("load","path"),&ImageTexture::load);
+ ClassDB::bind_method(_MD("set_data","image"),&ImageTexture::set_data);
+ ClassDB::bind_method(_MD("get_data","cube_side"),&ImageTexture::get_data);
+ ClassDB::bind_method(_MD("set_storage","mode"),&ImageTexture::set_storage);
+ ClassDB::bind_method(_MD("get_storage"),&ImageTexture::get_storage);
+ ClassDB::bind_method(_MD("set_lossy_storage_quality","quality"),&ImageTexture::set_lossy_storage_quality);
+ ClassDB::bind_method(_MD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
+ ClassDB::bind_method(_MD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
+ ClassDB::bind_method(_MD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
+ ClassDB::bind_method(_MD("normal_to_xy"),&ImageTexture::normal_to_xy);
+ ClassDB::bind_method(_MD("shrink_x2_and_keep_size"),&ImageTexture::shrink_x2_and_keep_size);
+
+ ClassDB::bind_method(_MD("set_size_override","size"),&ImageTexture::set_size_override);
+ ClassDB::set_method_flags(get_class_static(),_SCS("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::set_method_flags(get_class_static(),_SCS("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::set_method_flags(get_class_static(),_SCS("normal_to_xy"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::set_method_flags(get_class_static(),_SCS("shrink_x2_and_keep_size"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(_MD("_reload_hook","rid"),&ImageTexture::_reload_hook);
BIND_CONSTANT( STORAGE_RAW );
@@ -559,14 +548,14 @@ Rect2 AtlasTexture::get_margin() const {
void AtlasTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_atlas","atlas:Texture"),&AtlasTexture::set_atlas);
- ObjectTypeDB::bind_method(_MD("get_atlas:Texture"),&AtlasTexture::get_atlas);
+ ClassDB::bind_method(_MD("set_atlas","atlas:Texture"),&AtlasTexture::set_atlas);
+ ClassDB::bind_method(_MD("get_atlas:Texture"),&AtlasTexture::get_atlas);
- ObjectTypeDB::bind_method(_MD("set_region","region"),&AtlasTexture::set_region);
- ObjectTypeDB::bind_method(_MD("get_region"),&AtlasTexture::get_region);
+ ClassDB::bind_method(_MD("set_region","region"),&AtlasTexture::set_region);
+ ClassDB::bind_method(_MD("get_region"),&AtlasTexture::get_region);
- ObjectTypeDB::bind_method(_MD("set_margin","margin"),&AtlasTexture::set_margin);
- ObjectTypeDB::bind_method(_MD("get_margin"),&AtlasTexture::get_margin);
+ ClassDB::bind_method(_MD("set_margin","margin"),&AtlasTexture::set_margin);
+ ClassDB::bind_method(_MD("get_margin"),&AtlasTexture::get_margin);
ADD_SIGNAL(MethodInfo("atlas_changed"));
@@ -814,18 +803,18 @@ Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const{
void LargeTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_piece","ofs","texture:Texture"),&LargeTexture::add_piece);
- ObjectTypeDB::bind_method(_MD("set_piece_offset", "idx", "ofs"),&LargeTexture::set_piece_offset);
- ObjectTypeDB::bind_method(_MD("set_piece_texture","idx", "texture:Texture"),&LargeTexture::set_piece_texture);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&LargeTexture::set_size);
- ObjectTypeDB::bind_method(_MD("clear"),&LargeTexture::clear);
+ ClassDB::bind_method(_MD("add_piece","ofs","texture:Texture"),&LargeTexture::add_piece);
+ ClassDB::bind_method(_MD("set_piece_offset", "idx", "ofs"),&LargeTexture::set_piece_offset);
+ ClassDB::bind_method(_MD("set_piece_texture","idx", "texture:Texture"),&LargeTexture::set_piece_texture);
+ ClassDB::bind_method(_MD("set_size","size"),&LargeTexture::set_size);
+ ClassDB::bind_method(_MD("clear"),&LargeTexture::clear);
- ObjectTypeDB::bind_method(_MD("get_piece_count"),&LargeTexture::get_piece_count);
- ObjectTypeDB::bind_method(_MD("get_piece_offset","idx"),&LargeTexture::get_piece_offset);
- ObjectTypeDB::bind_method(_MD("get_piece_texture:Texture","idx"),&LargeTexture::get_piece_texture);
+ ClassDB::bind_method(_MD("get_piece_count"),&LargeTexture::get_piece_count);
+ ClassDB::bind_method(_MD("get_piece_offset","idx"),&LargeTexture::get_piece_offset);
+ ClassDB::bind_method(_MD("get_piece_texture:Texture","idx"),&LargeTexture::get_piece_texture);
- ObjectTypeDB::bind_method(_MD("_set_data","data"),&LargeTexture::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&LargeTexture::_get_data);
+ ClassDB::bind_method(_MD("_set_data","data"),&LargeTexture::_set_data);
+ ClassDB::bind_method(_MD("_get_data"),&LargeTexture::_get_data);
ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data") );
@@ -1058,18 +1047,18 @@ void CubeMap::_get_property_list( List<PropertyInfo> *p_list) const {
void CubeMap::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_width"),&CubeMap::get_width);
- ObjectTypeDB::bind_method(_MD("get_height"),&CubeMap::get_height);
- ObjectTypeDB::bind_method(_MD("get_rid"),&CubeMap::get_rid);
- ObjectTypeDB::bind_method(_MD("set_flags","flags"),&CubeMap::set_flags);
- ObjectTypeDB::bind_method(_MD("get_flags"),&CubeMap::get_flags);
-
- ObjectTypeDB::bind_method(_MD("set_side","side","image"),&CubeMap::set_side);
- ObjectTypeDB::bind_method(_MD("get_side","side"),&CubeMap::get_side);
- ObjectTypeDB::bind_method(_MD("set_storage","mode"),&CubeMap::set_storage);
- ObjectTypeDB::bind_method(_MD("get_storage"),&CubeMap::get_storage);
- ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality","quality"),&CubeMap::set_lossy_storage_quality);
- ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"),&CubeMap::get_lossy_storage_quality);
+ ClassDB::bind_method(_MD("get_width"),&CubeMap::get_width);
+ ClassDB::bind_method(_MD("get_height"),&CubeMap::get_height);
+ //ClassDB::bind_method(_MD("get_rid"),&CubeMap::get_rid);
+ ClassDB::bind_method(_MD("set_flags","flags"),&CubeMap::set_flags);
+ ClassDB::bind_method(_MD("get_flags"),&CubeMap::get_flags);
+
+ ClassDB::bind_method(_MD("set_side","side","image"),&CubeMap::set_side);
+ ClassDB::bind_method(_MD("get_side","side"),&CubeMap::get_side);
+ ClassDB::bind_method(_MD("set_storage","mode"),&CubeMap::set_storage);
+ ClassDB::bind_method(_MD("get_storage"),&CubeMap::get_storage);
+ ClassDB::bind_method(_MD("set_lossy_storage_quality","quality"),&CubeMap::set_lossy_storage_quality);
+ ClassDB::bind_method(_MD("get_lossy_storage_quality"),&CubeMap::get_lossy_storage_quality);
BIND_CONSTANT( STORAGE_RAW );
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 05ea833978..aac3514af3 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@
class Texture : public Resource {
- OBJ_TYPE( Texture, Resource );
+ GDCLASS( Texture, Resource );
OBJ_SAVE_TYPE( Texture ); //children are all saved as Texture, so they can be exchanged
protected:
@@ -54,7 +54,7 @@ public:
FLAG_FILTER=VisualServer::TEXTURE_FLAG_FILTER,
FLAG_ANISOTROPIC_FILTER=VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER,
FLAG_CONVERT_TO_LINEAR=VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
- FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_VIDEO_SURFACE,
+ FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_USED_FOR_STREAMING,
FLAGS_DEFAULT=FLAG_MIPMAPS|FLAG_REPEAT|FLAG_FILTER,
FLAG_MIRRORED_REPEAT=VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT
};
@@ -85,7 +85,7 @@ VARIANT_ENUM_CAST( Texture::Flags );
class ImageTexture : public Texture {
- OBJ_TYPE( ImageTexture, Texture );
+ GDCLASS( ImageTexture, Texture );
RES_BASE_EXTENSION("tex");
public:
enum Storage {
@@ -164,7 +164,7 @@ VARIANT_ENUM_CAST( ImageTexture::Storage );
class AtlasTexture : public Texture {
- OBJ_TYPE( AtlasTexture, Texture );
+ GDCLASS( AtlasTexture, Texture );
RES_BASE_EXTENSION("atex");
protected:
@@ -205,7 +205,7 @@ public:
class LargeTexture : public Texture {
- OBJ_TYPE( LargeTexture, Texture );
+ GDCLASS( LargeTexture, Texture );
RES_BASE_EXTENSION("ltex");
protected:
@@ -256,7 +256,7 @@ public:
class CubeMap : public Resource {
- OBJ_TYPE( CubeMap, Resource );
+ GDCLASS( CubeMap, Resource );
RES_BASE_EXTENSION("cbm");
public:
enum Storage {
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index b351167e10..d950407f54 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -267,7 +267,7 @@ void Theme::set_default_font( const Ref<Font>& p_font ) {
void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref<Texture>& p_icon) {
-// ERR_FAIL_COND(p_icon.is_null());
+ //ERR_FAIL_COND(p_icon.is_null());
bool new_value=!icon_map.has(p_type) || !icon_map[p_type].has(p_name);
@@ -367,7 +367,7 @@ void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list)
void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const Ref<StyleBox>& p_style) {
-// ERR_FAIL_COND(p_style.is_null());
+ //ERR_FAIL_COND(p_style.is_null());
bool new_value=!style_map.has(p_type) || !style_map[p_type].has(p_name);
@@ -430,7 +430,7 @@ void Theme::get_stylebox_types(List<StringName> *p_list) const {
void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref<Font>& p_font) {
-// ERR_FAIL_COND(p_font.is_null());
+ //ERR_FAIL_COND(p_font.is_null());
bool new_value=!font_map.has(p_type) || !font_map[p_type].has(p_name);
@@ -664,48 +664,48 @@ void Theme::get_type_list(List<StringName> *p_list) const {
void Theme::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_icon","name","type","texture:Texture"),&Theme::set_icon);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","name","type"),&Theme::get_icon);
- ObjectTypeDB::bind_method(_MD("has_icon","name","type"),&Theme::has_icon);
- ObjectTypeDB::bind_method(_MD("clear_icon","name","type"),&Theme::clear_icon);
- ObjectTypeDB::bind_method(_MD("get_icon_list","type"),&Theme::_get_icon_list);
+ ClassDB::bind_method(_MD("set_icon","name","type","texture:Texture"),&Theme::set_icon);
+ ClassDB::bind_method(_MD("get_icon:Texture","name","type"),&Theme::get_icon);
+ ClassDB::bind_method(_MD("has_icon","name","type"),&Theme::has_icon);
+ ClassDB::bind_method(_MD("clear_icon","name","type"),&Theme::clear_icon);
+ ClassDB::bind_method(_MD("get_icon_list","type"),&Theme::_get_icon_list);
- ObjectTypeDB::bind_method(_MD("set_stylebox","name","type","texture:StyleBox"),&Theme::set_stylebox);
- ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Theme::get_stylebox);
- ObjectTypeDB::bind_method(_MD("has_stylebox","name","type"),&Theme::has_stylebox);
- ObjectTypeDB::bind_method(_MD("clear_stylebox","name","type"),&Theme::clear_stylebox);
- ObjectTypeDB::bind_method(_MD("get_stylebox_list","type"),&Theme::_get_stylebox_list);
- ObjectTypeDB::bind_method(_MD("get_stylebox_types"),&Theme::_get_stylebox_types);
+ ClassDB::bind_method(_MD("set_stylebox","name","type","texture:StyleBox"),&Theme::set_stylebox);
+ ClassDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Theme::get_stylebox);
+ ClassDB::bind_method(_MD("has_stylebox","name","type"),&Theme::has_stylebox);
+ ClassDB::bind_method(_MD("clear_stylebox","name","type"),&Theme::clear_stylebox);
+ ClassDB::bind_method(_MD("get_stylebox_list","type"),&Theme::_get_stylebox_list);
+ ClassDB::bind_method(_MD("get_stylebox_types"),&Theme::_get_stylebox_types);
- ObjectTypeDB::bind_method(_MD("set_font","name","type","font:Font"),&Theme::set_font);
- ObjectTypeDB::bind_method(_MD("get_font:Font","name","type"),&Theme::get_font);
- ObjectTypeDB::bind_method(_MD("has_font","name","type"),&Theme::has_font);
- ObjectTypeDB::bind_method(_MD("clear_font","name","type"),&Theme::clear_font);
- ObjectTypeDB::bind_method(_MD("get_font_list","type"),&Theme::_get_font_list);
+ ClassDB::bind_method(_MD("set_font","name","type","font:Font"),&Theme::set_font);
+ ClassDB::bind_method(_MD("get_font:Font","name","type"),&Theme::get_font);
+ ClassDB::bind_method(_MD("has_font","name","type"),&Theme::has_font);
+ ClassDB::bind_method(_MD("clear_font","name","type"),&Theme::clear_font);
+ ClassDB::bind_method(_MD("get_font_list","type"),&Theme::_get_font_list);
- ObjectTypeDB::bind_method(_MD("set_color","name","type","color"),&Theme::set_color);
- ObjectTypeDB::bind_method(_MD("get_color","name","type"),&Theme::get_color);
- ObjectTypeDB::bind_method(_MD("has_color","name","type"),&Theme::has_color);
- ObjectTypeDB::bind_method(_MD("clear_color","name","type"),&Theme::clear_color);
- ObjectTypeDB::bind_method(_MD("get_color_list","type"),&Theme::_get_color_list);
+ ClassDB::bind_method(_MD("set_color","name","type","color"),&Theme::set_color);
+ ClassDB::bind_method(_MD("get_color","name","type"),&Theme::get_color);
+ ClassDB::bind_method(_MD("has_color","name","type"),&Theme::has_color);
+ ClassDB::bind_method(_MD("clear_color","name","type"),&Theme::clear_color);
+ ClassDB::bind_method(_MD("get_color_list","type"),&Theme::_get_color_list);
- ObjectTypeDB::bind_method(_MD("set_constant","name","type","constant"),&Theme::set_constant);
- ObjectTypeDB::bind_method(_MD("get_constant","name","type"),&Theme::get_constant);
- ObjectTypeDB::bind_method(_MD("has_constant","name","type"),&Theme::has_constant);
- ObjectTypeDB::bind_method(_MD("clear_constant","name","type"),&Theme::clear_constant);
- ObjectTypeDB::bind_method(_MD("get_constant_list","type"),&Theme::_get_constant_list);
+ ClassDB::bind_method(_MD("set_constant","name","type","constant"),&Theme::set_constant);
+ ClassDB::bind_method(_MD("get_constant","name","type"),&Theme::get_constant);
+ ClassDB::bind_method(_MD("has_constant","name","type"),&Theme::has_constant);
+ ClassDB::bind_method(_MD("clear_constant","name","type"),&Theme::clear_constant);
+ ClassDB::bind_method(_MD("get_constant_list","type"),&Theme::_get_constant_list);
- ObjectTypeDB::bind_method(_MD("set_default_font","font"),&Theme::set_default_theme_font);
- ObjectTypeDB::bind_method(_MD("get_default_font"),&Theme::get_default_theme_font);
+ ClassDB::bind_method(_MD("set_default_font","font"),&Theme::set_default_theme_font);
+ ClassDB::bind_method(_MD("get_default_font"),&Theme::get_default_theme_font);
- ObjectTypeDB::bind_method(_MD("get_type_list","type"),&Theme::_get_type_list);
+ ClassDB::bind_method(_MD("get_type_list","type"),&Theme::_get_type_list);
- ObjectTypeDB::bind_method(_MD("_emit_theme_changed"),&Theme::_emit_theme_changed);
+ ClassDB::bind_method(_MD("_emit_theme_changed"),&Theme::_emit_theme_changed);
- ObjectTypeDB::bind_method("copy_default_theme",&Theme::copy_default_theme);
+ ClassDB::bind_method("copy_default_theme",&Theme::copy_default_theme);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"default_font",PROPERTY_HINT_RESOURCE_TYPE,"Font"),_SCS("set_default_font"),_SCS("get_default_font"));
@@ -999,7 +999,7 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_origin
ERR_FAIL_V(RES());
}
-// int margin = params[i+ccodes+1].to_int();
+ //int margin = params[i+ccodes+1].to_int();
//sbflat->set_margin_size(Margin(i),margin);
}
} else if (params.size()!=ccodes+1) {
@@ -1147,7 +1147,7 @@ bool ResourceFormatLoaderTheme::handles_type(const String& p_type) const {
String ResourceFormatLoaderTheme::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="theme")
+ if (p_path.get_extension().to_lower()=="theme")
return "Theme";
return "";
}
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 1856bd4979..e9d890cf97 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@
*/
class Theme : public Resource {
- OBJ_TYPE( Theme, Resource );
+ GDCLASS( Theme, Resource );
RES_BASE_EXTENSION("thm");
static Ref<Theme> default_theme;
@@ -72,13 +72,13 @@ protected:
Ref<Font> default_theme_font;
- DVector<String> _get_icon_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_icon_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_stylebox_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_stylebox_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_stylebox_types(void) const { DVector<String> ilret; List<StringName> il; get_stylebox_types(&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_font_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_font_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_color_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_color_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_constant_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_constant_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_type_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_type_list(&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_icon_list(const String& p_type) const { PoolVector<String> ilret; List<StringName> il; get_icon_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_stylebox_list(const String& p_type) const { PoolVector<String> ilret; List<StringName> il; get_stylebox_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_stylebox_types(void) const { PoolVector<String> ilret; List<StringName> il; get_stylebox_types(&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_font_list(const String& p_type) const { PoolVector<String> ilret; List<StringName> il; get_font_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_color_list(const String& p_type) const { PoolVector<String> ilret; List<StringName> il; get_color_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_constant_list(const String& p_type) const { PoolVector<String> ilret; List<StringName> il; get_constant_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ PoolVector<String> _get_type_list(const String& p_type) const { PoolVector<String> ilret; List<StringName> il; get_type_list(&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
static void _bind_methods();
public:
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index bf01929191..c97682f504 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -48,6 +48,8 @@ bool TileSet::_set(const StringName& p_name, const Variant& p_value) {
tile_set_texture_offset(id,p_value);
else if (what=="material")
tile_set_material(id,p_value);
+ else if (what=="modulate")
+ tile_set_modulate(id,p_value);
else if (what=="shape_offset")
tile_set_shape_offset(id,p_value);
else if (what=="region")
@@ -91,6 +93,8 @@ bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{
r_ret=tile_get_texture_offset(id);
else if (what=="material")
r_ret=tile_get_material(id);
+ else if (what=="modulate")
+ r_ret=tile_get_modulate(id);
else if (what=="shape_offset")
r_ret=tile_get_shape_offset(id);
else if (what=="region")
@@ -124,6 +128,7 @@ void TileSet::_get_property_list( List<PropertyInfo> *p_list) const{
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"tex_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"material",PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemMaterial"));
+ p_list->push_back(PropertyInfo(Variant::COLOR,pre+"modulate"));
p_list->push_back(PropertyInfo(Variant::RECT2,pre+"region"));
p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"occluder_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"));
@@ -175,6 +180,20 @@ Ref<CanvasItemMaterial> TileSet::tile_get_material(int p_id) const{
}
+void TileSet::tile_set_modulate(int p_id,const Color &p_modulate) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].modulate=p_modulate;
+ emit_changed();
+
+}
+
+Color TileSet::tile_get_modulate(int p_id) const{
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Color(1,1,1));
+ return tile_map[p_id].modulate;
+}
+
void TileSet::tile_set_texture_offset(int p_id,const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
@@ -407,37 +426,37 @@ void TileSet::clear() {
void TileSet::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_tile","id"),&TileSet::create_tile);
- ObjectTypeDB::bind_method(_MD("tile_set_name","id","name"),&TileSet::tile_set_name);
- ObjectTypeDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name);
- ObjectTypeDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
- ObjectTypeDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
- ObjectTypeDB::bind_method(_MD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material);
- ObjectTypeDB::bind_method(_MD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material);
- ObjectTypeDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
- ObjectTypeDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_shape_offset","id"),&TileSet::tile_get_shape_offset);
- ObjectTypeDB::bind_method(_MD("tile_set_region","id","region"),&TileSet::tile_set_region);
- ObjectTypeDB::bind_method(_MD("tile_get_region","id"),&TileSet::tile_get_region);
- ObjectTypeDB::bind_method(_MD("tile_set_shape","id","shape:Shape2D"),&TileSet::tile_set_shape);
- ObjectTypeDB::bind_method(_MD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape);
- ObjectTypeDB::bind_method(_MD("tile_set_shapes","id","shapes"),&TileSet::_tile_set_shapes);
- ObjectTypeDB::bind_method(_MD("tile_get_shapes","id"),&TileSet::_tile_get_shapes);
- ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset);
- ObjectTypeDB::bind_method(_MD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder);
- ObjectTypeDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder);
- ObjectTypeDB::bind_method(_MD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset);
-
- ObjectTypeDB::bind_method(_MD("remove_tile","id"),&TileSet::remove_tile);
- ObjectTypeDB::bind_method(_MD("clear"),&TileSet::clear);
- ObjectTypeDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
- ObjectTypeDB::bind_method(_MD("find_tile_by_name","name"),&TileSet::find_tile_by_name);
- ObjectTypeDB::bind_method(_MD("get_tiles_ids", "name"), &TileSet::_get_tiles_ids);
+ ClassDB::bind_method(_MD("create_tile","id"),&TileSet::create_tile);
+ ClassDB::bind_method(_MD("tile_set_name","id","name"),&TileSet::tile_set_name);
+ ClassDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name);
+ ClassDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
+ ClassDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
+ ClassDB::bind_method(_MD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material);
+ ClassDB::bind_method(_MD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material);
+ ClassDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
+ ClassDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
+ ClassDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
+ ClassDB::bind_method(_MD("tile_get_shape_offset","id"),&TileSet::tile_get_shape_offset);
+ ClassDB::bind_method(_MD("tile_set_region","id","region"),&TileSet::tile_set_region);
+ ClassDB::bind_method(_MD("tile_get_region","id"),&TileSet::tile_get_region);
+ ClassDB::bind_method(_MD("tile_set_shape","id","shape:Shape2D"),&TileSet::tile_set_shape);
+ ClassDB::bind_method(_MD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape);
+ ClassDB::bind_method(_MD("tile_set_shapes","id","shapes"),&TileSet::_tile_set_shapes);
+ ClassDB::bind_method(_MD("tile_get_shapes","id"),&TileSet::_tile_get_shapes);
+ ClassDB::bind_method(_MD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon);
+ ClassDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon);
+ ClassDB::bind_method(_MD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset);
+ ClassDB::bind_method(_MD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset);
+ ClassDB::bind_method(_MD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder);
+ ClassDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder);
+ ClassDB::bind_method(_MD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset);
+ ClassDB::bind_method(_MD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset);
+
+ ClassDB::bind_method(_MD("remove_tile","id"),&TileSet::remove_tile);
+ ClassDB::bind_method(_MD("clear"),&TileSet::clear);
+ ClassDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
+ ClassDB::bind_method(_MD("find_tile_by_name","name"),&TileSet::find_tile_by_name);
+ ClassDB::bind_method(_MD("get_tiles_ids", "name"), &TileSet::_get_tiles_ids);
}
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index fb0e832c1e..b80889fc6f 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
class TileSet : public Resource {
- OBJ_TYPE( TileSet, Resource );
+ GDCLASS( TileSet, Resource );
struct Data {
@@ -52,6 +52,10 @@ class TileSet : public Resource {
Vector2 navigation_polygon_offset;
Ref<NavigationPolygon> navigation_polygon;
Ref<CanvasItemMaterial> material;
+ Color modulate;
+
+ // Default modulate for back-compat
+ explicit Data() : modulate(1,1,1) {}
};
Map<int,Data> tile_map;
@@ -94,6 +98,9 @@ public:
void tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material);
Ref<CanvasItemMaterial> tile_get_material(int p_id) const;
+ void tile_set_modulate(int p_id,const Color &p_color);
+ Color tile_get_modulate(int p_id) const;
+
void tile_set_occluder_offset(int p_id,const Vector2& p_offset);
Vector2 tile_get_occluder_offset(int p_id) const;
diff --git a/scene/resources/video_stream.cpp b/scene/resources/video_stream.cpp
index 8e16f2e024..84186616d7 100644
--- a/scene/resources/video_stream.cpp
+++ b/scene/resources/video_stream.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h
index b05a7cf773..bcd25c0336 100644
--- a/scene/resources/video_stream.h
+++ b/scene/resources/video_stream.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class VideoStreamPlayback : public Resource {
- OBJ_TYPE(VideoStreamPlayback,Resource);
+ GDCLASS(VideoStreamPlayback,Resource);
protected:
static void _bind_methods();
@@ -77,7 +77,7 @@ public:
class VideoStream : public Resource {
- OBJ_TYPE( VideoStream, Resource );
+ GDCLASS( VideoStream, Resource );
OBJ_SAVE_TYPE( VideoStream ); //children are all saved as AudioStream, so they can be exchanged
public:
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index 0a88abf252..3f7261c312 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@ struct SpatialIndexer {
struct NotifierData {
- AABB aabb;
+ Rect3 aabb;
OctreeElementID id;
};
@@ -64,7 +64,7 @@ struct SpatialIndexer {
uint64_t pass;
uint64_t last_frame;
- void _notifier_add(VisibilityNotifier* p_notifier,const AABB& p_rect) {
+ void _notifier_add(VisibilityNotifier* p_notifier,const Rect3& p_rect) {
ERR_FAIL_COND(notifiers.has(p_notifier));
notifiers[p_notifier].aabb=p_rect;
@@ -73,7 +73,7 @@ struct SpatialIndexer {
}
- void _notifier_update(VisibilityNotifier* p_notifier,const AABB& p_rect) {
+ void _notifier_update(VisibilityNotifier* p_notifier,const Rect3& p_rect) {
Map<VisibilityNotifier*,NotifierData>::Element *E=notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
@@ -246,14 +246,14 @@ void World::_remove_camera(Camera* p_camera){
-void World::_register_notifier(VisibilityNotifier* p_notifier,const AABB& p_rect){
+void World::_register_notifier(VisibilityNotifier* p_notifier,const Rect3& p_rect){
#ifndef _3D_DISABLED
indexer->_notifier_add(p_notifier,p_rect);
#endif
}
-void World::_update_notifier(VisibilityNotifier* p_notifier,const AABB& p_rect){
+void World::_update_notifier(VisibilityNotifier* p_notifier,const Rect3& p_rect){
#ifndef _3D_DISABLED
indexer->_notifier_update(p_notifier,p_rect);
@@ -314,12 +314,12 @@ PhysicsDirectSpaceState *World::get_direct_space_state() {
void World::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_space"),&World::get_space);
- ObjectTypeDB::bind_method(_MD("get_scenario"),&World::get_scenario);
- ObjectTypeDB::bind_method(_MD("get_sound_space"),&World::get_sound_space);
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&World::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&World::get_environment);
- ObjectTypeDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state);
+ ClassDB::bind_method(_MD("get_space"),&World::get_space);
+ ClassDB::bind_method(_MD("get_scenario"),&World::get_scenario);
+ ClassDB::bind_method(_MD("get_sound_space"),&World::get_sound_space);
+ ClassDB::bind_method(_MD("set_environment","env:Environment"),&World::set_environment);
+ ClassDB::bind_method(_MD("get_environment:Environment"),&World::get_environment);
+ ClassDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
}
@@ -332,6 +332,10 @@ World::World() {
sound_space = SpatialSoundServer::get_singleton()->space_create();
PhysicsServer::get_singleton()->space_set_active(space,true);
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/3d/default_gravity",9.8));
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics/3d/default_gravity_vector",Vector3(0,-1,0)));
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics/3d/default_linear_damp",0.1));
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics/3d/default_angular_damp",0.1));
#ifdef _3D_DISABLED
indexer = NULL;
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 5a74f27235..bea07882d7 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -40,7 +40,7 @@ class Camera;
class VisibilityNotifier;
class World : public Resource {
- OBJ_TYPE(World, Resource);
+ GDCLASS(World, Resource);
RES_BASE_EXTENSION("wrd");
private:
RID space;
@@ -60,8 +60,8 @@ friend class VisibilityNotifier;
void _update_camera(Camera* p_camera);
void _remove_camera(Camera* p_camera);
- void _register_notifier(VisibilityNotifier* p_notifier,const AABB& p_rect);
- void _update_notifier(VisibilityNotifier *p_notifier,const AABB& p_rect);
+ void _register_notifier(VisibilityNotifier* p_notifier,const Rect3& p_rect);
+ void _update_notifier(VisibilityNotifier *p_notifier,const Rect3& p_rect);
void _remove_notifier(VisibilityNotifier* p_notifier);
friend class Viewport;
void _update(uint64_t p_frame);
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 4c963da5b4..98c5ae3bb9 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -382,11 +382,11 @@ RID World2D::get_sound_space() {
void World2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_canvas"),&World2D::get_canvas);
- ObjectTypeDB::bind_method(_MD("get_space"),&World2D::get_space);
- ObjectTypeDB::bind_method(_MD("get_sound_space"),&World2D::get_sound_space);
+ ClassDB::bind_method(_MD("get_canvas"),&World2D::get_canvas);
+ ClassDB::bind_method(_MD("get_space"),&World2D::get_space);
+ ClassDB::bind_method(_MD("get_sound_space"),&World2D::get_sound_space);
- ObjectTypeDB::bind_method(_MD("get_direct_space_state:Physics2DDirectSpaceState"),&World2D::get_direct_space_state);
+ ClassDB::bind_method(_MD("get_direct_space_state:Physics2DDirectSpaceState"),&World2D::get_direct_space_state);
}
@@ -404,24 +404,16 @@ World2D::World2D() {
//set space2D to be more friendly with pixels than meters, by adjusting some constants
Physics2DServer::get_singleton()->space_set_active(space,true);
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics_2d/default_gravity",98));
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics_2d/default_gravity_vector",Vector2(0,1)));
+ Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/2d/default_gravity",98));
+ Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics/2d/default_gravity_vector",Vector2(0,1)));
// TODO: Remove this deprecation warning and compatibility code for 2.2 or 3.0
- if (Globals::get_singleton()->get("physics_2d/default_density") && !Globals::get_singleton()->get("physics_2d/default_linear_damp")) {
- WARN_PRINT("Deprecated parameter 'physics_2d/default_density'. It was renamed to 'physics_2d/default_linear_damp', adjusting your project settings accordingly (make sure to adjust scripts that potentially rely on 'physics_2d/default_density'.");
- Globals::get_singleton()->set("physics_2d/default_linear_damp", Globals::get_singleton()->get("physics_2d/default_density"));
- Globals::get_singleton()->set_persisting("physics_2d/default_linear_damp", true);
- Globals::get_singleton()->set_persisting("physics_2d/default_density", false);
- Globals::get_singleton()->save();
+ if (GlobalConfig::get_singleton()->get("physics/2d/default_density") && !GlobalConfig::get_singleton()->get("physics/2d/default_linear_damp")) {
+ WARN_PRINT("Deprecated parameter 'physics/2d/default_density'. It was renamed to 'physics/2d/default_linear_damp', adjusting your project settings accordingly (make sure to adjust scripts that potentially rely on 'physics/2d/default_density'.");
+ GlobalConfig::get_singleton()->set("physics/2d/default_linear_damp", GlobalConfig::get_singleton()->get("physics/2d/default_density"));
+ GlobalConfig::get_singleton()->save();
}
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics_2d/default_linear_damp",0.1));
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics_2d/default_angular_damp",1));
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS,1.0);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION,1.5);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION,0.3);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD,2);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,0.2);
-
+ Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics/2d/default_linear_damp",0.1));
+ Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics/2d/default_angular_damp",1));
indexer = memnew( SpatialIndexer2D );
}
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index a939d935c4..a9110b3bd9 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,7 @@
#include "resource.h"
#include "servers/physics_2d_server.h"
+#include "globals.h"
class SpatialIndexer2D;
class VisibilityNotifier2D;
@@ -38,7 +39,7 @@ class Viewport;
class World2D : public Resource {
- OBJ_TYPE( World2D, Resource );
+ GDCLASS( World2D, Resource );
RID canvas;
RID space;
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index 164ae55c9f..ffa35a93d8 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,32 +43,33 @@ SceneStringNames::SceneStringNames() {
shader_shader=StaticCString::create("shader/shader");
shader_unshaded=StaticCString::create("shader/unshaded");
shading_mode=StaticCString::create("shader/shading_mode");
- enter_tree=StaticCString::create("enter_tree");
- exit_tree=StaticCString::create("exit_tree");
+ tree_entered=StaticCString::create("tree_entered");
+ tree_exited=StaticCString::create("tree_exited");
item_rect_changed=StaticCString::create("item_rect_changed");
size_flags_changed=StaticCString::create("size_flags_changed");
minimum_size_changed=StaticCString::create("minimum_size_changed");
sleeping_state_changed=StaticCString::create("sleeping_state_changed");
finished=StaticCString::create("finished");
+ animation_finished=StaticCString::create("animation_finished");
animation_changed=StaticCString::create("animation_changed");
animation_started=StaticCString::create("animation_started");
- mouse_enter=StaticCString::create("mouse_enter");
- mouse_exit=StaticCString::create("mouse_exit");
+ mouse_entered=StaticCString::create("mouse_entered");
+ mouse_exited=StaticCString::create("mouse_exited");
- focus_enter=StaticCString::create("focus_enter");
- focus_exit=StaticCString::create("focus_exit");
+ focus_entered=StaticCString::create("focus_entered");
+ focus_exited=StaticCString::create("focus_exited");
sort_children = StaticCString::create("sort_children");
- body_enter_shape = StaticCString::create("body_enter_shape");
- body_enter = StaticCString::create("body_enter");
- body_exit_shape = StaticCString::create("body_exit_shape");
- body_exit = StaticCString::create("body_exit");
+ body_shape_entered = StaticCString::create("body_shape_entered");
+ body_entered = StaticCString::create("body_entered");
+ body_shape_exited = StaticCString::create("body_shape_exited");
+ body_exited = StaticCString::create("body_exited");
- area_enter_shape = StaticCString::create("area_enter_shape");
- area_exit_shape = StaticCString::create("area_exit_shape");
+ area_shape_entered = StaticCString::create("area_shape_entered");
+ area_shape_exited = StaticCString::create("area_shape_exited");
_body_inout = StaticCString::create("_body_inout");
_area_inout = StaticCString::create("_area_inout");
@@ -99,14 +100,14 @@ SceneStringNames::SceneStringNames() {
grouped=StaticCString::create("grouped");
ungrouped=StaticCString::create("ungrouped");
- enter_screen=StaticCString::create("enter_screen");
- exit_screen=StaticCString::create("exit_screen");
+ screen_entered=StaticCString::create("screen_entered");
+ screen_exited=StaticCString::create("screen_exited");
- enter_viewport=StaticCString::create("enter_viewport");
- exit_viewport=StaticCString::create("exit_viewport");
+ viewport_entered=StaticCString::create("viewport_entered");
+ viewport_exited=StaticCString::create("viewport_exited");
- enter_camera=StaticCString::create("enter_camera");
- exit_camera=StaticCString::create("exit_camera");
+ camera_entered=StaticCString::create("camera_entered");
+ camera_exited=StaticCString::create("camera_exited");
_body_enter_tree = StaticCString::create("_body_enter_tree");
_body_exit_tree = StaticCString::create("_body_exit_tree");
@@ -116,6 +117,12 @@ SceneStringNames::SceneStringNames() {
_input_event=StaticCString::create("_input_event");
+ gui_input=StaticCString::create("gui_input");
+ _gui_input=StaticCString::create("_gui_input");
+
+ _unhandled_input=StaticCString::create("_unhandled_input");
+ _unhandled_key_input=StaticCString::create("_unhandled_key_input");
+
changed=StaticCString::create("changed");
_shader_changed=StaticCString::create("_shader_changed");
@@ -138,8 +145,8 @@ SceneStringNames::SceneStringNames() {
get_minimum_size=StaticCString::create("get_minimum_size");
- area_enter=StaticCString::create("area_enter");
- area_exit=StaticCString::create("area_exit");
+ area_entered=StaticCString::create("area_entered");
+ area_exited=StaticCString::create("area_exited");
has_point = StaticCString::create("has_point");
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 32e51ce8f4..125d391294 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -54,12 +54,14 @@ public:
StringName visibility_changed;
StringName input_event;
StringName _input_event;
+ StringName gui_input;
+ StringName _gui_input;
StringName item_rect_changed;
StringName shader_shader;
StringName shader_unshaded;
StringName shading_mode;
- StringName enter_tree;
- StringName exit_tree;
+ StringName tree_entered;
+ StringName tree_exited;
StringName size_flags_changed;
StringName minimum_size_changed;
StringName sleeping_state_changed;
@@ -70,24 +72,25 @@ public:
StringName line_separation;
- StringName mouse_enter;
- StringName mouse_exit;
- StringName focus_enter;
- StringName focus_exit;
+ StringName mouse_entered;
+ StringName mouse_exited;
+ StringName focus_entered;
+ StringName focus_exited;
StringName sort_children;
StringName finished;
+ StringName animation_finished;
StringName animation_changed;
StringName animation_started;
- StringName body_enter_shape;
- StringName body_enter;
- StringName body_exit_shape;
- StringName body_exit;
+ StringName body_shape_entered;
+ StringName body_entered;
+ StringName body_shape_exited;
+ StringName body_exited;
- StringName area_enter_shape;
- StringName area_exit_shape;
+ StringName area_shape_entered;
+ StringName area_shape_exited;
StringName _body_inout;
StringName _area_inout;
@@ -105,6 +108,8 @@ public:
StringName _draw;
StringName _input;
StringName _ready;
+ StringName _unhandled_input;
+ StringName _unhandled_key_input;
StringName _pressed;
StringName _toggled;
@@ -123,12 +128,12 @@ public:
StringName can_drop_data;
StringName drop_data;
- StringName enter_screen;
- StringName exit_screen;
- StringName enter_viewport;
- StringName exit_viewport;
- StringName enter_camera;
- StringName exit_camera;
+ StringName screen_entered;
+ StringName screen_exited;
+ StringName viewport_entered;
+ StringName viewport_exited;
+ StringName camera_entered;
+ StringName camera_exited;
StringName _body_enter_tree;
StringName _body_exit_tree;
@@ -156,8 +161,8 @@ public:
StringName _update_remote;
StringName _update_pairs;
- StringName area_enter;
- StringName area_exit;
+ StringName area_entered;
+ StringName area_exited;
StringName get_minimum_size;